IG bug

Hi!

IG bug prevents using "String concatenation in loop" inspection

for (int i = 0; i < topic.getItemList().size(); i++) { ... if (tagInfo == null) { getLMT().log(S2SLLMT.LM_Error_In_Module, "Somelong error message in russian line 1" + "Somelong error message in russian line 2 " + item.getName()); } ... } ]]>

IG reports
Name:
public method void updateTopicToSCADA(Topic topic)

Location:
S2SL (ru.sterling.io3.s3sl)

Problem synopsis:
String concatenation ( +) in loop at line 1213

___
/** WBR @author Denis Tsyplakov @ICQ_UIN 108477017
@mailto: lc@yandex.ru */


6 comments
Comment actions Permalink

Denis Tsyplakov wrote:

Hi!

IG bug prevents using "String concatenation in loop" inspection

Why do you think this is a bug? A String concatenation in loop indeed.
--
Maxim Shafirov
IntelliJ Labs / JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"

0
Comment actions Permalink

Hi!

??>> IG bug prevents using "String concatenation in loop"
??>> inspection
MSJ> Why do you think this is a bug? A String concatenation in loop
MSJ> indeed. --

But it is not impact perfomance. I think this inspection should detect such
code:

String s = "1";
for (int i = 0;i<length;i++)
{
s = s + i;
}

If such case is not bug, then IG need another inspection, to detect
cases when one string concatenated in different loop iterations

___
/** WBR @author Denis Tsyplakov @ICQ_UIN 108477017
@mailto: lc@yandex.ru */


0
Comment actions Permalink

This is something I remember commenting on way back when IG first came
out... it seems like there could be a number of things you could do to
help in such cases : ignore strings whose visibility scope is limited to
one statement, ignore strings whose visibility scope is limited to the
loop, ignore local string variables that aren't 'used' outside the loop

N.

Denis Tsyplakov wrote:

Hi!

??>> IG bug prevents using "String concatenation in loop"
??>> inspection
MSJ> Why do you think this is a bug? A String concatenation in loop
MSJ> indeed. --

But it is not impact perfomance. I think this inspection should detect such
code:

String s = "1";
for (int i = 0;i<length;i++)
{
s = s + i;
}

If such case is not bug, then IG need another inspection, to detect
cases when one string concatenated in different loop iterations

___
/** WBR @author Denis Tsyplakov @ICQ_UIN 108477017
@mailto: lc@yandex.ru */

0
Comment actions Permalink

The code is not clear.

Unnecessary concatenation is dependent on whether item is assigned
inside the loop or not.

0
Comment actions Permalink


This behaviour is "as designed", but I welcome any suggestions on how to improve it. The suggestions I've seen so far have been less than precise, and as such I've kept the (occasionally overbroad) current semantics.

Also, InspectionGadgets bugs should be submitted to the Tracker now, not just the Plugins newsgroup.

--Dave Griffith

0
Comment actions Permalink

My view is that one or more of the suggestions could be implemented as
options to modify the strictness of the inspection, as is done elsewhere
in other inspections where there is a lack of a precise exception case
that can be applied at all times.

N.

Dave Griffith wrote:

This behaviour is "as designed", but I welcome any suggestions on how to improve it. The suggestions I've seen so far have been less than precise, and as such I've kept the (occasionally overbroad) current semantics.

Also, InspectionGadgets bugs should be submitted to the Tracker now, not just the Plugins newsgroup.

--Dave Griffith

0

Please sign in to leave a comment.