Skip to content
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

CHANGE (CodeAnalyzer): @W-14009441@: create output file when no violations are found #1170

Merged
merged 4 commits into from
Sep 8, 2023

Conversation

MrEminent42
Copy link
Contributor

  • Removes the "no violations found" message. Instead, when there are no violations, outputs an empty version of appropriate template/format to the console (to file when requested)
    • Note: SFCA will now create an empty file when an outfile is specified and no violations are found.
  • Edits existing automated tests to support the above behavior.

@W-14009441@: fill in fake header for csv output

@W-14009441@: clean comments/documentation

@W-14009441@: fix ancillary tests
@MrEminent42 MrEminent42 marked this pull request as ready for review September 5, 2023 17:50
@@ -1,7 +1,6 @@
module.exports = {
"output": {
"engineSummaryTemplate": "Executed %s, found %s violation(s) across %s file(s).",
"noViolationsDetected": "Executed engines: %s. No rule violations found.",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This message is now no longer used, anywhere. Instead, the above message is used. If there are no violations, a message similar to Executed sfge, found 0 violation(s) across 0 file(s) is printed.

Comment on lines -31 to -40
const {minSev, summaryMap, results} = rrr;
// If the results are an empty string, it means no violations were found.
if (results === '') {
// Build an appropriate message...
const msg = messages.getMessage('output.noViolationsDetected', [[...summaryMap.keys()].join(', ')]);
// ...log it to the console...
this.ux.log(msg);
// ...and return it for use with the --json flag.
return msg;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing this shortcut return is the main change here. The logic below works fine with 0 violations, it now returns [] when there are no violations, instead of an empty string.

Most of the other changes in this PR are a result of removing these lines. The other changes involve updating the automated tests.

test/lib/util/RunOutputProcessor.test.ts Outdated Show resolved Hide resolved
test/lib/RuleManager.test.ts Show resolved Hide resolved
test/lib/RuleManager.test.ts Outdated Show resolved Hide resolved
test/commands/scanner/run.test.ts Outdated Show resolved Hide resolved
test/commands/scanner/run.test.ts Show resolved Hide resolved
test/commands/scanner/run.test.ts Outdated Show resolved Hide resolved
test/commands/scanner/run.test.ts Outdated Show resolved Hide resolved
test/commands/scanner/run.test.ts Outdated Show resolved Hide resolved
test/commands/scanner/run.filters.test.ts Outdated Show resolved Hide resolved
@jfeingold35 jfeingold35 merged commit d75174d into forcedotcom:dev Sep 8, 2023
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants