mirror of
https://github.com/mgechev/revive.git
synced 2025-11-23 22:04:49 +02:00
Refactoring
This commit is contained in:
@@ -5,14 +5,14 @@ import (
|
||||
"go/ast"
|
||||
"strconv"
|
||||
|
||||
"github.com/mgechev/revive/linter"
|
||||
"github.com/mgechev/revive/lint"
|
||||
)
|
||||
|
||||
// ArgumentsLimitRule lints given else constructs.
|
||||
type ArgumentsLimitRule struct{}
|
||||
|
||||
// Apply applies the rule to given file.
|
||||
func (r *ArgumentsLimitRule) Apply(file *linter.File, arguments linter.Arguments) []linter.Failure {
|
||||
func (r *ArgumentsLimitRule) Apply(file *lint.File, arguments lint.Arguments) []lint.Failure {
|
||||
if len(arguments) != 1 {
|
||||
panic(`invalid configuration for "argument-limit"`)
|
||||
}
|
||||
@@ -21,11 +21,11 @@ func (r *ArgumentsLimitRule) Apply(file *linter.File, arguments linter.Arguments
|
||||
panic(`invalid configuration for "argument-limit"`)
|
||||
}
|
||||
|
||||
var failures []linter.Failure
|
||||
var failures []lint.Failure
|
||||
|
||||
walker := lintArgsNum{
|
||||
total: total,
|
||||
onFailure: func(failure linter.Failure) {
|
||||
onFailure: func(failure lint.Failure) {
|
||||
failures = append(failures, failure)
|
||||
},
|
||||
}
|
||||
@@ -42,7 +42,7 @@ func (r *ArgumentsLimitRule) Name() string {
|
||||
|
||||
type lintArgsNum struct {
|
||||
total int64
|
||||
onFailure func(linter.Failure)
|
||||
onFailure func(lint.Failure)
|
||||
}
|
||||
|
||||
func (w lintArgsNum) Visit(n ast.Node) ast.Visitor {
|
||||
@@ -50,7 +50,7 @@ func (w lintArgsNum) Visit(n ast.Node) ast.Visitor {
|
||||
if ok {
|
||||
num := int64(len(node.Type.Params.List))
|
||||
if num > w.total {
|
||||
w.onFailure(linter.Failure{
|
||||
w.onFailure(lint.Failure{
|
||||
Failure: fmt.Sprintf("maximum number of arguments per function exceeded; max %d but got %d", w.total, num),
|
||||
Node: node.Type,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user