-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
feat(severity): color warning severity, non-zero exit when issue != default severity #2595
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,16 +14,18 @@ import ( | |
|
||
type Text struct { | ||
printIssuedLine bool | ||
printSeverity bool | ||
useColors bool | ||
printLinterName bool | ||
|
||
log logutils.Log | ||
w io.Writer | ||
} | ||
|
||
func NewText(printIssuedLine, useColors, printLinterName bool, log logutils.Log, w io.Writer) *Text { | ||
func NewText(printIssuedLine, useColors, printLinterName, printSeverity bool, log logutils.Log, w io.Writer) *Text { | ||
return &Text{ | ||
printIssuedLine: printIssuedLine, | ||
printSeverity: printSeverity, | ||
useColors: useColors, | ||
printLinterName: printLinterName, | ||
log: log, | ||
|
@@ -56,10 +58,18 @@ func (p *Text) Print(ctx context.Context, issues []result.Issue) error { | |
} | ||
|
||
func (p Text) printIssue(i *result.Issue) { | ||
text := p.SprintfColored(color.FgRed, "%s", strings.TrimSpace(i.Text)) | ||
issueColor := color.FgRed | ||
if i.Severity == "warning" { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm sure this isn't great because this seems to attach to specific severity levels -- which I don't see well defined in this repository. Let me know if we want to define coloring a different way, if at all. I like this, personally. |
||
issueColor = color.FgYellow | ||
} | ||
|
||
text := p.SprintfColored(issueColor, "%s", strings.TrimSpace(i.Text)) | ||
if p.printLinterName { | ||
text += fmt.Sprintf(" (%s)", i.FromLinter) | ||
} | ||
if p.printSeverity { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The only time I really found this useful is if coloring is turned off, so I'm happy to remove it / restructure this. |
||
text += fmt.Sprintf(" %s", i.Severity) | ||
} | ||
pos := p.SprintfColored(color.Bold, "%s:%d", i.FilePath(), i.Line()) | ||
if i.Pos.Column != 0 { | ||
pos += fmt.Sprintf(":%d", i.Pos.Column) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really like this
print-severity
field in general, but I want to try to maintain older behaviour if possible. I was thinking of adding something likeexit-non-zero-severity
to replace the default severity field usage in this PR. Still need to look at this codebase more to figure out how that's implemented.