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] InsufficientStringBufferDeclaration false positive with StringBuilder.setLength(0) · Issue #3712 · pmd/pmd Closed Labels a:false-positivePMD flags a piece of code that is not problematic Milestone DescriptionAffects PMD Version: 6.41.0 Rule: InsufficientStringBufferDeclaration Description: When using There does not seem to be an issue when the constructor uses a hardcoded size, only when the initial constructor size is calculated at runtime and PMD is unable to determine the actual initial size. Code Sample demonstrating the issue: public static void foo(int i) { StringBuilder sb = new StringBuilder(i); sb.append("ab"); sb.setLength(0); // false positive sb.append("cd"); } public static void foo2() { StringBuilder sb = new StringBuilder(2); sb.append("ab"); sb.setLength(0); // no problem, no false positive sb.append("cd"); } Expected outcome: PMD reports a violation at line 4, but that's wrong. If PMD cannot determine the initial length from the constructor invocation, it should not assume that the length specified in Running PMD through: Gradle Activity
MetadataMetadataAssigneesLabelsa:false-positivePMD flags a piece of code that is not problematic 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. |