Re: unused local variables

View: New views
3 Messages — Rating Filter:   Alert me  

Re: unused local variables

by Arnaud Roques :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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

cs.jar (10K) Download Attachment

Re: unused local variables

by Oliver Burn :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Interesting idea - thanks

On Tue, Sep 2, 2008 at 20:13, Arnaud Roques <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@...
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
Checkstyle-user@...
https://lists.sourceforge.net/lists/listinfo/checkstyle-user

Re: unused local variables

by KiranKumar :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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