1
0
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:
chavacava
2023-09-23 10:41:34 +02:00
committed by GitHub
parent 50091409c0
commit 5ccebe86c2
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 package cli
import ( import (

View File

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

View File

@ -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
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. // 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
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 package logging
import ( import (

View File

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

View File

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

View File

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

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. // 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

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") 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
View File

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

View File

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

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