google / google/error-prone

Bug: False positive for ChainingConstructorIgnoresParameter for array concatenation passing

Open
#5,472 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
7.2k
Forks
820
Avg merge
5h 9m
Merged PRs (30d)
50

Description

The following pattern:
```java
public class MyClass {
final String[] targets;

MyClass(String target) {
this.targets = new String[]{target};
}

MyClass(String[] targets) {
this.targets = targets;
}

MyClass(String target, String... targets) {
String[] newTargets = new String[targets.length + 1];
newTargets[0] = target;
System.arraycopy(targets, 0, newTargets, 1, targets.length);
this(newTargets);
}
}
```
Cause a [ChainingConstructorIgnoresParameter](https://errorprone.info/bugpattern/ChainingConstructorIgnoresParameter) false-positive!

Found out while doing stuff on my project, original code is there:
https://github.com/Fox2Code/Hypertale/blob/master/patcher/src/main/java/com/fox2code/hypertale/patcher/patches/HypertalePatch.java

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.