mirror of
https://github.com/mgechev/revive.git
synced 2025-07-17 01:12:27 +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:
@ -1,3 +1,4 @@
|
|||||||
|
// Package cli implements the revive command line application.
|
||||||
package cli
|
package cli
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
// Package config implements revive's configuration data structures and related methods
|
||||||
package config
|
package config
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -3,7 +3,7 @@ package formatter
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/xml"
|
"encoding/xml"
|
||||||
plainTemplate "text/template"
|
plain "text/template"
|
||||||
|
|
||||||
"github.com/mgechev/revive/lint"
|
"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)
|
issues[fn] = append(issues[fn], iss)
|
||||||
}
|
}
|
||||||
|
|
||||||
t, err := plainTemplate.New("revive").Parse(checkstyleTemplate)
|
t, err := plain.New("revive").Parse(checkstyleTemplate)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
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.
|
// Arguments is type used for the arguments of a rule.
|
||||||
type Arguments = []interface{}
|
type Arguments = []interface{}
|
||||||
|
|
||||||
|
// FileFilters is type used for modeling file filters to apply to rules.
|
||||||
type FileFilters = []*FileFilter
|
type FileFilters = []*FileFilter
|
||||||
|
|
||||||
// RuleConfig is type used for the rule configuration.
|
// 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
|
package logging
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
1
main.go
1
main.go
@ -1,3 +1,4 @@
|
|||||||
|
// Package main is the build entry point of revive.
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import "github.com/mgechev/revive/cli"
|
import "github.com/mgechev/revive/cli"
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
// Package revivelib provides revive's linting functionality as a lib.
|
||||||
package revivelib
|
package revivelib
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -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 {
|
func (r *CommentSpacingsRule) Apply(file *lint.File, args lint.Arguments) []lint.Failure {
|
||||||
r.configure(args)
|
r.configure(args)
|
||||||
|
|
||||||
@ -74,6 +75,7 @@ func (r *CommentSpacingsRule) Apply(file *lint.File, args lint.Arguments) []lint
|
|||||||
return failures
|
return failures
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Name yields this rule name.
|
||||||
func (*CommentSpacingsRule) Name() string {
|
func (*CommentSpacingsRule) Name() string {
|
||||||
return "comment-spacings"
|
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.
|
// 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) {
|
func checkMethodName(holder string, id *ast.Ident, w *lintConfusingNames) {
|
||||||
|
|
||||||
if id.Name == "init" && holder == defaultStructName {
|
if id.Name == "init" && holder == defaultStructName {
|
||||||
// ignore init functions
|
// ignore init functions
|
||||||
return
|
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")
|
w.newFailure("be careful when deferring calls to methods without pointer receiver", fn, 0.8, "bad practice", "method-call")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
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
|
@ -8,7 +8,6 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestCommentSpacings(t *testing.T) {
|
func TestCommentSpacings(t *testing.T) {
|
||||||
|
|
||||||
testRule(t, "comment-spacings", &rule.CommentSpacingsRule{}, &lint.RuleConfig{
|
testRule(t, "comment-spacings", &rule.CommentSpacingsRule{}, &lint.RuleConfig{
|
||||||
Arguments: []interface{}{"myOwnDirective"}},
|
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
|
Reference in New Issue
Block a user