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:
parent
50091409c0
commit
5ccebe86c2
@ -1,3 +1,4 @@
|
||||
// Package cli implements the revive command line application.
|
||||
package cli
|
||||
|
||||
import (
|
||||
|
@ -1,3 +1,4 @@
|
||||
// Package config implements revive's configuration data structures and related methods
|
||||
package config
|
||||
|
||||
import (
|
||||
|
@ -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
2
formatter/doc.go
Normal file
@ -0,0 +1,2 @@
|
||||
// Package formatter implements the linter output formatters.
|
||||
package formatter
|
@ -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
2
lint/doc.go
Normal file
@ -0,0 +1,2 @@
|
||||
// Package lint implements the linting machinery.
|
||||
package lint
|
@ -1,3 +1,4 @@
|
||||
// Package logging provides a logger and related methods.
|
||||
package logging
|
||||
|
||||
import (
|
||||
|
1
main.go
1
main.go
@ -1,3 +1,4 @@
|
||||
// Package main is the build entry point of revive.
|
||||
package main
|
||||
|
||||
import "github.com/mgechev/revive/cli"
|
||||
|
@ -1,3 +1,4 @@
|
||||
// Package revivelib provides revive's linting functionality as a lib.
|
||||
package revivelib
|
||||
|
||||
import (
|
||||
|
@ -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"
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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
2
rule/doc.go
Normal file
@ -0,0 +1,2 @@
|
||||
// Package rule implements revive's linting rules.
|
||||
package rule
|
@ -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
|
||||
}
|
||||
|
@ -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
2
test/doc.go
Normal file
@ -0,0 +1,2 @@
|
||||
// Package test implements rule tests.
|
||||
package test
|
@ -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
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user