Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run golangci-lint in travis-ci #2

Merged
merged 1 commit into from
Nov 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
108 changes: 108 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
run:
timeout: 1m # default 1m
tests: true # default true

linters-settings:
errcheck:
check-type-assertions: true # default false
check-blank: true # default false
ignore: "fmt:.*" # default fmt:.*
exclude: "" # default ""
govet:
enable-all: true
settings:
shadow:
strict: true # default false
structcheck:
exported-fields: true # default false
unused:
check-exported: true # default false
varcheck:
exported-fields: true # default false
dupl:
threshold: 150 # default 150
funlen:
lines: 60 # default 60
statements: 40 # default 40
gocognit:
min-complexity: 10 # minimal code complexity to report, 30 by default (but we recommend 10-20)
goconst:
min-len: 3 # default 3
min-occurrences: 3 # default 3
gocritic:
settings:
captLocal:
paramsOnly: false # default true
elseif:
skipBalanced: false # default true
underef:
skipRecvDeref: false # default true
gocyclo:
min-complexity: 15 # default 30
goimports:
local-prefixes: github.com/maratori/testpackage
golint:
min-confidence: 0.1 # default 0.8
lll:
line-length: 120 # default 120
maligned:
suggest-new: true # default false
misspell:
locale: us
ignore-words: "" # default: ""
nakedret:
max-func-lines: 0 # default 30
prealloc:
simple: false # default true
range-loops: true # default true
for-loops: true # default false
unparam:
check-exported: true # default false
wsl:
strict-append: true # default true
allow-assign-and-call: true # default true
allow-multiline-assign: true # default true
allow-case-trailing-whitespace: true # default true
allow-cuddle-declarations: false # default false

linters:
disable-all: true
enable:
## enabled by default
- deadcode
- errcheck
- gosimple
- govet
- ineffassign
- staticcheck
- structcheck
- typecheck
#- unused # false positives
- varcheck
## disabled by default
- bodyclose
- dupl
- funlen
- gochecknoglobals
- gochecknoinits
- gocognit
- goconst
- gocritic
- gocyclo
- goimports
- golint
- gosec
- lll
- maligned
- misspell
- nakedret
- prealloc
- scopelint
- unconvert
- unparam
- whitespace
- wsl

issues:
max-issues-per-linter: 0
max-same-issues: 0
8 changes: 4 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ env:
matrix:
include:
- go: "1.13.x"
#install:
# - curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.21.0
# - golangci-lint --version
install:
- curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.21.0
- golangci-lint --version
script:
- go test -race -coverpkg ./... -coverprofile=coverage.out ./...

#- golangci-lint run
- golangci-lint run

- echo "Check that go.mod and go.sum are tidy"
- go mod tidy
Expand Down
3 changes: 2 additions & 1 deletion pkg/testpackage/testpackage.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
)

// Analyzer that make you use a separate _test package
var Analyzer = &analysis.Analyzer{
var Analyzer = &analysis.Analyzer{ // nolint:gochecknoglobals,varcheck
Name: "testpackage",
Doc: "linter that make you use a separate _test package",
Run: run,
Expand All @@ -23,5 +23,6 @@ func run(pass *analysis.Pass) (interface{}, error) {
}
}
}

return nil, nil
}
2 changes: 2 additions & 0 deletions pkg/testpackage/testpackage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ func TestAnalyzer_Good(t *testing.T) {
if err != nil {
t.FailNow()
}

analysistest.Run(t, testdata, testpackage.Analyzer)
}

Expand All @@ -22,5 +23,6 @@ func TestAnalyzer_Bad(t *testing.T) {
if err != nil {
t.FailNow()
}

analysistest.Run(t, testdata, testpackage.Analyzer)
}