From e7ac86bb83d99991b38483ca69795094f181341d Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Mon, 26 Apr 2021 17:23:53 +0200 Subject: [PATCH] feat(revive): convert hard coded into default exclude patterns --- pkg/config/issues.go | 12 ++++++++++++ pkg/golinters/revive.go | 7 +------ test/testdata/configs/revive.yml | 2 ++ test/testdata/revive.go | 2 +- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/pkg/config/issues.go b/pkg/config/issues.go index 82455e02c6a7..b84a61962c86 100644 --- a/pkg/config/issues.go +++ b/pkg/config/issues.go @@ -77,6 +77,18 @@ var DefaultExcludePatterns = []ExcludePattern{ Linter: "stylecheck", Why: "Annoying issue about not having a comment. The rare codebase has such comments", }, + { + ID: "EXC0012", + Pattern: "exported (method|function|type|const) (.+) should have comment or be unexported", + Linter: "revive", + Why: "Annoying issue about not having a comment. The rare codebase has such comments", + }, + { + ID: "EXC0013", + Pattern: `package comment should be of the form "Package (.+) ..."`, + Linter: "revive", + Why: "Annoying issue about not having a comment. The rare codebase has such comments", + }, } type Issues struct { diff --git a/pkg/golinters/revive.go b/pkg/golinters/revive.go index 6622aab3db57..c3a135adae9f 100644 --- a/pkg/golinters/revive.go +++ b/pkg/golinters/revive.go @@ -29,7 +29,7 @@ type jsonObject struct { lint.Failure `json:",inline"` } -// NewNewRevive returns a new Revive linter. +// NewRevive returns a new Revive linter. func NewRevive(cfg *config.ReviveSettings) *goanalysis.Linter { var issues []goanalysis.Issue @@ -157,11 +157,6 @@ func getReviveConfig(cfg *config.ReviveSettings) (*lint.Config, error) { normalizeConfig(conf) - // By default golangci-lint ignores missing doc comments, follow same convention by removing this default rule - // Relevant issue: https://github.com/golangci/golangci-lint/issues/456 - delete(conf.Rules, "package-comments") - delete(conf.Rules, "exported") - return conf, nil } diff --git a/test/testdata/configs/revive.yml b/test/testdata/configs/revive.yml index acbcd18e46ae..5c0c60561db7 100644 --- a/test/testdata/configs/revive.yml +++ b/test/testdata/configs/revive.yml @@ -3,6 +3,8 @@ linters-settings: ignore-generated-header: true severity: warning rules: + - name: exported + - name: package-comments - name: cognitive-complexity arguments: [ 7 ] - name: line-length-limit diff --git a/test/testdata/revive.go b/test/testdata/revive.go index ce6a396e7b14..814d7ae9046e 100644 --- a/test/testdata/revive.go +++ b/test/testdata/revive.go @@ -7,7 +7,7 @@ import ( "time" ) -func testRevive(t *time.Duration) error { +func SampleRevive(t *time.Duration) error { if t == nil { return nil } else {