-
Notifications
You must be signed in to change notification settings - Fork 54
CHANGE: @W-17321151@: Only show fields in detail view of rules command if they are non-empty #1684
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 |
|---|---|---|
|
|
@@ -38,14 +38,31 @@ export class RuleDetailDisplayer extends AbstractRuleDisplayer { | |
| const rule = rules[i]; | ||
| const header = getMessage(BundleName.RuleViewer, 'summary.detail.header', [i + 1, rule.getName()]); | ||
| const severity = rule.getSeverityLevel(); | ||
|
|
||
| const body = { | ||
| engine: rule.getEngineName(), | ||
| severity: `${severity.valueOf()} (${SeverityLevel[severity]})`, | ||
| tags: rule.getTags().join(', '), | ||
| resources: rule.getResourceUrls().join(', '), | ||
| description: rule.getDescription() | ||
| engine: rule.getEngineName(), | ||
| }; | ||
| const keys = ['severity', 'engine', 'tags', 'resources', 'description']; | ||
| const keys: string[] = ['severity', 'engine']; | ||
|
|
||
| if (rule.getTags().length > 0) { | ||
| body['tags'] = rule.getTags().join(', '); | ||
| keys.push('tags'); | ||
| } | ||
|
|
||
| if (rule.getResourceUrls().length == 1) { | ||
| body['resource'] = rule.getResourceUrls()[0]; | ||
| keys.push('resource'); | ||
| } else if (rule.getResourceUrls().length > 1) { | ||
| body['resources'] = rule.getResourceUrls(); | ||
| keys.push('resources'); | ||
| } | ||
|
|
||
| if (rule.getDescription().length > 0) { | ||
| body['description'] = rule.getDescription(); | ||
| keys.push('description'); | ||
| } | ||
|
Comment on lines
+61
to
+64
Contributor
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. Genuine question: Why is it valid for a rule to have no description? That seems like it should be a required property.
Contributor
Author
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. IDK... if people don't put in a description in their custom PMD that might occur. |
||
|
|
||
| styledRules.push(toStyledHeaderAndBody(header, body, keys)); | ||
| } | ||
| this.display.displayLog(styledRules.join('\n\n')); | ||
|
|
||
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 think there might be value in having a tag-less rule display with
tags: noneor something like that.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.
You'll have to ask John and Marcelino if that's what they want. Last I heard, we just wanted to hide the fields if they were empty.