revive: convert hard coded excludes into default exclude patterns (#1938)
This commit is contained in:
parent
cd9d8bb739
commit
34ffdc243f
@ -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 {
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
2
test/testdata/configs/revive.yml
vendored
2
test/testdata/configs/revive.yml
vendored
@ -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
|
||||
|
2
test/testdata/revive.go
vendored
2
test/testdata/revive.go
vendored
@ -7,7 +7,7 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
func testRevive(t *time.Duration) error {
|
||||
func SampleRevive(t *time.Duration) error {
|
||||
if t == nil {
|
||||
return nil
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user