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

NEW (Extension) @W-13992309@ Remove duplicate suppress violations prompts on the same line #92

Merged
merged 3 commits into from
Jun 6, 2024

Conversation

jag-j
Copy link
Collaborator

@jag-j jag-j commented Jun 5, 2024

This PR does the following:

  1. Shows only one "suppress warning" per line on the editor and in the "Problems" tab per line even if there are multiple violations were found on a line. Previously, multiple "suppress warning"s would show up and they all would add the same "// NOPMD" tag.
  2. Additionally, this PR also clears all the diagnostics on the line automatically. We do this by changing the removeSingleDiagnostics command to a more generic removeDiagnosticsInRange that clears all diagnostics in a given range.

@@ -92,8 +92,8 @@ export async function activate(context: vscode.ExtensionContext): Promise<vscode
outputChannel
});
});
const removeSingleDiagnostic = vscode.commands.registerCommand(Constants.COMMAND_REMOVE_SINGLE_DIAGNOSTIC, (uri: vscode.Uri, diagnostic: vscode.Diagnostic) => {
_removeSingleDiagnostic(uri, diagnostic, diagnosticCollection);
const removeDiagnosticsInRange = vscode.commands.registerCommand(Constants.COMMAND_DIAGNOSTICS_IN_RANGE, (uri: vscode.Uri, range: vscode.Range) => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

For a better user experience, we should remove all diagnostics on a given line (or even a set of lines). That's because "// NOPMD" is generic and not specific to a rule. So, a line could have both apexdoc and unused var error and both should go away with the "// NOPMD" tag. This wasn't specifically called out in the acceptance criteria or anywhere else, but I think this is the right thing to do.

const fixes: vscode.CodeAction[] = [];
if (this.documentSupportsLineLevelSuppression()) {
fixes.push(this.generateLineLevelSuppression());
const lineNumber = this.diagnostic.range.start.line;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is the main change. Even if we have multiple violations on a single line, we show only one "suppress violation" and that would add the "// NOPMD" tag.

@jag-j jag-j marked this pull request as draft June 5, 2024 21:40
@jag-j jag-j marked this pull request as draft June 5, 2024 21:40
@jag-j jag-j marked this pull request as ready for review June 6, 2024 14:15
@jag-j jag-j merged commit ee902a0 into dev Jun 6, 2024
7 checks passed
@jag-j jag-j deleted the jj/W-13992309 branch June 6, 2024 15:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants