GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — [java] AvoidDeeplyNestedIfStmts violations can be unintentionally undetected · Issue #1499 · pmd/pmd Closed Labels a:false-negativePMD doesn't flag a problematic piece of code Milestone DescriptionAffects PMD Version: 5.3.3, 6.*, 7.0.0 Rule: design/AvoidDeeplyNestedIfStatements Description: This rule has strange behavior where if you dispatch from an else block from somewhere else to a method containing violating deeply nested if code, it doesn't get caught as a violation. But if you do a simple if block but no else block, then it gets caught as a violation. It's hard to explain without writing a book.... so see the sample code... Code Sample demonstrating the issue: This is a sample violating method: private String doSomething(String somethingToDo) { if (condition) { if (anotherCondition) { if (problemDepthCondition) { return SOMETHING; } } } return SOMETHING_ELSE; } Here is code that the violation is caught for: public String performSomething(String action) { if (action.equals(NOTHING)) { return NOTHING; } return doSomething(action); } However, this code (which is effectively the same) allows the violation: public String performSomething(String action) { if (action.equals(NOTHING)) { return NOTHING; } // Only difference: using an else block else { return doSomething(action); } } Sure, the nested if's can and should be avoided and rewritten, but I would expect that if someone did code that way (which is what happened and why I am bringing up this issue) that it would be caught, even in the Please let me know if this actually isn't an issue (and is expected behavior), or if further clarification is needed. Running PMD through: Gradle Activity
MetadataMetadataAssigneesLabelsa:false-negativePMD doesn't flag a problematic piece of code TypeProjectsMilestoneRelationshipsDevelopmentIssue actions |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |