Rule java:S1874 "@Deprecated" code should not be used - in test code

Hi,

As I see rule java:S1874 detect using of deprecated code only in production code.

I think it will be also useful if I can detect the same in my test classes.

Hi Slawomir,

At the moment, it is a hard-coded list in the SonarJava plugin which rules are applied to the main code and which ones are applied to the test code. It might be a good idea to rethink that assignment or make it even configurable for the users. Thanks for your feedback! I have created a ticket (SONARJAVA-4905) about your suggestion.

Best,
Marco

2 Likes

Thanks for creating issue.

Maybe instead of making possibility to configure assignment of rule to code scope (it looks as a bigger change), you can simply add new rule with test code scope.

1 Like