mirror of
https://github.com/mgechev/revive.git
synced 2025-07-05 00:28:53 +02:00
better messages for rules' config errors (#563)
This commit is contained in:
@ -14,17 +14,15 @@ type CognitiveComplexityRule struct{}
|
||||
|
||||
// Apply applies the rule to given file.
|
||||
func (r *CognitiveComplexityRule) Apply(file *lint.File, arguments lint.Arguments) []lint.Failure {
|
||||
var failures []lint.Failure
|
||||
checkNumberOfArguments(1, arguments, r.Name())
|
||||
|
||||
const expectedArgumentsCount = 1
|
||||
if len(arguments) < expectedArgumentsCount {
|
||||
panic(fmt.Sprintf("not enough arguments for cognitive-complexity, expected %d, got %d", expectedArgumentsCount, len(arguments)))
|
||||
}
|
||||
complexity, ok := arguments[0].(int64)
|
||||
if !ok {
|
||||
panic(fmt.Sprintf("invalid argument type for cognitive-complexity, expected int64, got %T", arguments[0]))
|
||||
}
|
||||
|
||||
var failures []lint.Failure
|
||||
|
||||
linter := cognitiveComplexityLinter{
|
||||
file: file,
|
||||
maxComplexity: int(complexity),
|
||||
|
Reference in New Issue
Block a user