Skip to content

Commit

Permalink
replaces obsolete golint with staticcheck
Browse files Browse the repository at this point in the history
Signed-off-by: Springcomp <[email protected]>
  • Loading branch information
springcomp committed Oct 28, 2024
1 parent 6eb5a34 commit 950377b
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 19 deletions.
27 changes: 20 additions & 7 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,31 @@ jobs:
run: go mod download
- name: Tests
run: make test
- name: Install golint
if: ${{ matrix.go-version == '1.17' }}
run: |
make install-dev-cmds
make check

static-check:
name: Run Static Checks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.18'
- name: Install deps
run: go mod download
- name: go vet ./...
run: go vet ./...
# TODO: improve with caching
- uses: dominikh/[email protected]
with:
version: "2022.1.1"
install-go: false
min-go-version: "1.18"

golangci-lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: golangci-lint
uses: golangci/golangci-lint-action@aaa42aa0628b4ae2578232a66b541047968fac86 # v6.1.0
8 changes: 2 additions & 6 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,21 @@ linters:
- bodyclose
- containedctx
- contextcheck
- copyloopvar
# - cyclop
# - deadcode
- decorder
# - depguard
- dogsled
- dupl
- dupword
- durationcheck
- errcheck
- errchkjson
- errname
# - errorlint
- execinquery
# - exhaustive
# - exhaustivestruct
# - exhaustruct
- exportloopref
# - forbidigo
# - forcetypeassert
# - funlen
Expand All @@ -38,8 +36,6 @@ linters:
# - goerr113
- gofmt
- gofumpt


- prealloc
# - predeclared
- promlinter
Expand All @@ -48,7 +44,7 @@ linters:
- rowserrcheck
# - scopelint
- sqlclosecheck
- staticcheck
# - staticcheck
# - structcheck
- stylecheck
- tagliatelle
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ test: build

check:
go vet ./...
golint ./...
staticcheck ./...
golangci-lint run

htmlc:
Expand All @@ -42,6 +42,6 @@ pprof-cpu:
go tool pprof ./go-jmespath.test ./cpu.out

install-dev-cmds:
go install golang.org/x/lint/golint@latest
go install honnef.co/go/tools/cmd/staticcheck@latest
go install golang.org/x/tools/cmd/stringer@latest
command -v golangci-lint || { curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $$(go env GOPATH)/bin v1.46.2; }
6 changes: 3 additions & 3 deletions pkg/interpreter/interpreter.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ import (
var DefaultFunctionCaller FunctionCaller = NewFunctionCaller(functions.GetDefaultFunctions()...)

/*
This is a tree based interpreter. It walks the AST and directly
interprets the AST to search through a JSON document.
Interpreter is a tree based interpreter.
It walks and interprets the AST directly
to search through a JSON document.
*/
type Interpreter interface {
Execute(parsing.ASTNode, any, ...Option) (any, error)
Expand Down
2 changes: 1 addition & 1 deletion pkg/parsing/lexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func (lexer *Lexer) peek() rune {
return t
}

// tokenize takes an expression and returns corresponding tokens.
// Tokenize takes an expression and returns corresponding tokens.
func (lexer *Lexer) Tokenize(expression string) ([]token, error) {
var tokens []token
lexer.expression = expression
Expand Down
3 changes: 3 additions & 0 deletions pkg/util/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ func TestSlicePositiveStep(t *testing.T) {
result, err := Slice(input, []SliceParam{{0, true}, {3, true}, {1, true}})
assert.Nil(err)
assert.Equal(input[:3], result)
if err == err {
assert.Nil(err)
}
}

func TestIsFalseJSONTypes(t *testing.T) {
Expand Down
34 changes: 34 additions & 0 deletions staticcheck.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
checks = [
"all",
"-SA9003",
"-ST1000",
"-ST1003",
"-ST1016",
"-ST1020",
"-ST1021",
"-ST1022",
"-ST1023",
]
initialisms = [
"ACL", "AMQP", "API", "ASCII",
"CPU", "CSS",
"DB", "DNS",
"EOF",
"GID", "GUID",
"HTML", "HTTP", "HTTPS",
"ID", "IP",
"JSON",
"QPS",
"RAM", "RPC", "RTP",
"SIP", "SLA", "SMTP", "SQL", "SSH",
"TCP", "TLS", "TS", "TTL",
"UDP", "UI", "UID", "UUID", "URI", "URL", "UTF8",
"VM",
"XML", "XMPP", "XSRF", "XSS",
]
dot_import_whitelist = [
"github.com/mmcloughlin/avo/build",
"github.com/mmcloughlin/avo/operand",
"github.com/mmcloughlin/avo/reg"
]
http_status_code_whitelist = ["200", "400", "404", "500"]

0 comments on commit 950377b

Please sign in to comment.