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

Code cleaunp #905

Merged
merged 5 commits into from
Sep 23, 2023
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cli/main.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Package cli implements the revive command line application.
package cli

import (
Expand Down
1 change: 1 addition & 0 deletions config/config.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Package config implements revive's configuration data structures and related methods
package config

import (
Expand Down
4 changes: 2 additions & 2 deletions formatter/checkstyle.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package formatter
import (
"bytes"
"encoding/xml"
plainTemplate "text/template"
plain "text/template"

"github.com/mgechev/revive/lint"
)
Expand Down Expand Up @@ -50,7 +50,7 @@ func (*Checkstyle) Format(failures <-chan lint.Failure, config lint.Config) (str
issues[fn] = append(issues[fn], iss)
}

t, err := plainTemplate.New("revive").Parse(checkstyleTemplate)
t, err := plain.New("revive").Parse(checkstyleTemplate)
if err != nil {
return "", err
}
Expand Down
2 changes: 2 additions & 0 deletions formatter/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Package formatter implements the linter output formatters.
package formatter
1 change: 1 addition & 0 deletions lint/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// Arguments is type used for the arguments of a rule.
type Arguments = []interface{}

// FileFilters is type used for modeling file filters to apply to rules.
type FileFilters = []*FileFilter

// RuleConfig is type used for the rule configuration.
Expand Down Expand Up @@ -32,7 +33,7 @@
type RulesConfig = map[string]RuleConfig

// MustExclude - checks if given filename `name` must be excluded
func (rcfg *RuleConfig) MustExclude(name string) bool {

Check warning on line 36 in lint/config.go

View workflow job for this annotation

GitHub Actions / Lint

receiver name rcfg should be consistent with previous receiver name rc for RuleConfig
for _, exclude := range rcfg.excludeFilters {
if exclude.MatchFileName(name) {
return true
Expand Down
2 changes: 2 additions & 0 deletions lint/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Package lint implements the linting machinery.
package lint
1 change: 1 addition & 0 deletions logging/logger.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Package logging provides a logger and related methods.
package logging

import (
Expand Down
1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Package main is the build entry point of revive.
package main

import "github.com/mgechev/revive/cli"
Expand Down
1 change: 1 addition & 0 deletions revivelib/core.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Package revivelib provides revive's linting functionality as a lib.
package revivelib

import (
Expand Down
4 changes: 3 additions & 1 deletion rule/comment-spacings.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/mgechev/revive/lint"
)

// CommentSpacings Rule check the whether there is a space between
// CommentSpacingsRule check the whether there is a space between
// the comment symbol( // ) and the start of the comment text
type CommentSpacingsRule struct {
allowList []string
Expand Down Expand Up @@ -36,6 +36,7 @@ func (r *CommentSpacingsRule) configure(arguments lint.Arguments) {
}
}

// Apply the rule.
func (r *CommentSpacingsRule) Apply(file *lint.File, args lint.Arguments) []lint.Failure {
r.configure(args)

Expand Down Expand Up @@ -74,6 +75,7 @@ func (r *CommentSpacingsRule) Apply(file *lint.File, args lint.Arguments) []lint
return failures
}

// Name yields this rule name.
func (*CommentSpacingsRule) Name() string {
return "comment-spacings"
}
Expand Down
1 change: 0 additions & 1 deletion rule/confusing-naming.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ func (*ConfusingNamingRule) Name() string {

// checkMethodName checks if a given method/function name is similar (just case differences) to other method/function of the same struct/file.
func checkMethodName(holder string, id *ast.Ident, w *lintConfusingNames) {

if id.Name == "init" && holder == defaultStructName {
// ignore init functions
return
Expand Down
2 changes: 1 addition & 1 deletion rule/defer.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ func (w lintDeferRule) Visit(node ast.Node) ast.Visitor {
w.newFailure("be careful when deferring calls to methods without pointer receiver", fn, 0.8, "bad practice", "method-call")
}
}

}

return nil
}

Expand Down
2 changes: 2 additions & 0 deletions rule/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Package rule implements revive's linting rules.
package rule
2 changes: 1 addition & 1 deletion rule/struct-tag.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func (lintStructTagRule) getTagName(tag *structtag.Tag) string {
return strings.TrimPrefix(option, "name=")
}
}
return "" //protobuf tag lacks 'name' option
return "" // protobuf tag lacks 'name' option
default:
return tag.Name
}
Expand Down
1 change: 0 additions & 1 deletion test/comment-spacings_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
)

func TestCommentSpacings(t *testing.T) {

testRule(t, "comment-spacings", &rule.CommentSpacingsRule{}, &lint.RuleConfig{
Arguments: []interface{}{"myOwnDirective"}},
)
Expand Down
2 changes: 2 additions & 0 deletions test/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Package test implements rule tests.
package test
2 changes: 1 addition & 1 deletion test/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func assertFailures(t *testing.T, baseDir string, fi os.FileInfo, src []byte, ru
copy(failures[i:], failures[i+1:])
failures = failures[:len(failures)-1]

//t.Logf("/%v/ matched at %s:%d", in.Match, fi.Name(), in.Line)
// t.Logf("/%v/ matched at %s:%d", in.Match, fi.Name(), in.Line)
ok = true
break
}
Expand Down
Loading