Skip to content

Commit

Permalink
dev: enable funlen on repo (#668)
Browse files Browse the repository at this point in the history
  • Loading branch information
jirfag committed Sep 9, 2019
1 parent 0b49095 commit 6864b2f
Show file tree
Hide file tree
Showing 10 changed files with 77 additions and 13 deletions.
39 changes: 34 additions & 5 deletions .golangci.yml
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
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
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions pkg/commands/run.go
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
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
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
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
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
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
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

0 comments on commit 6864b2f

Please sign in to comment.