revive: convert hard coded excludes into default exclude patterns (#1938)

This commit is contained in:
Ludovic Fernandez 2021-05-01 18:40:56 +02:00 committed by GitHub
parent cd9d8bb739
commit 34ffdc243f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 7 deletions

View File

@ -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 {

View File

@ -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
}

View File

@ -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

View File

@ -7,7 +7,7 @@ import (
"time"
)
func testRevive(t *time.Duration) error {
func SampleRevive(t *time.Duration) error {
if t == nil {
return nil
} else {