Re: Any Checkstyle users?
- From: Rick Giles <rick.giles@xxxxxxxxxx>
- Date: Tue, 31 Jan 2006 08:40:48 -0400
Chris Uppal wrote:
Yes, it does; see SuppressionCommentFilter at http://checkstyle.sourceforge.net/config.htmlmikm wrote:
{ private HashMap guests; private static final int MAX_GUESTS = 50; //... public Hotel() { guests = new HashMap(MAX_GUESTS); [...] Now, anybody looking at your code knows that the maximum number of guests is 50 and that the HashMap "guests" can hold that much data.
Except that that isn't true. The name should be something like private static final int INITIAL_ESTIMATE_OF_PROBABLE_MAX_GUESTS = 50; which is unwieldy in the extreme, but calling it MAX_GUESTS is actively wrong and so must be avoided.
The real problem here is not the use of a "magic number", but the use of a checking tool which will blindly apply the same so-called rule to every situation, regardless of whether it is applicable. If Checkstyle doesn't provide a way to annotate your code to say "I have reviewed this 'problem' code and it is fine as it is", then I'd suggest dropping Checkstyle.
/RG
-- chris
.
- Follow-Ups:
- Re: Any Checkstyle users?
- From: Chris Uppal
- Re: Any Checkstyle users?
- References:
- Any Checkstyle users?
- From: slippymississippi
- Re: Any Checkstyle users?
- From: mikm
- Re: Any Checkstyle users?
- From: mikm
- Re: Any Checkstyle users?
- From: Chris Uppal
- Any Checkstyle users?
- Prev by Date: Re: Dialog box with clickable url
- Next by Date: Re: When will reflections support casting (especially for constructors, etc) properly?
- Previous by thread: Re: Any Checkstyle users?
- Next by thread: Re: Any Checkstyle users?
- Index(es):