Repository navigation
SONARJAVA-7163 Restrict S9436 to main code and report uninitialized loggers - #6369
Conversation
d4b29b0 to
80f3ccf
Compare
|
Check now reports uninitialized logger fields, so the description matches it. |
This comment has been minimized.
This comment has been minimized.
|
⚖️ Ruling update ready for review: #6370 |
Ruling Diff SummaryDetected changes in 2 rule files: 0 issues removed, 2 issues added. S9436 (
|
|
⚖️ Ruling update ready for review: #6371 |
Code Review ✅ Approved 1 closed / 1 findings🟡 Medium risk · S9436 now ignores test code and flags uninitialized logger fields in production, which could add findings for configurable loggers and prompt unnecessary cleanup. Restricts rule S9436 to main code so tests that keep one logger per class for output capture are no longer flagged, matching S1312 and S3416. The metadata now drops the uninitialized non-final logger exception, so those fields are reported and the description matches the behavior. ✅ 1 closed✅ Bug: Doc drops the uninitialized non-final logger exception the check keeps
Verification Rules 1/1 met Repos 4 inspected · PRs 1 inspectedFunctional validation No results Rules 1 passed 2 not applicable
Broader impact Repos 4 inspected PRs 1 inspectedCross-repo 4 repositories inspected 0 open impacts
Cross-PR 1 PR inspected 0 open impactsAuto-approval Not enabledFor more verification details, comment 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 |
|
|
/pvf |
|
|
| .filter(member -> member.is(Tree.Kind.VARIABLE)) | ||
| .map(VariableTree.class::cast) | ||
| .filter(MoreThanOneLoggerCheck::isDeclaredLogger) | ||
| .filter(field -> isLoggerType(field.type().symbolType())) |
There was a problem hiding this comment.
[nit] the PR title and description don't mention this change to the rule implementation
There was a problem hiding this comment.
Updated the title and description to mention the check change.




Summary
ContextHandler.java. It is a true positive against the current specification: a production class with a static logger and a second, uninitialized logger field.Test plan
S9436.jsonhas"scope": "Main"MoreThanOneLoggerCheckTestpasses, including an uninitialized logger next to another one