"Field can be converted to one or more local variable" false positives
This one inspection generates so many false positives that it is nearly useless. It is particularly bad in files where a field had been a local variable but was changed to a field so that it could be accessed in more than one method.
Attached is a file in which IDEA swears that testComplete can be replaced by a local variable.
Donald
Attachment(s):
CgiSynPhotBlackboardEWTest.java
请先登录再写评论。
Build 4244 (5.1.2 release candidate).
Hello Donald,
DM> This one inspection generates so many false positives that it is
DM> nearly useless. It is particularly bad in files where a field had
DM> been a local variable but was changed to a field so that it could be
DM> accessed in more than one method.
DM>
DM> Attached is a file in which IDEA swears that testComplete can be
DM> replaced by a local variable.
This is a known issue. The problem is not in the inspection itself (which
works correctly), but rather in the update code (which does not re-run the
inspection when the usages of the field are changed).
--
Dmitry Jemerov
Software Developer
http://www.jetbrains.com/
"Develop with Pleasure!"
It isn't JUST the update code.
The file that I attached gets a false positive and it's been the way it is for months.
Donald
The inspection is reworked in 6.0 to flag only single-metthod-accessed fields.
I just noticed today that this will also flag bound-UI fields which have custom-create code, if they are only accessed in the "createUIComponents()" method. I'll submit a JIRA.
Also, as has been discussed in the past, this inspection really needs to be documented as explicitly not-thread-safe, even for the single-method-access only case.
--Dave Griffith