SONARJAVA-4647 Improve S120 to report one project-level issue per bad package name - #6025
Conversation
…name Previously, the rule raised an issue on every file within a non-compliant package, producing n issues for n classes in the same package. The rule now collects unique bad package names across all files and reports a single project-level issue per package via endOfAnalysis(). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: Asya Vorobeva <253306985+asya-vorobeva@users.noreply.github.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- scanFile now always writes to cache (empty string for default package), so unchanged files without a package declaration are correctly skipped via scanWithoutParsing on subsequent runs - scanWithoutParsing now calls copyFromPrevious to propagate the cache entry to the write cache, preventing it from disappearing after a hit - Empty package name is excluded from badPackageNames in both paths Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Code Review ✅ Approved 4 resolved / 4 findingsUpdates rule S120 to report a single project-level issue per bad package name instead of raising redundant issues per file, addressing incremental analysis issues and caching bugs. No remaining findings. ✅ 4 resolved✅ Bug: Project issue lost on incremental analysis (unchanged files skipped)
✅ Quality: badPackageNames is never cleared after reporting
✅ Performance: Cache entry not propagated on scan-without-parsing hit
✅ Performance: Default-package files get no cache entry, blocking file skipping
OptionsAuto-apply is off → Gitar will not commit updates to this branch. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Gitar |
|




Previously, the rule raised an issue on every file within a non-compliant package, producing n issues for n classes in the same package. The rule now collects unique bad package names across all files and reports a single project-level issue per package via endOfAnalysis().