FinalLocalVariable does not check for loop variable

60 views
Skip to first unread message

Ruslan Diachenko

unread,
Feb 11, 2015, 10:24:04 AM2/11/15
to checksty...@googlegroups.com
This topic is related to the issue: https://github.com/checkstyle/checkstyle/issues/20

Assignee:  Bhavik Patel

Ruslan Diachenko

unread,
Feb 11, 2015, 10:25:28 AM2/11/15
to checksty...@googlegroups.com
Hi Bhavik Patel,

According to your pull request: https://github.com/checkstyle/checkstyle/pull/630

1. Please explain the changes in .classpath, what for?
2. Next time you make a pulll request please provide some description about what you have done
3. Don't use such commit messages:


They say nothing useful

4. Your changes decreased the coverage, please fix
>> Coverage decreased (-0.02%)

5. I don't see any changes which are related to the actual fix
6. Before making a pull request please squash all your commits into one

Bhavik Patel

unread,
Feb 11, 2015, 11:02:28 AM2/11/15
to checksty...@googlegroups.com
Hi Ruslan Diachenko,

sorry for not describing in detail.

>> .classpth changes : actually i did not change anything in .classpath manually. it was done by eclipse automatically. i thought it is necessary for project to be built.

>> https://github.com/Bhavik3/checkstyle/blob/889c7bcfe036c46ad40904ce8469939c84cd69cd/src/test/resources/com/puppycrawl/tools/checkstyle/coding/InputFinalLocalVariable.java#L134 should be declared final.

    FinalLocalVariableCheck.java is not checking for this variable (because it is not checking for FOR_EACH_CLAUSE variable). following is the lone of code:

    https://github.com/checkstyle/checkstyle/blob/master/src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheck.java#L112

    so, I remove this line. as there is not any conflict with removing this line.
 
    now there are many places where FOR_EACH_CLAUSE variable is not declared final. so i changed it.

>> may be I am doing something wrong. point me out where I am going wrong. so that i can fix it and improve it.

Thanks,
Bhavik.



Ruslan Diachenko

unread,
Feb 12, 2015, 8:40:04 AM2/12/15
to checksty...@googlegroups.com
Hi,

Ok, seems fine. Could you please:

1. Rollback changes in .classpath. There shouldn't be changes in this file
2. Squash your commits into one and provide a link to your commit

Bhavik Patel

unread,
Feb 12, 2015, 8:41:41 AM2/12/15
to checksty...@googlegroups.com
OK

Bhavik Patel

unread,
Feb 12, 2015, 4:34:54 PM2/12/15
to checksty...@googlegroups.com
Hi Ruslan,

following is the commit in my fork repository. I built it on my local system and all fine. you look at it:

https://github.com/Bhavik3/checkstyle/commit/92f392623197355319de1b6c8cc8b5d532b424da

I will do PR after your suggestion.

Ruslan Diachenko

unread,
Feb 13, 2015, 2:29:13 AM2/13/15
to checksty...@googlegroups.com
Hi,

Please do pull request and include the issue number.

Ruslan Diachenko

unread,
Feb 13, 2015, 8:38:37 AM2/13/15
to checksty...@googlegroups.com
>> Coverage should not be decreased. Please update unit tests as well

You can use code coverage tools (e.g.: Cobertura, Eclemma, etc.). Most of them can be installed as plugins to Eclipse.

Than you run FinalLocalVariableCheckTest within a code coverage tool and analyze the source of FinalLocalVariableCheck. All uncovered code branches will be highlighted. So you can update FinalLocalVariableCheckTest to cover missed cases.

Bhavik Patel

unread,
Feb 13, 2015, 12:58:43 PM2/13/15
to checksty...@googlegroups.com
 

 showing 100% coverage on my local system for FinalLocalVariableCheckTest

Ruslan Diachenko

unread,
Feb 13, 2015, 1:37:30 PM2/13/15
to checksty...@googlegroups.com
See the attached file - the result of running FinalLocalVariableCheckTest with Eclemma. Not 100% but 99.4% and there're some code branches which can be covered :)
FinalLocalVariableCheckCoverage.png

Bhavik Patel

unread,
Feb 13, 2015, 2:03:24 PM2/13/15
to checksty...@googlegroups.com
ya, I seen it after posting.


Message has been deleted
Message has been deleted

Ruslan Diachenko

unread,
Feb 15, 2015, 3:52:33 PM2/15/15
to checksty...@googlegroups.com
Hi,

According to you pull request. Seems you have problems with squashing you commits as there are changes which are not related to your issue.

Ruslan Diachenko

unread,
Feb 15, 2015, 3:57:34 PM2/15/15
to checksty...@googlegroups.com
Please follow these instruction about the development process: https://github.com/sevntu-checkstyle/sevntu.checkstyle/wiki/Development-workflow-with-Git%3A-Fork%2C-Branching%2C-Commits%2C-and-Pull-Request where "sevntu-checkstyle" can be replaced to "checkstyle".

The goal: we need only your changes in one commit message.

Bhavik Patel

unread,
Feb 15, 2015, 9:52:21 PM2/15/15
to checksty...@googlegroups.com
Hi,

I noticed that. but actually, there are other developer's commits in between my two commits. so when I squashed them, their commits also squashed into me.


Bhavik Patel

unread,
Feb 15, 2015, 9:57:56 PM2/15/15
to checksty...@googlegroups.com
 

 It is good idea to make separate branch. so that no other commits can come in between my commits and I can squash them. At the end, I will merge my squashed commit to my origin/master and finally push into upstream. 
Reply all
Reply to author
Forward
Message has been deleted
0 new messages