Migrate to simplified collection: disable if null or repeating constant value; checkbox to not warn on non-constant content

This commit is contained in:
Tagir Valeev
2017-02-27 16:30:49 +07:00
parent afc78ac84b
commit 5459f1f931
9 changed files with 104 additions and 12 deletions
@@ -4,5 +4,5 @@ import java.util.Collections;
import java.util.List;
public class Test {
public static final List<Number> EVEN = List.of(2, 4, 6, 8, 10);
public static final List<Number> EVEN = List.of(2, 4, 6, 8, 10, 2);
}
@@ -5,5 +5,5 @@ import java.util.HashSet;
import java.util.Set;
public class Test {
public static final Set<String> MY_SET = Set.of("a", "b", "c");
public static final Set<String> MY_SET = Set.of("a", "b", "c", Math.random() > 0.5 ? "d" : Math.random() > 0.5 ? "e" : "d");
}
@@ -0,0 +1,11 @@
// "Replace with 'Set.of' call" "false"
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
public class Test {
static final String CONST = "b";
public static final Set<String> MY_SET = Set.of("a", "b", "c", CONST);
}
@@ -4,5 +4,5 @@ import java.util.Collections;
import java.util.List;
public class Test {
public static final List<Number> EVEN = Collections.unmodi<caret>fiableList(Arrays.asList(2,4,6,8,10));
public static final List<Number> EVEN = Collections.unmodi<caret>fiableList(Arrays.asList(2,4,6,8,10,2));
}
@@ -0,0 +1,8 @@
// "Replace with 'List.of' call" "false"
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
public class Test {
public static final List<Number> EVEN = Collections.unmodi<caret>fiableList(Arrays.asList(2,4,6,8,10,Math.random() > 0.5 ? 12 : null));
}
@@ -5,5 +5,5 @@ import java.util.HashSet;
import java.util.Set;
public class Test {
public static final Set<String> MY_SET = Collections.unm<caret>odifiableSet(new HashSet<>(Arrays.asList("a", "b", "c")));
public static final Set<String> MY_SET = Collections.unm<caret>odifiableSet(new HashSet<>(Arrays.asList("a", "b", "c", Math.random() > 0.5 ? "d" : Math.random() > 0.5 ? "e" : "d")));
}