Skip to content

dev: enable funlen on repo #668

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

Merged
merged 1 commit into from
Sep 9, 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
39 changes: 34 additions & 5 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
39 changes: 34 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,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
Expand Down
1 change: 1 addition & 0 deletions pkg/commands/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion pkg/golinters/funlen.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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(),
}
}
Expand Down
1 change: 1 addition & 0 deletions pkg/lint/lintersdb/enabled_set_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions pkg/lint/lintersdb/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions pkg/result/processors/nolint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
1 change: 1 addition & 0 deletions test/enabled_linters_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ func getEnabledByDefaultFastLintersWith(with ...string) []string {
return ret
}

//nolint:funlen
func TestEnabledLinters(t *testing.T) {
type tc struct {
name string
Expand Down
2 changes: 1 addition & 1 deletion test/errchk.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down