From 6864b2f764b823f3f8805bae40e973e23e7be473 Mon Sep 17 00:00:00 2001 From: Isaev Denis Date: Mon, 9 Sep 2019 18:07:09 +0300 Subject: [PATCH] dev: enable funlen on repo (#668) --- .golangci.yml | 39 ++++++++++++++++++++++---- README.md | 39 ++++++++++++++++++++++---- go.mod | 2 +- pkg/commands/run.go | 1 + pkg/golinters/funlen.go | 3 +- pkg/lint/lintersdb/enabled_set_test.go | 1 + pkg/lint/lintersdb/manager.go | 1 + pkg/result/processors/nolint_test.go | 1 + test/enabled_linters_test.go | 1 + test/errchk.go | 2 +- 10 files changed, 77 insertions(+), 13 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index c412cefa8a7a..a3066ad68614 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -39,14 +39,43 @@ linters-settings: disabled-checks: - wrapperFunc - dupImport # https://github.com/go-critic/go-critic/issues/845 + funlen: + lines: 70 linters: - enable-all: true - disable: - - maligned - - prealloc - - gochecknoglobals + # inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint + disable-all: true + enable: + - bodyclose + - deadcode + - depguard + - dupl + - errcheck - funlen + - gochecknoinits + - goconst + - gocritic + - gocyclo + - gofmt + - goimports + - golint + - gosec + - gosimple + - govet + - ineffassign + - interfacer + - lll + - misspell + - nakedret + - scopelint + - staticcheck + - structcheck + - stylecheck + - typecheck + - unconvert + - unparam + - unused + - varcheck run: skip-dirs: diff --git a/README.md b/README.md index 16b81b64a69f..5e78f360696a 100644 --- a/README.md +++ b/README.md @@ -859,14 +859,43 @@ linters-settings: disabled-checks: - wrapperFunc - dupImport # https://github.com/go-critic/go-critic/issues/845 + funlen: + lines: 70 linters: - enable-all: true - disable: - - maligned - - prealloc - - gochecknoglobals + # inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint + disable-all: true + enable: + - bodyclose + - deadcode + - depguard + - dupl + - errcheck - funlen + - gochecknoinits + - goconst + - gocritic + - gocyclo + - gofmt + - goimports + - golint + - gosec + - gosimple + - govet + - ineffassign + - interfacer + - lll + - misspell + - nakedret + - scopelint + - staticcheck + - structcheck + - stylecheck + - typecheck + - unconvert + - unparam + - unused + - varcheck run: skip-dirs: diff --git a/go.mod b/go.mod index 431c43067350..aa462b3b4399 100644 --- a/go.mod +++ b/go.mod @@ -51,8 +51,8 @@ require ( github.com/spf13/pflag v1.0.1 github.com/spf13/viper v1.0.2 github.com/stretchr/testify v1.2.2 - github.com/ultraware/funlen v0.0.1 github.com/timakin/bodyclose v0.0.0-00010101000000-87058b9bfcec + github.com/ultraware/funlen v0.0.1 github.com/valyala/quicktemplate v1.1.1 golang.org/x/crypto v0.0.0-20190313024323-a1f597ede03a // indirect golang.org/x/sys v0.0.0-20190312061237-fead79001313 // indirect diff --git a/pkg/commands/run.go b/pkg/commands/run.go index 597d26d65233..f5e0a666553b 100644 --- a/pkg/commands/run.go +++ b/pkg/commands/run.go @@ -45,6 +45,7 @@ func wh(text string) string { return color.GreenString(text) } +//nolint:funlen func initFlagSet(fs *pflag.FlagSet, cfg *config.Config, m *lintersdb.Manager, isFinalInit bool) { hideFlag := func(name string) { if err := fs.MarkHidden(name); err != nil { diff --git a/pkg/golinters/funlen.go b/pkg/golinters/funlen.go index 1a24e24584d6..c5768ec36b74 100644 --- a/pkg/golinters/funlen.go +++ b/pkg/golinters/funlen.go @@ -3,6 +3,7 @@ package golinters import ( "context" "go/token" + "strings" "github.com/golangci/golangci-lint/pkg/lint/linter" "github.com/golangci/golangci-lint/pkg/result" @@ -37,7 +38,7 @@ func (f Funlen) Run(ctx context.Context, lintCtx *linter.Context) ([]result.Issu Filename: i.Pos.Filename, Line: i.Pos.Line, }, - Text: i.Message, + Text: strings.TrimRight(i.Message, "\n"), FromLinter: f.Name(), } } diff --git a/pkg/lint/lintersdb/enabled_set_test.go b/pkg/lint/lintersdb/enabled_set_test.go index 2e72b67375ee..fdde6bd54a37 100644 --- a/pkg/lint/lintersdb/enabled_set_test.go +++ b/pkg/lint/lintersdb/enabled_set_test.go @@ -12,6 +12,7 @@ import ( "github.com/golangci/golangci-lint/pkg/lint/linter" ) +//nolint:funlen func TestGetEnabledLintersSet(t *testing.T) { type cs struct { cfg config.Linters diff --git a/pkg/lint/lintersdb/manager.go b/pkg/lint/lintersdb/manager.go index c19b1dfb1852..0b5effdc7494 100644 --- a/pkg/lint/lintersdb/manager.go +++ b/pkg/lint/lintersdb/manager.go @@ -77,6 +77,7 @@ func (Manager) GetMetaLinters() map[string]linter.MetaLinter { return ret } +//nolint:funlen func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config { var govetCfg *config.GovetSettings if m.cfg != nil { diff --git a/pkg/result/processors/nolint_test.go b/pkg/result/processors/nolint_test.go index a3fd0ad2efe0..fac2100f1455 100644 --- a/pkg/result/processors/nolint_test.go +++ b/pkg/result/processors/nolint_test.go @@ -48,6 +48,7 @@ func getOkLogger(ctrl *gomock.Controller) *logutils.MockLog { return log } +//nolint:funlen func TestNolint(t *testing.T) { ctrl := gomock.NewController(t) defer ctrl.Finish() diff --git a/test/enabled_linters_test.go b/test/enabled_linters_test.go index 2b85ab17b3b3..77d759feb491 100644 --- a/test/enabled_linters_test.go +++ b/test/enabled_linters_test.go @@ -74,6 +74,7 @@ func getEnabledByDefaultFastLintersWith(with ...string) []string { return ret } +//nolint:funlen func TestEnabledLinters(t *testing.T) { type tc struct { name string diff --git a/test/errchk.go b/test/errchk.go index d8717a86bbf5..18612866b7bf 100644 --- a/test/errchk.go +++ b/test/errchk.go @@ -22,7 +22,7 @@ import ( // // Sources files are supplied as fullshort slice. // It consists of pairs: full path to source file and its base name. -//nolint:gocyclo +//nolint:gocyclo,funlen func errorCheck(outStr string, wantAuto bool, fullshort ...string) (err error) { var errs []error out := splitOutput(outStr, wantAuto)