1
0
mirror of https://github.com/mgechev/revive.git synced 2025-02-01 13:07:44 +02:00

Code cleaunp (#905)

* fix minor lint issue

* fix package comments

* fix comments

* removes extra empty lines

* fix import alias name
This commit is contained in:
chavacava 2023-09-23 10:41:34 +02:00 committed by GitHub
parent 50091409c0
commit 5ccebe86c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 22 additions and 8 deletions

View File

@ -1,3 +1,4 @@
// Package cli implements the revive command line application.
package cli
import (

View File

@ -1,3 +1,4 @@
// Package config implements revive's configuration data structures and related methods
package config
import (

View File

@ -3,7 +3,7 @@ package formatter
import (
"bytes"
"encoding/xml"
plainTemplate "text/template"
plain "text/template"
"github.com/mgechev/revive/lint"
)
@ -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
}

2
formatter/doc.go Normal file
View File

@ -0,0 +1,2 @@
// Package formatter implements the linter output formatters.
package formatter

View File

@ -3,6 +3,7 @@ package lint
// 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.

2
lint/doc.go Normal file
View File

@ -0,0 +1,2 @@
// Package lint implements the linting machinery.
package lint

View File

@ -1,3 +1,4 @@
// Package logging provides a logger and related methods.
package logging
import (

View File

@ -1,3 +1,4 @@
// Package main is the build entry point of revive.
package main
import "github.com/mgechev/revive/cli"

View File

@ -1,3 +1,4 @@
// Package revivelib provides revive's linting functionality as a lib.
package revivelib
import (

View File

@ -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
@ -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)
@ -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"
}

View File

@ -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

View File

@ -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
}

2
rule/doc.go Normal file
View File

@ -0,0 +1,2 @@
// Package rule implements revive's linting rules.
package rule

View File

@ -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
}

View File

@ -8,7 +8,6 @@ import (
)
func TestCommentSpacings(t *testing.T) {
testRule(t, "comment-spacings", &rule.CommentSpacingsRule{}, &lint.RuleConfig{
Arguments: []interface{}{"myOwnDirective"}},
)

2
test/doc.go Normal file
View File

@ -0,0 +1,2 @@
// Package test implements rule tests.
package test

View File

@ -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
}