Skip to content

Commit 6864b2f

Browse files
authored
dev: enable funlen on repo (#668)
1 parent 0b49095 commit 6864b2f

File tree

10 files changed

+77
-13
lines changed

10 files changed

+77
-13
lines changed

.golangci.yml

+34-5
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,43 @@ linters-settings:
3939
disabled-checks:
4040
- wrapperFunc
4141
- dupImport # https://github.com/go-critic/go-critic/issues/845
42+
funlen:
43+
lines: 70
4244

4345
linters:
44-
enable-all: true
45-
disable:
46-
- maligned
47-
- prealloc
48-
- gochecknoglobals
46+
# inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint
47+
disable-all: true
48+
enable:
49+
- bodyclose
50+
- deadcode
51+
- depguard
52+
- dupl
53+
- errcheck
4954
- funlen
55+
- gochecknoinits
56+
- goconst
57+
- gocritic
58+
- gocyclo
59+
- gofmt
60+
- goimports
61+
- golint
62+
- gosec
63+
- gosimple
64+
- govet
65+
- ineffassign
66+
- interfacer
67+
- lll
68+
- misspell
69+
- nakedret
70+
- scopelint
71+
- staticcheck
72+
- structcheck
73+
- stylecheck
74+
- typecheck
75+
- unconvert
76+
- unparam
77+
- unused
78+
- varcheck
5079

5180
run:
5281
skip-dirs:

README.md

+34-5
Original file line numberDiff line numberDiff line change
@@ -859,14 +859,43 @@ linters-settings:
859859
disabled-checks:
860860
- wrapperFunc
861861
- dupImport # https://github.com/go-critic/go-critic/issues/845
862+
funlen:
863+
lines: 70
862864
863865
linters:
864-
enable-all: true
865-
disable:
866-
- maligned
867-
- prealloc
868-
- gochecknoglobals
866+
# inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint
867+
disable-all: true
868+
enable:
869+
- bodyclose
870+
- deadcode
871+
- depguard
872+
- dupl
873+
- errcheck
869874
- funlen
875+
- gochecknoinits
876+
- goconst
877+
- gocritic
878+
- gocyclo
879+
- gofmt
880+
- goimports
881+
- golint
882+
- gosec
883+
- gosimple
884+
- govet
885+
- ineffassign
886+
- interfacer
887+
- lll
888+
- misspell
889+
- nakedret
890+
- scopelint
891+
- staticcheck
892+
- structcheck
893+
- stylecheck
894+
- typecheck
895+
- unconvert
896+
- unparam
897+
- unused
898+
- varcheck
870899
871900
run:
872901
skip-dirs:

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ require (
5151
github.com/spf13/pflag v1.0.1
5252
github.com/spf13/viper v1.0.2
5353
github.com/stretchr/testify v1.2.2
54-
github.com/ultraware/funlen v0.0.1
5554
github.com/timakin/bodyclose v0.0.0-00010101000000-87058b9bfcec
55+
github.com/ultraware/funlen v0.0.1
5656
github.com/valyala/quicktemplate v1.1.1
5757
golang.org/x/crypto v0.0.0-20190313024323-a1f597ede03a // indirect
5858
golang.org/x/sys v0.0.0-20190312061237-fead79001313 // indirect

pkg/commands/run.go

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ func wh(text string) string {
4545
return color.GreenString(text)
4646
}
4747

48+
//nolint:funlen
4849
func initFlagSet(fs *pflag.FlagSet, cfg *config.Config, m *lintersdb.Manager, isFinalInit bool) {
4950
hideFlag := func(name string) {
5051
if err := fs.MarkHidden(name); err != nil {

pkg/golinters/funlen.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package golinters
33
import (
44
"context"
55
"go/token"
6+
"strings"
67

78
"github.com/golangci/golangci-lint/pkg/lint/linter"
89
"github.com/golangci/golangci-lint/pkg/result"
@@ -37,7 +38,7 @@ func (f Funlen) Run(ctx context.Context, lintCtx *linter.Context) ([]result.Issu
3738
Filename: i.Pos.Filename,
3839
Line: i.Pos.Line,
3940
},
40-
Text: i.Message,
41+
Text: strings.TrimRight(i.Message, "\n"),
4142
FromLinter: f.Name(),
4243
}
4344
}

pkg/lint/lintersdb/enabled_set_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"github.com/golangci/golangci-lint/pkg/lint/linter"
1313
)
1414

15+
//nolint:funlen
1516
func TestGetEnabledLintersSet(t *testing.T) {
1617
type cs struct {
1718
cfg config.Linters

pkg/lint/lintersdb/manager.go

+1
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ func (Manager) GetMetaLinters() map[string]linter.MetaLinter {
7777
return ret
7878
}
7979

80+
//nolint:funlen
8081
func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
8182
var govetCfg *config.GovetSettings
8283
if m.cfg != nil {

pkg/result/processors/nolint_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ func getOkLogger(ctrl *gomock.Controller) *logutils.MockLog {
4848
return log
4949
}
5050

51+
//nolint:funlen
5152
func TestNolint(t *testing.T) {
5253
ctrl := gomock.NewController(t)
5354
defer ctrl.Finish()

test/enabled_linters_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ func getEnabledByDefaultFastLintersWith(with ...string) []string {
7474
return ret
7575
}
7676

77+
//nolint:funlen
7778
func TestEnabledLinters(t *testing.T) {
7879
type tc struct {
7980
name string

test/errchk.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222
//
2323
// Sources files are supplied as fullshort slice.
2424
// It consists of pairs: full path to source file and its base name.
25-
//nolint:gocyclo
25+
//nolint:gocyclo,funlen
2626
func errorCheck(outStr string, wantAuto bool, fullshort ...string) (err error) {
2727
var errs []error
2828
out := splitOutput(outStr, wantAuto)

0 commit comments

Comments
 (0)