Skip to content

Commit

Permalink
Fix typos, add golanci-lint check and CI step
Browse files Browse the repository at this point in the history
  • Loading branch information
bombsimon committed Oct 1, 2023
1 parent d35b661 commit b7693d3
Show file tree
Hide file tree
Showing 7 changed files with 117 additions and 7 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/go.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,9 @@ jobs:

- name: Test
run: go test -v ./ -race

lint:
runs-on: ubuntu-latest
steps:
- name: "Run golangci-lint"
uses: golangci/golangci-lint-action@v3
100 changes: 100 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
---
run:
deadline: 1m
issues-exit-code: 1
tests: true

output:
format: colored-line-number
print-issued-lines: false

linters-settings:
misspell:
locale: US

issues:
exclude-use-default: false
max-issues-per-linter: 0
max-same-issues: 0
exclude-rules:
- linters: revive
text: "^package-comments:"

linters:
disable-all: true
enable:
- asasalint
- asciicheck
- bidichk
- containedctx
- contextcheck
- decorder
- dupl
- dupword
- durationcheck
- errcheck
- errchkjson
- errname
- errorlint
- exhaustive
- exportloopref
- forbidigo
- forcetypeassert
- gochecknoglobals
- gochecknoinits
- goconst
- gocritic
- godot
- godox
- goerr113
- gofmt
- gofumpt
- goimports
- gomnd
- gomoddirectives
- gomodguard
- goprintffuncname
- gosec
- gosimple
- gosmopolitan
- govet
- grouper
- importas
- ineffassign
- interfacebloat
- ireturn
- lll
- loggercheck
- makezero
- mirror
- misspell
- musttag
- nakedret
- nilerr
- nilnil
- noctx
- nolintlint
- nonamedreturns
- nosprintfhostport
- prealloc
- predeclared
- promlinter
- reassign
- revive
- rowserrcheck
- sqlclosecheck
- staticcheck
- tagalign
- tagliatelle
- tenv
- testableexamples
- thelper
- typecheck
- unconvert
- unparam
- unused
- usestdlibvars
- wastedassign
- whitespace
- wrapcheck
- wsl
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
[![Go Reference](https://pkg.go.dev/badge/github.com/bombsimon/jtd-infer-go.svg)](https://pkg.go.dev/github.com/bombsimon/jtd-infer-go)
[![Build and test](https://github.com/bombsimon/jtd-infer-go/actions/workflows/go.yaml/badge.svg)](https://github.com/bombsimon/jtd-infer-go/actions/workflows/go.yaml)

This is a port of [`json-typedef-infer`][jtd-infer] Go. The reason for porting
this is that I was in need of JTD inference from code and not as a CLI tool.
This is a port of [`json-typedef-infer`][jtd-infer] for Go. The reason for
porting this is that I was in need of JTD inference from code and not as a CLI
tool.

For more information about JSON Typedef and its RFC and how to use different
kind of hints see [`json-typedef-infer`][jtd-infer]
kind of hints see [`json-typedef-infer`][jtd-infer].

## Usage

Expand Down
5 changes: 3 additions & 2 deletions hints.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ type Hints struct {
Discriminator HintSet
}

// WithoutHints is a shorthand to return empty hints.
func WithoutHints() Hints {
return Hints{}
}

// SubHint will return the sub hints for all hint sets for the passed key.
// SubHints will return the sub hints for all hint sets for the passed key.
func (h Hints) SubHints(key string) Hints {
return Hints{
DefaultNumType: h.DefaultNumType,
Expand Down Expand Up @@ -60,7 +61,7 @@ func (h HintSet) Add(v []string) HintSet {
return h
}

// SubHint will filter all the current sets and keep those who's first element
// SubHints will filter all the current sets and keep those who's first element
// matches the passed key or wildcard.
func (h HintSet) SubHints(key string) HintSet {
filteredValues := [][]string{}
Expand Down
3 changes: 2 additions & 1 deletion inferred_number.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
// JTD.
type NumType uint8

// Available number types.
const (
NumTypeUint8 NumType = iota
NumTypeInt8
Expand Down Expand Up @@ -97,7 +98,7 @@ func (i *InferredNumber) Infer(n float64) *InferredNumber {
}
}

// InfoType will convert an `InferredNumber` to a `jtd.Type`.
// IntoType will convert an `InferredNumber` to a `jtd.Type`.
func (i *InferredNumber) IntoType(defaultType NumType) jtd.Type {
if i.ContainedBy(defaultType) {
return defaultType.IntoType()
Expand Down
1 change: 1 addition & 0 deletions inferred_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
// available types for JTD.
type SchemaType int8

// Available schema types.
const (
SchemaTypeUnknown SchemaType = iota
SchemaTypeAny
Expand Down
2 changes: 1 addition & 1 deletion inferrer.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ type Inferrer struct {
Hints Hints
}

// NewInferred will create a new inferrer with a default `InferredSchema`.
// NewInferrer will create a new inferrer with a default `InferredSchema`.
func NewInferrer(hints Hints) *Inferrer {
return &Inferrer{
Inference: NewInferredSchema(),
Expand Down

0 comments on commit b7693d3

Please sign in to comment.