[ checkstyle-Feature Requests-3298881 ] new check: VariableDeclarationUsageDistanceCheck

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[ checkstyle-Feature Requests-3298881 ] new check: VariableDeclarationUsageDistanceCheck

SourceForge.net
Feature Requests item #3298881, was opened at 2011-05-07 22:11
Message generated for change (Comment added) made by romanivanov
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=397081&aid=3298881&group_id=29721

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Check
Group: None
Status: Open
Priority: 5
Private: No
Submitted By: Roman Ivanov (romanivanov)
Assigned to: Nobody/Anonymous (nobody)
Summary: new check: VariableDeclarationUsageDistanceCheck

Initial Comment:
Check distance between declaration of variable and its first usage of it.
To developer: be aware of  blocks { ... } and declaration out the block and usage inside of block - this is a bit complicate the task of detection such cases.
Options:
 - Allowed distance (in rows count); Default is 0;
 - Ignore variable names (regexp). Default is "";

Problematic code :
int count;
a=a+b;
b=a+a;
count = b;  // DECLARATION SHOULD BE HERE

Problematic code:
int count;
{
   a=a+b;
   count = b; // DECLARATION SHOULD BE HERE
}

Correct code:
int count;
{
   a=a+b;
   count = b;
}
count = 1;

----------------------------------------------------------------------

>Comment By: Roman Ivanov (romanivanov)
Date: 2012-05-29 20:18

Message:
Cases that VariableDeclarationUsageDistanceCheck have to support
1.
int mm = Integer.parseInt(time.substring(div + 1).trim());

    Calendar cal = Calendar.getInstance();
    cal.setTimeInMillis(timeNow);
    cal.set(Calendar.SECOND, 0);
    cal.set(Calendar.MILLISECOND, 0);
    cal.set(Calendar.HOUR_OF_DAY, hh);
    cal.set(Calendar.MINUTE, mm);

2.
Option srcDdlFile = OptionBuilder.create("f");
Option logDdlFile = OptionBuilder.create("o");
Option help = OptionBuilder.create("h");

    Options options = new Options();
    options.addOption(srcDdlFile, logDdlFile, help);


----------------------------------------------------------------------

Comment By: Ruslan Diachenko (rusya7)
Date: 2011-08-15 09:26

Message:
https://sourceforge.net/tracker/?func=detail&aid=3392053&group_id=29721&atid=397080

----------------------------------------------------------------------

You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=397081&aid=3298881&group_id=29721

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Checkstyle-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/checkstyle-devel