JS-540 Persist ESLint-suppressed findings as accepted issues#7123
JS-540 Persist ESLint-suppressed findings as accepted issues#7123zglicz wants to merge 5 commits into
Conversation
Agentic Analysis: Early ResultsAgentic Analysis and Context Augmentation are available on your project. Here are some issues that could have been prevented. Follow the links to learn how to put them into action. 3 issue(s) found across 2 file(s):
Analyzed by SonarQube Agentic Analysis in 4.5 s |
| .getSensorContext() | ||
| .newIssueResolution() | ||
| .on(file) | ||
| .at(file.selectLine(issue.getLine())) |
There was a problem hiding this comment.
⚠️ Bug: saveAcceptedIssueResolution crashes when issue.getLine() is 0
In saveAcceptedIssueResolution (line 654), file.selectLine(issue.getLine()) is called unconditionally. If a suppressed issue has line == 0 (the protobuf default for unset int32 fields), this will throw an IllegalArgumentException because SonarQube line indexing is 1-based. The existing saveIssue method at line 485 has a guard (issue.getLine() != 0) before calling selectLine, but saveAcceptedIssueResolution lacks this check. While the try/catch in saveSuppressedIssues will prevent a crash, the issue resolution will silently fail to save.
Add a guard for line == 0 before calling selectLine, matching the pattern in saveIssue:
private void saveAcceptedIssueResolution(JsTsContext<?> context, Issue issue, RuleKey ruleKey) {
if (issue.getLine() == 0) {
LOG.warn("Cannot save issue resolution for rule {} without a valid line", ruleKey);
return;
}
context
.getSensorContext()
.newIssueResolution()
.on(file)
.at(file.selectLine(issue.getLine()))
.status(IssueResolution.Status.DEFAULT)
.forRules(List.of(ruleKey))
.comment(issue.getResolutionComment())
.save();
}
- Apply fix
Check the box to apply the fix or reply for a change | Was this helpful? React with 👍 / 👎
Ruling Report✅ No changes to ruling expected issues in this PR |
|
Code Review
|
| Auto-apply | Compact | Unblock |
|
|
|
Was this helpful? React with 👍 / 👎 | Gitar




Summary
Testing
Summary by Gitar
appendSuccessfulFileResultinpackages/grpc/src/transformers/response.ts.packages/analysis/src/jsts/linter/issues/transform.tsusing logical OR operator.its/ruling/src/test/expected/to reflect changes in suppressed issue reporting.This will update automatically on new commits.