Re: unused local variables

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: unused local variables

Arnaud Roques
Hello,

I have created two checkers:

<module name="cs.UnusedLocalVariable" />
        This checker detects unused local variable.


<module name="cs.TooEarlyVariableDeclaration" />

        This checker detects several things about variable declaration.
Examples:
        int i = 0, j = 4; // Error: Declare variables on separate lines

        int i;
        i = 4;  // those two lines can be merged into "int i = 4"


        int i = 0; // this affectation is useless
        i = 4;

        int i; // Declare variable as close as possible to where they are
used
        [A lot of code that does not use i]
        i = 6;

I've attached the "cs.jar" file that is needed to used thoses checkers.
(sources are included).

The checkers have *not* been extensively tested, so use them with care.

Hope this helps!


Arnaud Roques


-------------------------------------------------------------------------
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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/checkstyle-user

cs.jar (10K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: unused local variables

Oliver Burn
Interesting idea - thanks

On Tue, Sep 2, 2008 at 20:13, Arnaud Roques <[hidden email]> wrote:
Hello,

I have created two checkers:

<module name="cs.UnusedLocalVariable" />
       This checker detects unused local variable.


<module name="cs.TooEarlyVariableDeclaration" />

       This checker detects several things about variable declaration.
Examples:
       int i = 0, j = 4; // Error: Declare variables on separate lines

       int i;
       i = 4;  // those two lines can be merged into "int i = 4"


       int i = 0; // this affectation is useless
       i = 4;

       int i; // Declare variable as close as possible to where they are
used
       [A lot of code that does not use i]
       i = 6;

I've attached the "cs.jar" file that is needed to used thoses checkers.
(sources are included).

The checkers have *not* been extensively tested, so use them with care.

Hope this helps!


Arnaud Roques


-------------------------------------------------------------------------
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
[hidden email]
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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/checkstyle-user
Reply | Threaded
Open this post in threaded view
|

Re: unused local variables

kkforums
In reply to this post by Arnaud Roques
Hi Arnaud,

I also have written a small check. But i'm not able to test due to lack of knowledge in running the check.

I have downloaded your jar file, but i didn't see an custom check xml configuration file.

Please let me know how to test custom checks and how to integrate them with the existing check style in my local machine?

Thanks in advance.

Regards
Kiran

Arnaud Roques wrote
Hello,

I have created two checkers:

<module name="cs.UnusedLocalVariable" />
        This checker detects unused local variable.


<module name="cs.TooEarlyVariableDeclaration" />

        This checker detects several things about variable declaration.
Examples:
        int i = 0, j = 4; // Error: Declare variables on separate lines

        int i;
        i = 4;  // those two lines can be merged into "int i = 4"


        int i = 0; // this affectation is useless
        i = 4;

        int i; // Declare variable as close as possible to where they are
used
        [A lot of code that does not use i]
        i = 6;

I've attached the "cs.jar" file that is needed to used thoses checkers.
(sources are included).

The checkers have *not* been extensively tested, so use them with care.

Hope this helps!


Arnaud Roques


 
-------------------------------------------------------------------------
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
Checkstyle-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/checkstyle-user