mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IJ-CR-7352 [java] Fix inspection descriptions
GitOrigin-RevId: 6690332575359f1f9bab67d976756c570004179e
This commit is contained in:
committed by
intellij-monorepo-bot
parent
01a577572c
commit
af042e1eb6
@@ -3,7 +3,6 @@
|
||||
Reports cases where a <code>Comparator</code> is defined as a lambda expression which could be expressed using
|
||||
methods like <code>Comparator.comparing()</code>.
|
||||
This inspection also reports chain comparisons which can be replaced by <code>Comparator.thenComparing()</code>.
|
||||
<!-- tooltip end -->
|
||||
<p>Example:</p>
|
||||
<pre>
|
||||
myList.sort((person1, person2) -> person1.getName().compareTo(person2.getName()));
|
||||
@@ -23,6 +22,7 @@ This inspection also reports chain comparisons which can be replaced by <code>Co
|
||||
.thenComparing(Person::second)
|
||||
.thenComparingInt(Person::third));
|
||||
</pre>
|
||||
<!-- tooltip end -->
|
||||
<p><small>New in 2016.3</small></p>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,7 +1,6 @@
|
||||
<html>
|
||||
<body>
|
||||
Reports duplicate exceptions in a method throws list.
|
||||
<!-- tooltip end -->
|
||||
<p>Example:</p>
|
||||
<pre>
|
||||
void f() throws Exception, Exception {}
|
||||
@@ -10,6 +9,7 @@ Reports duplicate exceptions in a method throws list.
|
||||
<pre>
|
||||
void f() throws Exception {}
|
||||
</pre>
|
||||
<!-- tooltip end -->
|
||||
<p>
|
||||
Use the checkbox below to ignore exceptions subclassing others.
|
||||
</p>
|
||||
|
||||
@@ -3,13 +3,13 @@
|
||||
Reports when <code>equals()</code> is called on specific classes like <code>StringBuilder</code> or <code>StringBuffer</code>.
|
||||
The <code>equals()</code> method is not overridden in these classes, so may return <code>false</code> even when the contents of two objects are the same.
|
||||
If reference equality is intended, it's better to use <code>==</code> to avoid confusion.
|
||||
<!-- tooltip end -->
|
||||
<p>Example:</p>
|
||||
<pre>
|
||||
public void test(StringBuilder sb1, StringBuilder sb2) {
|
||||
boolean result = sb1.equals(sb2); // Suspicious
|
||||
}
|
||||
</pre>
|
||||
<!-- tooltip end -->
|
||||
<p><small>New in 2017.2</small></p>
|
||||
</body>
|
||||
</html>
|
||||
@@ -5,15 +5,17 @@ Reports method references mapped to the <code>Comparator</code> interface which
|
||||
Some method references like <code>Integer::max</code> can be mapped to the <code>Comparator</code> interface.
|
||||
However using them as <code>Comparator</code> is meaningless and the result might be unpredictable.
|
||||
</p>
|
||||
<!-- tooltip end -->
|
||||
<p>Example:</p>
|
||||
<pre>
|
||||
ArrayList<Integer> ints = foo();
|
||||
ints.sort(Math::min);
|
||||
</pre>
|
||||
<p>After the quick-fix is applied, the result looks like this:</p>
|
||||
<pre>
|
||||
ArrayList<Integer> ints = foo();
|
||||
ints.sort(Comparator.reverseOrder());
|
||||
</pre>
|
||||
<!-- tooltip end -->
|
||||
<p><small>New in 2016.3</small></p>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,7 +1,6 @@
|
||||
<html>
|
||||
<body>
|
||||
Reports loops which can be collapsed into a single <code>Collection.removeIf</code> call.
|
||||
<!-- tooltip end -->
|
||||
<p>Example:</p>
|
||||
<pre>
|
||||
for (Iterator<String> it = collection.iterator(); it.hasNext(); ) {
|
||||
@@ -15,6 +14,7 @@ Reports loops which can be collapsed into a single <code>Collection.removeIf</co
|
||||
<pre>
|
||||
collection.removeIf(aValue -> shouldBeRemoved(aValue));
|
||||
</pre>
|
||||
<!-- tooltip end -->
|
||||
<p>
|
||||
This inspection only reports if the language level of the project or module is 8 or higher
|
||||
</p>
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
<body>
|
||||
Reports loops that cannot complete without an index overflow or that don't loop at all.
|
||||
It usually happens because of a mistake in the update operation.
|
||||
<!-- tooltip end -->
|
||||
<p>Example:</p>
|
||||
<pre>
|
||||
void foo(int s) {
|
||||
@@ -11,6 +10,7 @@ It usually happens because of a mistake in the update operation.
|
||||
}
|
||||
}
|
||||
</pre>
|
||||
<!-- tooltip end -->
|
||||
<p><small>New in 2019.1</small></p>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,6 +1,6 @@
|
||||
<html>
|
||||
<body>
|
||||
Suggests to replace a record by an ordinary <code>class</code>.
|
||||
Suggests to replace a record by an ordinary class.
|
||||
This inspection makes it possible to move a Java record to a codebase using an earlier Java version.
|
||||
<p>
|
||||
Note that the resulting class is not completely equivalent to the original record:
|
||||
@@ -20,7 +20,7 @@ This inspection makes it possible to move a Java record to a codebase using an e
|
||||
<pre>
|
||||
record Point(int x, int y) {}
|
||||
</pre>
|
||||
<p>This record will be converted to:</p>
|
||||
<p>After the quick-fix is applied, the result looks like this:</p>
|
||||
<pre>
|
||||
final class Point {
|
||||
private final int x;
|
||||
@@ -57,7 +57,7 @@ This inspection makes it possible to move a Java record to a codebase using an e
|
||||
}
|
||||
}
|
||||
</pre>
|
||||
<p>This inspection only applies from language level 15 preview.</p>
|
||||
<p>This inspection only reports if the language level of the project or module is 15 preview or higher.</p>
|
||||
<p><small>New in 2020.3</small></p>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,7 +1,6 @@
|
||||
<html>
|
||||
<body>
|
||||
Reports redundant <code>Comparator</code> combinator constructs which can be simplified.
|
||||
<!-- tooltip end -->
|
||||
<p>Example:</p>
|
||||
<pre>
|
||||
c.thenComparing(Comparator.comparing(function));
|
||||
@@ -18,6 +17,7 @@ Reports redundant <code>Comparator</code> combinator constructs which can be sim
|
||||
|
||||
Collections.min(list, Comparator.naturalOrder());
|
||||
</pre>
|
||||
<!-- tooltip end -->
|
||||
<p><small>New in 2018.1</small></p>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,7 +1,6 @@
|
||||
<html>
|
||||
<body>
|
||||
Reports comparisons where the <code>compare</code> function is superfluous.
|
||||
<!-- tooltip end -->
|
||||
Reports comparisons where the <code>compare</code> method is superfluous.
|
||||
<p>Example:</p>
|
||||
<pre>
|
||||
boolean result = Integer.compare(a, b) == 0;
|
||||
@@ -10,6 +9,7 @@ Reports comparisons where the <code>compare</code> function is superfluous.
|
||||
<pre>
|
||||
boolean result = a == b;
|
||||
</pre>
|
||||
<!-- tooltip end -->
|
||||
<p><small>New in 2018.2</small></p>
|
||||
</body>
|
||||
</html>
|
||||
@@ -2,11 +2,10 @@
|
||||
<body>
|
||||
Reports all methods with variable arity which can be annotated as <code>@SafeVarargs</code>.
|
||||
<code>@SafeVarargs</code> annotation suppresses unchecked warnings about parameterized array creation at call sites.
|
||||
<!-- tooltip end -->
|
||||
<p>Example:</p>
|
||||
<pre>
|
||||
public class Foo<T> {
|
||||
private List<T> list = new ArrayList<>();
|
||||
private List<T> list = new ArrayList<>();
|
||||
|
||||
public final void safeVarargs(T... elements) {
|
||||
Collections.addAll(list, elements);
|
||||
@@ -15,8 +14,8 @@ Reports all methods with variable arity which can be annotated as <code>@SafeVar
|
||||
</pre>
|
||||
<p>After the quick-fix is applied, the result looks like this:</p>
|
||||
<pre>
|
||||
public class Foo<T> {
|
||||
private List<T> list = new ArrayList<>();
|
||||
public class Foo<T> {
|
||||
private List<T> list = new ArrayList<>();
|
||||
|
||||
@SafeVarargs
|
||||
public final void safeVarargs(T... elements) {
|
||||
@@ -27,5 +26,6 @@ Reports all methods with variable arity which can be annotated as <code>@SafeVar
|
||||
<p>
|
||||
This annotation is not supported under Java 1.6 or earlier JVMs.
|
||||
</p>
|
||||
<!-- tooltip end -->
|
||||
</body>
|
||||
</html>
|
||||
@@ -2,21 +2,19 @@
|
||||
<body>
|
||||
Reports method calls to parameterized collections, where actual argument type does not
|
||||
correspond to the collection's elements type.
|
||||
<!-- tooltip end -->
|
||||
<p>For example if you have the following code:</p>
|
||||
<p>Example:</p>
|
||||
<pre>
|
||||
List<Integer> list = getListOfElements();
|
||||
list.remove("");
|
||||
list.remove(""); // remove is highlighted
|
||||
</pre>
|
||||
<p>
|
||||
the call to <code>remove()</code> will be highlighted.
|
||||
<!-- tooltip end -->
|
||||
<p>
|
||||
The option '<b>Report suspicious but possibly correct method calls</b>' makes it possible to ignore
|
||||
potentially correct code, like this:
|
||||
</p>
|
||||
<pre>
|
||||
Number number = new Integer(0);
|
||||
list.remove(number));
|
||||
list.remove(number);
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -10,7 +10,6 @@ Requirements:
|
||||
<p>
|
||||
Use the <b>Apply to single string literals</b> option to suggest the fix for single literals containing line breaks.
|
||||
<p>
|
||||
<!-- tooltip end -->
|
||||
<p>Example:</p>
|
||||
<pre>
|
||||
String html = "<html>\n" +
|
||||
@@ -29,7 +28,8 @@ Use the <b>Apply to single string literals</b> option to suggest the fix for sin
|
||||
</html>
|
||||
""";
|
||||
</pre>
|
||||
<p>This inspection only reports if the configured language level is 15 or higher.</p>
|
||||
<!-- tooltip end -->
|
||||
<p>This inspection only reports if the language level of the project or module is 15 or higher.</p>
|
||||
<p><small>New in 2019.3</small></p>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,6 +1,6 @@
|
||||
<html>
|
||||
<body>
|
||||
Reports invalid arguments passed to functions with parameters annotated as <code>@PropertyKey</code>.
|
||||
Reports invalid arguments passed to methods with parameters annotated as <code>@PropertyKey</code>.
|
||||
These arguments should be valid property keys in the respective properties files.
|
||||
Also verifies that the <code>resourceBundle</code>
|
||||
argument of the <code>@PropertyKey</code> annotation is an existing resource bundle.
|
||||
|
||||
@@ -3,15 +3,19 @@
|
||||
Reports cases where the static <code>Integer.compare()</code> method or similar methods can be used
|
||||
instead of more verbose or less efficient constructs.
|
||||
If <code>x</code> and <code>y</code> are already boxed integers, then <code>x.compareTo(y)</code> is suggested.
|
||||
<!-- tooltip end -->
|
||||
<p>Example:</p>
|
||||
<pre>
|
||||
int z = x > y ? 1 : x < y ? -1 : 0;
|
||||
public int compare(int x, int y) {
|
||||
return x > y ? 1 : x < y ? -1 : 0;
|
||||
}
|
||||
</pre>
|
||||
<p>After the quick-fix is applied, the result looks like this:</p>
|
||||
<pre>
|
||||
int z = Integer.compare(x, y);
|
||||
public int compare(int x, int y) {
|
||||
return Integer.compare(x, y);
|
||||
}
|
||||
</pre>
|
||||
<!-- tooltip end -->
|
||||
<p>
|
||||
<code>Double.compare</code> and <code>Float.compare</code> methods appeared in Java 1.4, methods for other primitive types
|
||||
are available since Java 1.7.
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// "Fix all 'Comparator function can be simplified' problems in file" "true"
|
||||
// "Fix all 'Comparator method can be simplified' problems in file" "true"
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// "Fix all 'Comparator function can be simplified' problems in file" "true"
|
||||
// "Fix all 'Comparator method can be simplified' problems in file" "true"
|
||||
import java.util.*;
|
||||
import java.util.stream.*;
|
||||
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// "Fix all 'Comparator function can be simplified' problems in file" "true"
|
||||
// "Fix all 'Comparator method can be simplified' problems in file" "true"
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// "Fix all 'Comparator function can be simplified' problems in file" "true"
|
||||
// "Fix all 'Comparator method can be simplified' problems in file" "true"
|
||||
import java.util.*;
|
||||
import java.util.stream.*;
|
||||
|
||||
|
||||
@@ -668,15 +668,15 @@ inspection.same.parameter.fix.name=Inline value ''{1}'' for parameter ''{0}''
|
||||
inspection.same.parameter.problem.descriptor=Actual value of parameter ''{0}'' is always ''{1}''
|
||||
inspection.scope.for.title=Scope
|
||||
inspection.simplifiable.comparator.comparing.message=Unnecessary ''{0}()'' call
|
||||
inspection.simplifiable.comparator.display.name=Comparator function can be simplified
|
||||
inspection.simplifiable.comparator.display.name=Comparator method can be simplified
|
||||
inspection.simplifiable.comparator.entry.comparator.message=''{0}'' can be used instead
|
||||
inspection.simplifiable.comparator.fix.comparing.family.name=Remove redundant call
|
||||
inspection.simplifiable.comparator.fix.entry.comparator.family.name=Use predefined 'Map.Entry' comparator
|
||||
inspection.simplifiable.comparator.fix.remove.name=Remove ''{0}()'' call
|
||||
inspection.simplifiable.comparator.fix.replace.name=Remove ''{0}()'' call and use ''{1}()''
|
||||
inspection.simplifiable.comparator.fix.reversed.family.name=Simplify comparator function replacing 'max' with 'min'
|
||||
inspection.simplifiable.comparator.fix.reversed.family.name=Simplify comparator method replacing 'max' with 'min'
|
||||
inspection.simplifiable.comparator.fix.reversed.name=Replace with ''{0}'' simplifying the comparator
|
||||
inspection.simplifiable.comparator.reversed.message=Comparator function can be simplified if ''{0}()'' call is replaced with ''{1}()''
|
||||
inspection.simplifiable.comparator.reversed.message=Comparator method can be simplified if ''{0}()'' call is replaced with ''{1}()''
|
||||
inspection.simplify.collector.fix.family.name=Simplify cascaded collector
|
||||
inspection.simplify.collector.fix.name=Use ''Collectors.{0}'' collector
|
||||
inspection.simplify.collector.message=Can be simplified using ''{0}'' collector
|
||||
|
||||
+1
-1
@@ -4,10 +4,10 @@ Reports calls to <code>divide()</code> or <code>setScale()</code> without a roun
|
||||
Such calls can lead to an <code>ArithmeticException</code> when the exact value cannot be represented in the result
|
||||
(e.g. because it has a non-terminating decimal expansion).
|
||||
Specifying a rounding mode prevents the <code>ArithmeticException</code>.
|
||||
<!-- tooltip end -->
|
||||
<p>Example:</p>
|
||||
<pre>
|
||||
BigDecimal.valueOf(1).divide(BigDecimal.valueOf(3));
|
||||
</pre>
|
||||
<!-- tooltip end -->
|
||||
</body>
|
||||
</html>
|
||||
+1
-2
@@ -2,7 +2,6 @@
|
||||
<body>
|
||||
Reports methods with a <code>boolean</code> return type, which are only used in a negated context.
|
||||
Due to performance reasons some methods might not be reported during in-editor highlighting.
|
||||
<!-- tooltip end -->
|
||||
<p>Example:</p>
|
||||
<pre>
|
||||
class C {
|
||||
@@ -33,6 +32,6 @@ Due to performance reasons some methods might not be reported during in-editor h
|
||||
boolean member = notInvertedAnymore();
|
||||
}
|
||||
</pre>
|
||||
|
||||
<!-- tooltip end -->
|
||||
</body>
|
||||
</html>
|
||||
|
||||
+1
-1
@@ -3,10 +3,10 @@
|
||||
Reports calls to <code>equals()</code> where the target and argument are
|
||||
of incompatible types. While such a call might theoretically be useful, most likely it represents
|
||||
a bug.
|
||||
<!-- tooltip end -->
|
||||
<p>Example:</p>
|
||||
<pre>
|
||||
new HashSet<String>() {}.equals(new TreeSet<Integer>());
|
||||
</pre>
|
||||
<!-- tooltip end -->
|
||||
</body>
|
||||
</html>
|
||||
+1
-1
@@ -2,7 +2,6 @@
|
||||
<body>
|
||||
Reports <code>if</code> statements where common parts can be extracted from the branches.
|
||||
These common parts are independent from the condition and make <code>if</code> statements harder to understand.
|
||||
<!-- tooltip end -->
|
||||
<p>Example:</p>
|
||||
<pre>
|
||||
if (x > 12) {
|
||||
@@ -25,6 +24,7 @@ These common parts are independent from the condition and make <code>if</code> s
|
||||
}
|
||||
doSomethingAfter();
|
||||
</pre>
|
||||
<!-- tooltip end -->
|
||||
<p><small>Updated in 2018.1</small></p>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
+1
-1
@@ -1,7 +1,6 @@
|
||||
<html>
|
||||
<body>
|
||||
Reports methods which can be converted to a variable arity method.
|
||||
<!-- tooltip end -->
|
||||
<p>Example:</p>
|
||||
<pre>
|
||||
void process(String name, Object[] objects);
|
||||
@@ -10,6 +9,7 @@ Reports methods which can be converted to a variable arity method.
|
||||
<pre>
|
||||
void process(String name, Object... objects);
|
||||
</pre>
|
||||
<!-- tooltip end -->
|
||||
<p>
|
||||
This inspection only reports if the language level of the project or module is 5 or higher.
|
||||
</p>
|
||||
|
||||
+1
-1
@@ -6,7 +6,6 @@ the value is used to update the field. It is possible for the value of the
|
||||
field to change between the read and the write, possibly invalidating the operation.
|
||||
The non-atomic operation can be avoided by surrounding it with a <code>synchronized</code> block or
|
||||
by making use of one of the classes from the <code>java.util.concurrent.atomic</code> package.
|
||||
<!-- tooltip end -->
|
||||
<p>Example:</p>
|
||||
<pre>
|
||||
private volatile int v = 1;
|
||||
@@ -15,5 +14,6 @@ by making use of one of the classes from the <code>java.util.concurrent.atomic</
|
||||
v = 2 * this.v;
|
||||
}
|
||||
</pre>
|
||||
<!-- tooltip end -->
|
||||
</body>
|
||||
</html>
|
||||
@@ -4,7 +4,6 @@ Reports unnecessary local variables, which add nothing to the comprehensibility
|
||||
Variables caught include local variables which are immediately returned,
|
||||
local variables that are immediately assigned to another variable and then not used,
|
||||
and local variables which always have the same value as another local variable or parameter.
|
||||
<!-- tooltip end -->
|
||||
<p>Example:</p>
|
||||
<pre>
|
||||
boolean yes() {
|
||||
@@ -25,6 +24,6 @@ and local variables which always have the same value as another local variable o
|
||||
<p>
|
||||
Use the second checkbox below to have this inspection ignore annotated variables.
|
||||
</p>
|
||||
|
||||
<!-- tooltip end -->
|
||||
</body>
|
||||
</html>
|
||||
+1
-1
@@ -2,7 +2,6 @@
|
||||
<body>
|
||||
Reports unnecessary creation of temporary objects when converting
|
||||
from a primitive type to a <code>String</code>.
|
||||
<!-- tooltip end -->
|
||||
<p>Example:</p>
|
||||
<pre>
|
||||
String foo = new Integer(3).toString();
|
||||
@@ -11,5 +10,6 @@ from a primitive type to a <code>String</code>.
|
||||
<pre>
|
||||
String foo = Integer.toString(3);
|
||||
</pre>
|
||||
<!-- tooltip end -->
|
||||
</body>
|
||||
</html>
|
||||
@@ -12,7 +12,6 @@ Reports parameterized tests which have malformed sources:
|
||||
No sources are defined.
|
||||
</li>
|
||||
</ul>
|
||||
<!-- tooltip end -->
|
||||
<p>Example:</p>
|
||||
<pre>
|
||||
class Test {
|
||||
@@ -33,6 +32,7 @@ Reports parameterized tests which have malformed sources:
|
||||
void foo(String param) {}
|
||||
}
|
||||
</pre>
|
||||
<!-- tooltip end -->
|
||||
<p>
|
||||
<small>New in 2017.2</small>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user