java:S116 does not check fields of test classes


the rule java:S116 Field names should comply with a naming convention does not check test classes.
This might be by design. java:S101 does not check test classes, but there is an equivalent rule for test classes: java:S3577. The same is true for naming conventions of methods and test methods.
However, there is no equivalent for field names.
Ideally, the naming convention is the same for fields of test classes and S116 would apply.

We use SonarLint, connected to SonarQube 9.9.0

Hi @oliver,

All our rules apply either to test or main code, with more rules being available for main code. Indeed, there are many rules that currently only apply to main code but would also make sense for test code.

This topic of test vs main code has been discussed various times in the past and is still open on our side. The fact that some rules could also apply to test code but currently don’t is a known limitation. However, there are more subtleties to this than one might assume at first sight. I am expecting us to revisit it next year, although unfortunately, I cannot give you a concrete ETA.

If you really want to have main code rules on test code, one workaround would be to also scan your test code as main code.

1 Like