Contradiction enter the rules AvoidVisibleConstantFieldRule and PreferLiteralOverInitOnlyFieldsRule!!

115 views
Skip to first unread message

Luping

unread,
Dec 8, 2011, 5:42:24 AM12/8/11
to Gendarme
I have a problem with two rules AvoidVisibleConstantFieldRule and
PreferLiteralOverInitOnlyFieldsRule. These two rule are contradictory.
Anyone has the same problem? Do you have any suggestion?

Eric Zeitler

unread,
Dec 8, 2011, 4:34:04 PM12/8/11
to Gendarme
These rules are only contradictory on externally visible methods. The
documentation mentions this (with lots of parenthetical explanations
(: ), but I'm not positive the rule actually lowers the severity for
this case. I can understand the frustration at having to wade through
false positives and ignore them as such; In my projects there are
quite a few thousand sometimes. I've been making custom patches to my
local tree to fix them, but I currently don't have time to wade
through and cherry pick them, give them proper test cases and cleanup
for inclusion in trunk.

Leszek Ciesielski

unread,
Dec 9, 2011, 9:23:25 AM12/9/11
to gend...@googlegroups.com
It should be possible to fix this conflict in the rule code. Visible
(non-private) contants are bad, period. Init-only fields are bad,
_except_ when you expose them through a visible (non-private)
property.

> --
> You received this message because you are subscribed to the Google Groups "Gendarme" group.
> To post to this group, send email to gend...@googlegroups.com.
> To unsubscribe from this group, send email to gendarme+u...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/gendarme?hl=en.
>

Reply all
Reply to author
Forward
0 new messages