Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from May 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions pkg/config/issues.go
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
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
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
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