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:
parent
47ba3e360c
commit
6545203e2d
@ -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,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
2
testdata/cyclomatic-2.go
vendored
2
testdata/cyclomatic-2.go
vendored
@ -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 {
|
||||
|
4
testdata/cyclomatic.go
vendored
4
testdata/cyclomatic.go
vendored
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user