mirror of
https://github.com/mgechev/revive.git
synced 2025-11-25 22:12:38 +02:00
Improve the cli formatter
This commit is contained in:
@@ -2,9 +2,9 @@ severity = "warning"
|
|||||||
confidence = 0.8
|
confidence = 0.8
|
||||||
|
|
||||||
[rule.else]
|
[rule.else]
|
||||||
|
severity = "error"
|
||||||
[rule.names]
|
[rule.names]
|
||||||
[rule.argument-limit]
|
[rule.argument-limit]
|
||||||
arguments = [2]
|
arguments = [2]
|
||||||
[rule.cyclomatic]
|
[rule.cyclomatic]
|
||||||
arguments = [3]
|
arguments = [3]
|
||||||
severity = "error"
|
|
||||||
@@ -22,14 +22,13 @@ type CLIFormatter struct {
|
|||||||
|
|
||||||
func formatFailure(failure lint.Failure, severity lint.Severity) []string {
|
func formatFailure(failure lint.Failure, severity lint.Severity) []string {
|
||||||
fString := color.BlueString(failure.Failure)
|
fString := color.BlueString(failure.Failure)
|
||||||
fTypeStr := string(severity)
|
fName := color.RedString(failure.RuleName)
|
||||||
fType := color.RedString(fTypeStr)
|
|
||||||
lineColumn := failure.Position
|
lineColumn := failure.Position
|
||||||
pos := fmt.Sprintf("(%d, %d)", lineColumn.Start.Line, lineColumn.Start.Column)
|
pos := fmt.Sprintf("(%d, %d)", lineColumn.Start.Line, lineColumn.Start.Column)
|
||||||
if severity == lint.SeverityWarning {
|
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.
|
// Format formats the failures gotten from the lint.
|
||||||
|
|||||||
2
main.go
2
main.go
@@ -98,6 +98,7 @@ func main() {
|
|||||||
src := `
|
src := `
|
||||||
package p
|
package p
|
||||||
|
|
||||||
|
// revive:disable:cyclomatic
|
||||||
func Test() {
|
func Test() {
|
||||||
if true || bar && baz {
|
if true || bar && baz {
|
||||||
return 42;
|
return 42;
|
||||||
@@ -105,6 +106,7 @@ func main() {
|
|||||||
return 23;
|
return 23;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// revive:enable:cyclomatic
|
||||||
|
|
||||||
func foo_bar(a int, b int, c int, d int) {
|
func foo_bar(a int, b int, c int, d int) {
|
||||||
return a + b + c;
|
return a + b + c;
|
||||||
|
|||||||
Reference in New Issue
Block a user