A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pmd/pmd/issues/4042 below:

[java] A false negative about the rule StringBufferInstantiationWithChar · Issue #4042 · pmd/pmd · GitHub

Affects PMD Version:
6.47.0+
7.0.0

Rule:StringBufferInstantiationWithChar

Please provide the rule name and a link to the rule documentation:
https://pmd.github.io/latest/pmd_rules_java_errorprone.html#stringbufferinstantiationwithchar

Description:
Hi, I found a false negative about the rule StringBufferInstantiationWithChar, please read the following minimized code example. In line 3, builder is initialized by a character, but ch could converted into an integer. Hence, I think this is a false negative, and maybe we should analyze variable type about this rule.

Code Sample demonstrating the issue:

public void foo() {
    char ch = 'c';
    StringBuilder builder = new StringBuilder(ch);  // should report a warning in this line
}

Expected outcome:A warning

PMD should report a violation at line 3, but doesn't. This is a false-negative.

Running PMD through: [Maven]


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4