Skip to content

Commit

Permalink
feat(revive): convert hard coded into default exclude patterns
Browse files Browse the repository at this point in the history
  • Loading branch information
ldez committed Apr 30, 2021
1 parent 12ed5fa commit e7ac86b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
12 changes: 12 additions & 0 deletions pkg/config/issues.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
7 changes: 1 addition & 6 deletions pkg/golinters/revive.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
}

Expand Down
2 changes: 2 additions & 0 deletions test/testdata/configs/revive.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/testdata/revive.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"time"
)

func testRevive(t *time.Duration) error {
func SampleRevive(t *time.Duration) error {
if t == nil {
return nil
} else {
Expand Down

0 comments on commit e7ac86b

Please sign in to comment.