Re: RE : Checking a method call
"Oliver Burn" <[email protected]> Tue, 16 Sep 2008 10:48:45 +1000
| Newsgroups | gmane.comp.java.audit.checkstyle.user |
|---|---|
| Message-ID | <[email protected]> |
Yes, I do something similar as well. Here is an example:
<module name="GenericIllegalRegexp">
<property name="format"
value="(Double|Float|Integer|Long)\s*\.\s*valueOf\s*\(\s*[01]\s*\)"/>
<property name="message" value="Use NumberUtils.xxx_ZERO or
NumberUtils.xxx_ONE"/>
</module>
<module name="GenericIllegalRegexp">
<property name="format"
value="(Double|Float|Integer|Long)\s*\.\s*valueOf\s*\(\s*""/>
<property name="message" value="Do not supply a string to be parsed,
you know the number."/>
</module>
<module name="GenericIllegalRegexp">
<property name="format"
value="\.\s*parse(Double|Float|Int|Long)\s*\(\s*""/>
<property name="message" value="Do not avoid magic numbers this
way!"/>
</module>
On Thu, Sep 11, 2008 at 18:45, Arnaud Roques
<[email protected]>wrote:
> Hi,
>
>
>
> I am thinking about writing a specific Checker for this.
>
> You can still use regular expression to test this, even if it is quite
> limited and not 100% perfect:
>
>
>
> Example:
>
>
>
> <!-- printStackTrace() == -->
>
> <module name="GenericIllegalRegexp">
>
> <property name="format" value="\.printStackTrace\s*\("
> />
>
> <property name="message" value="Don't use
> printStackTrace" />
>
> <property name="ignoreComments" value="true" />
>
> </module>
>
>
>
>
>
> Or :
>
>
>
> <!-- compareTo() == -->
>
> <module name="GenericIllegalRegexp">
>
> <property name="format"
>
> value="\.\s*compareTo\s*\([^=]*\)\s*==" />
>
> <property name="message"
>
> value="Use equals instead of compareTo()==0" />
>
> <property name="ignoreComments" value="true" />
>
> </module>
>
>
>
> <!-- System.err.println -->
>
> <module name="GenericIllegalRegexp">
>
> <property name="format" value="System\.(err|out)\.print"
> />
>
> <property name="message" value="Do not use
> System.println" />
>
> <property name="ignoreComments" value="true" />
>
> </module>
>
>
>
>
>
> -----Message d'origine-----
> *De :* [email protected] [mailto:
> [email protected]] *De la part de* jp.vandara
> *Envoyé :* jeudi 11 septembre 2008 10:06
> *À :* [email protected]
> *Objet :* [Checkstyle-user] Checking a method call
>
>
>
>
>
> Hi,
>
> I would like to avoid the calls to some methods.
>
> How can I check if a method is called?
>
> Thanks,
> Jean-Philippe.
>
>
>
> *Créez votre adresse <http://www.laposte.net> électronique
> [email protected]
> 1 Go d'espace de stockage, anti-spam et anti-virus intégrés.*
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's
> challenge
> Build the coolest Linux based applications with Moblin SDK & win great
> prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> Checkstyle-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/checkstyle-user
>
>
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Checkstyle-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/checkstyle-user