Java for each loop being flagged as UR anomaly by PMD -


i confirm if bug on pmd? how file ticket if is.

    public static void main(final string[] args) {         (final string string : args) {             string.getbytes(); //ur anomaly         }         (int = 0; < args.length; i++) {             args[i].getbytes();         }     } 

lines 1-3 being flagged ur anomaly, while rewriting iterate local variable fine.

would eliminate pmd violations, inconvenient have resort old loop construct workaround.

while controversial, not wish disable rule since find dd, , du anomaly flagging useful.

it appears have hit bug in pmd. dataflowanomalyanalysis rule not seem catch possible kinds of variable definitions (another example found here). ur stands "undefined reference", incorrect.

so, can do?

since problem appears affect ur part of rule, can disable , continue using du , dd parts. need recent version of pmd this. in ruleset file, suppress ur findings this:

<rule ref="rulesets/java/controversial.xml/dataflowanomalyanalysis">     <properties>         <property name="violationsuppressregex" value="^found 'ur'-anomaly.*"/>     </properties> </rule> 

in humble opinion, whole ur checking bit on top, because compiler not accept undefined references. , these days, running compiler no longer such big deal.


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -