Open dgroup opened 5 years ago
@dgroup/z this project will fix the problem faster if you donate a few dollars to it; just click here and pay via Stripe, it's very fast, convenient and appreciated; thanks a lot!
@yegor256 may be really it is better to disable this rule? https://pmd.github.io/pmd/pmd_rules_java_bestpractices.html#arrayisstoreddirectly
@pnatashap well, it's a good rule, I believe. Maybe, we should take their rule, copy it to our code base, and then modify it so that it only alarms when this happens:
this.args = args;
But doesn't alarm if:
this.args = any_other_method_call_or_constructor(args);
@pnatashap @yegor256 If I get you right. I tried to reproduce this (versions 0.18.19 and 0.23.0) but I only got errors in the following code:
public final class Temp2 {
private final String[] list;
public Temp2(final String... arg) {
this.list = arg;
}
}
The following code did not generate errors:
public final class Temp {
private final List<String> list;
public Temp(final String... arg) {
this.list = new ListOf<>(arg);
}
}
public final class Temp4 {
private final String[] list;
public Temp4(final String... arg) {
this.list = Temp4.conv(arg);
}
private static String[] conv(final String... arg) {
return arg;
}
}
On qulice
v0.18.19
gives PMD
The user-supplied array 'args' is stored directly. (ArrayIsStoredDirectly)
. What's wrong with it?