"Constants should not be defined in interfaces" a misleading name for java:S1214

The name of rule java:S1214 is “Constants should not be defined in interfaces” but the description seems to imply that this rule only applies to interfaces that consist of nothing but constants. When we upgraded from 7 to 8, 2/3 of our issues for this rule went away. I believe this is because the rule used to apply to any use of constants in an interface, while now it only covers constants-only interfaces.

(I assume constants in an interface that contains methods are considered OK on the assumption that the constants are relevant to the methods, such as possible values for one of the arguments in one of the methods?)

So the name is a little misleading, and should be updated to reflect the change. Perhaps something like “Interfaces consisting only of constants should not be used” – or any more elegant wording your Java experts come up with.

Hello @MisterPi,

Thanks for pointing this out. The implementation was indeed changed and this should be reflected in the name of the rule. Here is a ticket to track it:

https://sonarsource.atlassian.net/browse/SONARJAVA-4429

Regards,
Margarita

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.