diff --git a/.golangci.reference.yml b/.golangci.reference.yml index 2ee3375df8b3..4154a77f81cd 100644 --- a/.golangci.reference.yml +++ b/.golangci.reference.yml @@ -402,6 +402,9 @@ linters-settings: # If lower than 0, disable the check. # Default: 40 statements: -1 + # Ignore comments when counting lines. + # Default false + ignore-comments: true gci: # DEPRECATED: use `sections` and `prefix(github.com/org/project)` instead. diff --git a/go.mod b/go.mod index 8008e464e0ea..6fc3b9d69ec5 100644 --- a/go.mod +++ b/go.mod @@ -106,7 +106,7 @@ require ( github.com/timonwong/loggercheck v0.9.4 github.com/tomarrell/wrapcheck/v2 v2.8.1 github.com/tommy-muehle/go-mnd/v2 v2.5.1 - github.com/ultraware/funlen v0.0.3 + github.com/ultraware/funlen v0.1.0 github.com/ultraware/whitespace v0.0.5 github.com/uudashr/gocognit v1.0.7 github.com/valyala/quicktemplate v1.7.0 diff --git a/go.sum b/go.sum index 5385480ec8df..3884c754feda 100644 --- a/go.sum +++ b/go.sum @@ -547,8 +547,8 @@ github.com/tomarrell/wrapcheck/v2 v2.8.1 h1:HxSqDSN0sAt0yJYsrcYVoEeyM4aI9yAm3KQp github.com/tomarrell/wrapcheck/v2 v2.8.1/go.mod h1:/n2Q3NZ4XFT50ho6Hbxg+RV1uyo2Uow/Vdm9NQcl5SE= github.com/tommy-muehle/go-mnd/v2 v2.5.1 h1:NowYhSdyE/1zwK9QCLeRb6USWdoif80Ie+v+yU8u1Zw= github.com/tommy-muehle/go-mnd/v2 v2.5.1/go.mod h1:WsUAkMJMYww6l/ufffCD3m+P7LEvr8TnZn9lwVDlgzw= -github.com/ultraware/funlen v0.0.3 h1:5ylVWm8wsNwH5aWo9438pwvsK0QiqVuUrt9bn7S/iLA= -github.com/ultraware/funlen v0.0.3/go.mod h1:Dp4UiAus7Wdb9KUZsYWZEWiRzGuM2kXM1lPbfaF6xhA= +github.com/ultraware/funlen v0.1.0 h1:BuqclbkY6pO+cvxoq7OsktIXZpgBSkYTQtmwhAK81vI= +github.com/ultraware/funlen v0.1.0/go.mod h1:XJqmOQja6DpxarLj6Jj1U7JuoS8PvL4nEqDaQhy22p4= github.com/ultraware/whitespace v0.0.5 h1:hh+/cpIcopyMYbZNVov9iSxvJU3OYQg78Sfaqzi/CzI= github.com/ultraware/whitespace v0.0.5/go.mod h1:aVMh/gQve5Maj9hQ/hg+F75lr/X5A89uZnzAmWSineA= github.com/uudashr/gocognit v1.0.7 h1:e9aFXgKgUJrQ5+bs61zBigmj7bFJ/5cC6HmMahVzuDo= diff --git a/pkg/config/linters_settings.go b/pkg/config/linters_settings.go index 0fc503254d40..805d0ff4736b 100644 --- a/pkg/config/linters_settings.go +++ b/pkg/config/linters_settings.go @@ -380,8 +380,9 @@ func (p *ForbidigoPattern) MarshalString() ([]byte, error) { } type FunlenSettings struct { - Lines int - Statements int + Lines int + Statements int + IgnoreComments bool `mapstructure:"ignore-comments"` } type GciSettings struct { diff --git a/pkg/golinters/funlen.go b/pkg/golinters/funlen.go index aae1623c7f19..8def9c1f678a 100644 --- a/pkg/golinters/funlen.go +++ b/pkg/golinters/funlen.go @@ -52,7 +52,7 @@ func NewFunlen(settings *config.FunlenSettings) *goanalysis.Linter { func runFunlen(pass *analysis.Pass, settings *config.FunlenSettings) []goanalysis.Issue { var lintIssues []funlen.Message for _, file := range pass.Files { - fileIssues := funlen.Run(file, pass.Fset, settings.Lines, settings.Statements) + fileIssues := funlen.Run(file, pass.Fset, settings.Lines, settings.Statements, settings.IgnoreComments) lintIssues = append(lintIssues, fileIssues...) }