Skip to content

Commit e7ac86b

Browse files
committed
feat(revive): convert hard coded into default exclude patterns
1 parent 12ed5fa commit e7ac86b

File tree

4 files changed

+16
-7
lines changed

4 files changed

+16
-7
lines changed

Diff for: pkg/config/issues.go

+12
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,18 @@ var DefaultExcludePatterns = []ExcludePattern{
7777
Linter: "stylecheck",
7878
Why: "Annoying issue about not having a comment. The rare codebase has such comments",
7979
},
80+
{
81+
ID: "EXC0012",
82+
Pattern: "exported (method|function|type|const) (.+) should have comment or be unexported",
83+
Linter: "revive",
84+
Why: "Annoying issue about not having a comment. The rare codebase has such comments",
85+
},
86+
{
87+
ID: "EXC0013",
88+
Pattern: `package comment should be of the form "Package (.+) ..."`,
89+
Linter: "revive",
90+
Why: "Annoying issue about not having a comment. The rare codebase has such comments",
91+
},
8092
}
8193

8294
type Issues struct {

Diff for: pkg/golinters/revive.go

+1-6
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ type jsonObject struct {
2929
lint.Failure `json:",inline"`
3030
}
3131

32-
// NewNewRevive returns a new Revive linter.
32+
// NewRevive returns a new Revive linter.
3333
func NewRevive(cfg *config.ReviveSettings) *goanalysis.Linter {
3434
var issues []goanalysis.Issue
3535

@@ -157,11 +157,6 @@ func getReviveConfig(cfg *config.ReviveSettings) (*lint.Config, error) {
157157

158158
normalizeConfig(conf)
159159

160-
// By default golangci-lint ignores missing doc comments, follow same convention by removing this default rule
161-
// Relevant issue: https://github.com/golangci/golangci-lint/issues/456
162-
delete(conf.Rules, "package-comments")
163-
delete(conf.Rules, "exported")
164-
165160
return conf, nil
166161
}
167162

Diff for: test/testdata/configs/revive.yml

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ linters-settings:
33
ignore-generated-header: true
44
severity: warning
55
rules:
6+
- name: exported
7+
- name: package-comments
68
- name: cognitive-complexity
79
arguments: [ 7 ]
810
- name: line-length-limit

Diff for: test/testdata/revive.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"time"
88
)
99

10-
func testRevive(t *time.Duration) error {
10+
func SampleRevive(t *time.Duration) error {
1111
if t == nil {
1212
return nil
1313
} else {

0 commit comments

Comments
 (0)