Hi Freddy,
A
Magic Number sould declared as constant.
In Java, the best way for constant declaration is
static final :
static for instantiation and
final for unchanged value.
Beyond implementation / memory optimisation, a constant is a "unchanged value" =>
final "could represent" a constant (lexically).
For field declaration, a only final field (like following snippet) has 2 violations :
S109 'MagicNumber' and
S1170 'Public constants and fields initialized at declaration should be "static final" rather than merely "final"'
public class Clazz {
/** This is a constant (use static is better) */
private final int foo = 42;
}
I agree with S1170, this is not the perfect way for constant declaration ... but this is a constant ; so S109 is severe.
And
when you change a rule implementation (from checkstyle to squid) ...
this difference could be a little disturbing for users :-(.
Best regards.