Qube: Community 9.9
The Java rule S5960 reports a FP for assertEquals(CharSequence, CharSequence). I tried it with JUnit 4 and 5. Both the same.
The method is annotated with the @Test.
public void test1() throws Exception
assertEquals( "a", "b" );
Thanks for your message. I’m not sure I have enough data to reproduce your issue. In the configuration of the analysis, we distinguish between “main” sources and “test” sources. This rule triggers if it finds the invocation of assert methods in the “main” code.
Could you please share with me the configuration of your analysis and the project structure? For some reason, this file was recognized as the “main” code. I’m interested in the values of the properties “sonar.sources” and “sonar.tests”.
As a side note, if you’re using Gradle or Maven we suggest using scanners for Gradle or Maven respectively. This will help you avoid such problems.
This is a good point. I don’t think, we have distinguished between these two.
Do you have any documentation? Is this a setting for the sonar scanner? Or for lint preferences? Both?
These are the properties you set. You can read about it here: Narrowing the focus with an analysis scope
And which build tool are you using? For Maven and Gradle, if you’re using corresponding plugins, you should have these properties automatically populated.