From 430ebdef8b43d3e652b951448b770cff9a9a6dbc Mon Sep 17 00:00:00 2001 From: Mario Carrion Date: Sat, 23 Mar 2019 23:11:38 -0400 Subject: [PATCH] replace gometalinter with golangci-lint --- .circleci/config.yml | 14 ++++++++++++-- .go-version | 1 + .golangci.yml | 9 +++++++++ Dockerfile | 11 ----------- README.md | 3 ++- break_comments_test.go | 5 +---- consts_test.go | 5 +---- funcs_test.go | 2 +- imports.go | 2 +- imports_test.go | 5 +---- methods_test.go | 5 +---- nit_test.go | 4 ++-- tools.json | 6 +++++- types_test.go | 5 +---- vars_test.go | 5 +---- 15 files changed, 39 insertions(+), 43 deletions(-) create mode 100644 .go-version create mode 100644 .golangci.yml diff --git a/.circleci/config.yml b/.circleci/config.yml index 39079de..061137f 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -17,7 +17,16 @@ jobs: - checkout - run: go build github.com/MarioCarrion/nit/testdata - run: go build github.com/MarioCarrion/nit/cmd/nit - lint: + golint: + docker: + - image: golangci/golangci-lint:v1.15 + working_directory: /go/src/github.com/MarioCarrion/nit + environment: + CGO_ENABLED: 0 + steps: + - checkout + - run: golangci-lint run ./... + nitlint: docker: - image: mariocarrion/nit:v0.1.1 working_directory: /go/src/github.com/MarioCarrion/nit @@ -41,7 +50,8 @@ workflows: jobs: - test - build - - lint + - golint + - nitlint release: jobs: - release: diff --git a/.go-version b/.go-version new file mode 100644 index 0000000..3d0e623 --- /dev/null +++ b/.go-version @@ -0,0 +1 @@ +1.11.4 diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..cd70b17 --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,9 @@ +linters: + enable-all: true + +issues: + exclude-rules: + - path: _test\.go + linters: + - scopelint + - gocritic diff --git a/Dockerfile b/Dockerfile index 326e2ed..fbeb637 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,14 +5,3 @@ WORKDIR / COPY ./ ./go/src/github.com/MarioCarrion/nit RUN CGO_ENABLED=0 GOOS=linux go build --ldflags="-s" -a -installsuffix cgo -o /go/bin/nit ./go/src/github.com/MarioCarrion/nit/cmd/nit - -#-- - -FROM supinf/gometalinter:2.0.11 - -COPY --from=0 /go/bin/* /go/bin/ - -WORKDIR /go/src - -ENTRYPOINT ["gometalinter"] -CMD ["--help"] diff --git a/README.md b/README.md index 18e93be..f0389fb 100644 --- a/README.md +++ b/README.md @@ -33,4 +33,5 @@ A really, really nitpicking linter that complains when the code is not organized ### Development -Requires [`dep`](https://github.com/golang/dep), you can use [retool](https://github.com/twitchtv/retool) for installing that dependency. +* Requires [`dep`](https://github.com/golang/dep), you can use [retool](https://github.com/twitchtv/retool) for installing that dependency. +* [goenv](https://github.com/syndbg/goenv) is used for versioning Go. diff --git a/break_comments_test.go b/break_comments_test.go index 0dcbab9..7a5fb4e 100644 --- a/break_comments_test.go +++ b/break_comments_test.go @@ -23,10 +23,7 @@ func TestBreakComments(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(ts *testing.T) { - f, fset, err := newParserFile(ts, tt.filename) - if err != nil { - ts.Fatalf("expected no error, got %s", err) - } + f, fset := newParserFile(ts, tt.filename) var actual []int diff --git a/consts_test.go b/consts_test.go index af28501..e9a71d3 100644 --- a/consts_test.go +++ b/consts_test.go @@ -49,10 +49,7 @@ func TestConstsValidator_Validate(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(ts *testing.T) { - f, fset, err := newParserFile(ts, tt.filename) - if err != nil { - ts.Fatalf("expected no error, got %s", err) - } + f, fset := newParserFile(ts, tt.filename) for _, s := range f.Decls { switch g := s.(type) { diff --git a/funcs_test.go b/funcs_test.go index 73b79b0..c3f8b77 100644 --- a/funcs_test.go +++ b/funcs_test.go @@ -50,7 +50,7 @@ func TestFuncsValidator_Validate(t *testing.T) { fset *token.FileSet ) - f, fset, err = newParserFile(ts, tt.filename) + f, fset = newParserFile(ts, tt.filename) if err != nil { ts.Fatalf("expected no error, got %s", err) } diff --git a/imports.go b/imports.go index 836f437..3504e20 100644 --- a/imports.go +++ b/imports.go @@ -197,7 +197,7 @@ func (externalImportsTransition) Local() (ImportsTransition, error) { } func (externalImportsTransition) Standard() (ImportsTransition, error) { - return nil, errors.New("standard imports is invalid, next one must be external or local.") + return nil, errors.New("standard imports is invalid, next one must be external or local") } //- diff --git a/imports_test.go b/imports_test.go index 310163c..6d12c2b 100644 --- a/imports_test.go +++ b/imports_test.go @@ -80,10 +80,7 @@ func TestImportsValidator(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(ts *testing.T) { - f, fset, err := newParserFile(ts, tt.filename) - if err != nil { - ts.Fatalf("expected no error, got %s", err) - } + f, fset := newParserFile(ts, tt.filename) for _, s := range f.Decls { switch g := s.(type) { diff --git a/methods_test.go b/methods_test.go index a6ba716..6ca59cc 100644 --- a/methods_test.go +++ b/methods_test.go @@ -69,10 +69,7 @@ func TestMethodsValidator_Validate(t *testing.T) { validator *nit.MethodsValidator ) - f, fset, err = newParserFile(ts, tt.filename) - if err != nil { - ts.Fatalf("expected no error, got %s", err) - } + f, fset = newParserFile(ts, tt.filename) comments := nit.NewBreakComments(fset, f.Comments) diff --git a/nit_test.go b/nit_test.go index dcdc914..7b6cd38 100644 --- a/nit_test.go +++ b/nit_test.go @@ -8,7 +8,7 @@ import ( "testing" ) -func newParserFile(t *testing.T, name string) (*ast.File, *token.FileSet, error) { +func newParserFile(t *testing.T, name string) (*ast.File, *token.FileSet) { t.Helper() fset := token.NewFileSet() @@ -17,5 +17,5 @@ func newParserFile(t *testing.T, name string) (*ast.File, *token.FileSet, error) t.Fatalf("expected no error, got %s", err) } - return f, fset, nil + return f, fset } diff --git a/tools.json b/tools.json index a6b6c87..98be1e7 100644 --- a/tools.json +++ b/tools.json @@ -3,7 +3,11 @@ { "Repository": "github.com/golang/dep/cmd/dep", "Commit": "224a564abe296670b692fe08bb63a3e4c4ad7978" + }, + { + "Repository": "github.com/golangci/golangci-lint/cmd/golangci-lint", + "Commit": "901cf25e20f86b7e9dc6f73eaba5afbd0cbdc257" } ], - "RetoolVersion": "1.3.5" + "RetoolVersion": "1.3.7" } \ No newline at end of file diff --git a/types_test.go b/types_test.go index d5a4ebb..302dbc4 100644 --- a/types_test.go +++ b/types_test.go @@ -44,10 +44,7 @@ func TestTypesValidator_Validate(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(ts *testing.T) { - f, fset, err := newParserFile(ts, tt.filename) - if err != nil { - ts.Fatalf("expected no error, got %s", err) - } + f, fset := newParserFile(ts, tt.filename) for _, s := range f.Decls { switch g := s.(type) { diff --git a/vars_test.go b/vars_test.go index fb1a0e0..4abcad3 100644 --- a/vars_test.go +++ b/vars_test.go @@ -44,10 +44,7 @@ func TestVarsValidator_Validate(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(ts *testing.T) { - f, fset, err := newParserFile(ts, tt.filename) - if err != nil { - ts.Fatalf("expected no error, got %s", err) - } + f, fset := newParserFile(ts, tt.filename) for _, s := range f.Decls { switch g := s.(type) {