1
0
mirror of https://github.com/mgechev/revive.git synced 2024-11-24 08:32:22 +02:00

Improve the cli formatter

This commit is contained in:
mgechev 2018-01-27 11:52:36 -08:00
parent 22d1e33541
commit a227153bc2
3 changed files with 7 additions and 6 deletions

View File

@ -2,9 +2,9 @@ severity = "warning"
confidence = 0.8
[rule.else]
severity = "error"
[rule.names]
[rule.argument-limit]
arguments = [2]
[rule.cyclomatic]
arguments = [3]
severity = "error"
arguments = [3]

View File

@ -22,14 +22,13 @@ type CLIFormatter struct {
func formatFailure(failure lint.Failure, severity lint.Severity) []string {
fString := color.BlueString(failure.Failure)
fTypeStr := string(severity)
fType := color.RedString(fTypeStr)
fName := color.RedString(failure.RuleName)
lineColumn := failure.Position
pos := fmt.Sprintf("(%d, %d)", lineColumn.Start.Line, lineColumn.Start.Column)
if severity == lint.SeverityWarning {
fType = color.YellowString(fTypeStr)
fName = color.YellowString(failure.RuleName)
}
return []string{failure.GetFilename(), pos, fType, fString}
return []string{failure.GetFilename(), pos, fName, fString}
}
// Format formats the failures gotten from the lint.

View File

@ -98,6 +98,7 @@ func main() {
src := `
package p
// revive:disable:cyclomatic
func Test() {
if true || bar && baz {
return 42;
@ -105,6 +106,7 @@ func main() {
return 23;
}
}
// revive:enable:cyclomatic
func foo_bar(a int, b int, c int, d int) {
return a + b + c;