I’m a bit confused by your question. Are you saying that S1144 is raising issues on test files? From what I can tell that rule is for source files only.
That Jira repo is vestigial; the rules got moved into Git a while ago. But even when it was in use, that scope field was largely aspirational. It got honored for C# but nothing else. Since then some work has been done around what rules apply to tests, but the scope of that was never clear to me.
I would think it is correct that it also scans test code for unused methods. Having unused code in test files are just as much dead code as in regular classes.
As Ann has already mentioned, the rule is currently not designed to run on test code. In principle, I completely agree with you, that this rule could also make sense applied to test code. However, as your example shows very well, we can’t simply activate rules that work well on main code for test code and expect everything to work out of the box. Problems like this FP arise, as the rule does not understand that the annotation provided in the context of the parametrized test actually means that the method is used.
One day, I hope we can improve our support for test code, as there are certainly many rules in the Java analyzer, which currently only run on main code and would also bring value for test code. Unfortunately, I cannot give you an ETA for this, though.
Since you are using the CLI sonar scanner, you will manually need to provide the directories that contain test code vs main code (using the property sonar.tests - see the docs here). Alternatively, if you can, I would recommend that you use the SonarScanner for Gradle or for Maven instead, which will usually be able to set these (and more!) properties for you.
If you still want to run the rules designed for main code on your test code, you will unfortunately have to expect odd behavior for the time being.
We noticed a sudden rise in the number of code smells in our projects (without code changes), and upon analysis, we noticed that all of them are S1144 in test files - all are on private methods used with @MethodSource. We also noticed that the “analysis scope” of S1144 is “Main and Test sources” in our SonarCloud instance. Did this scope change recently?
I also saw that there was recent work in this regard in [SONARJAVA-4943] - Jira. Is this fix already available?
Recently, we worked on the effort to enable some rules on the test code. You can find more details here: SONARJAVA-4932.
The rule S1144 was part of this effort, and that is why you see a rise in the number of issues in your project.
For the other point, SONARJAVA-4943 is part of the 7.34 release, and the fix should be on SonarCloud.
Out of curiosity, was this communicated in any changelog?
Also, is the analysis scope of a given rule configurable in SonarCloud?
Regarding @MethodSource, there’s a false positive when no value is passed to the annotation:
If no factory method names are declared, a method within the test class that has the same name as the test method will be used as the factory method by default.
As JUnit5 is a massively used library, is there any chance that this false positive could be fixed? Most of our uses of @MethodSource rely on this default behavior.