SONARJAVA-6654 Fix S2166 false positives for classes with unresolvable supertypes#5832
Conversation
|
I don't see any unit test to make sure it's fine. Is it possible to add one ? |
Unfortunately no. This situation happens in very specific case when the project fails to be parsed with ECJ parser (which we use in default batch mode). The problem is that our unit tests always use JParser, so this path is inherently untestable at the unit level. And our ruling projects also don't satisfy this condition. I've already added defensive comment to clarify this. |
Guard against ECJ batch mode behavior where a compilation error causes superClass() to return null instead of UnknownType, which was triggering false positives on classes with an extends clause. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
8cb4283 to
769c7d9
Compare
|
Code Review 👍 Approved with suggestions 0 resolved / 1 findingsPrevents S2166 false positives in ECJ batch mode by handling null return values from superClass() during resolution. Please add regression test coverage to verify the fix. 💡 Quality: No test coverage added for the FP fixReply with The PR fixes an S2166 false positive but the diff contains no changes to test files or test sources. Without a regression test that reproduces the ECJ-batch case (an 🤖 Prompt for agentsOptionsAuto-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 |




Guard against ECJ batch mode behavior where a compilation error causes superClass() to return null instead of UnknownType, which was triggering false positives on classes with an extends clause.