1
0
mirror of https://github.com/mgechev/revive.git synced 2024-11-21 17:16:40 +02:00

refactor(cyclomatic): improved message for cyclomatic rule (#629)

This commit is contained in:
Oleg Butuzov 2022-01-31 18:33:43 +02:00 committed by GitHub
parent 47ba3e360c
commit 6545203e2d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 5 deletions

View File

@ -62,8 +62,9 @@ func (w lintCyclomatic) Visit(_ ast.Node) ast.Visitor {
w.onFailure(lint.Failure{
Confidence: 1,
Category: "maintenance",
Failure: fmt.Sprintf("function %s has cyclomatic complexity %d", funcName(fn), c),
Node: fn,
Failure: fmt.Sprintf("function %s has cyclomatic complexity %d (> max enabled %d)",
funcName(fn), c, w.complexity),
Node: fn,
})
}
}

View File

@ -5,7 +5,7 @@ package pkg
import "log"
func f(x int) bool { // MATCH /function f has cyclomatic complexity 4/
func f(x int) bool { // MATCH /function f has cyclomatic complexity 4 (> max enabled 3)/
if x > 0 && true || false {
return true
} else {

View File

@ -5,7 +5,7 @@ package pkg
import "log"
func f(x int) bool { // MATCH /function f has cyclomatic complexity 4/
func f(x int) bool { // MATCH /function f has cyclomatic complexity 4 (> max enabled 1)/
if x > 0 && true || false {
return true
} else {
@ -14,7 +14,7 @@ func f(x int) bool { // MATCH /function f has cyclomatic complexity 4/
return false
}
func g(f func() bool) string { // MATCH /function g has cyclomatic complexity 2/
func g(f func() bool) string { // MATCH /function g has cyclomatic complexity 2 (> max enabled 1)/
if ok := f(); ok {
return "it's okay"
} else {