Skip to content

SONARJAVA-5397 Support the import of custom checkstyle issues - #6059

Open
aurelien-coet-sonarsource wants to merge 2 commits into
masterfrom
ac/SONARJAVA-5397
Open

SONARJAVA-5397 Support the import of custom checkstyle issues#6059
aurelien-coet-sonarsource wants to merge 2 commits into
masterfrom
ac/SONARJAVA-5397

Conversation

@aurelien-coet-sonarsource

@aurelien-coet-sonarsource aurelien-coet-sonarsource commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Summary by Gitar

  • External Reports:
    • Added support for importing custom checkstyle issues without the standard prefix in CheckstyleXmlReportReader.java

This will update automatically on new commits.

@hashicorp-vault-sonar-prod

hashicorp-vault-sonar-prod Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

SONARJAVA-5397

@gitar-bot

gitar-bot Bot commented Aug 28, 2026

Copy link
Copy Markdown
Code Review ✅ Approved 1 resolved / 1 findings

Added support for importing custom checkstyle issues without the standard prefix in CheckstyleXmlReportReader.java. The handling of empty 'source' attributes that previously required guards has been addressed.

✅ 1 resolved
Edge Case: Empty 'source' attribute no longer guarded, yields blank rule key

📄 external-reports/src/main/java/org/sonar/java/externalreport/CheckstyleXmlReportReader.java:112-120 📄 external-reports/src/test/java/org/sonar/java/externalreport/CheckstyleSensorTest.java:145-153
The removed prefix check was also the only guard against an error element with a missing/empty source attribute (getAttributeValue returns "" in that case, and "".startsWith(CHECKSTYLE_PREFIX) was false, so the element was skipped with a debug log). Now such an element produces key = "" and ExternalIssueUtils.saveIssue is called with a blank ruleId, so either a meaningless issue with an empty rule key is reported or the platform rejects the blank rule id (RuleKey.of requires a non-blank rule) — and because CheckstyleSensor.importReport catches Exception around the whole parse, one such element aborts the import of every remaining file in the report (same failure mode already demonstrated by checkstyle-with-invalid-line.xml). Since this PR intentionally widens the reader to accept checkstyle-format XML produced by non-Checkstyle/custom tooling, a missing source is realistic input; restore an explicit empty-source guard (SpotBugsXmlReportReader does exactly this for an empty @type at SpotBugsXmlReportReader.java:146-149) and add a fixture covering it.

Implementation Status ✅ 2 of 2 objectives covered
SONARJAVA-5397 - 2 of 2 objectives covered

This PR covers both objectives: it continues to remove the standard checkstyle prefix when present while successfully importing custom checkstyle issues that lack the prefix.

✅ 2 covered here
  • ✅ Continue to reduce the rule key by removing the com.puppycrawl.tools.checkstyle.checks. prefix if possible
  • ✅ Import Checkstyle issues even if the rule key does not start with the prefix and has no rule description
Options

Auto-apply is off → Gitar will not commit updates to this branch.
Display: compact → Showing less information.

Comment with these commands to change the behavior for this request:

Auto-apply Compact
gitar auto-apply:on         
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Gitar

@sonarqube-next

Copy link
Copy Markdown
Contributor

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.

1 participant