[java] Update inspection descriptions

GitOrigin-RevId: c9f960eb87b520f47644c31cdfabf03434ee9b59
This commit is contained in:
Louis Vignier
2021-03-16 14:56:18 +00:00
committed by intellij-monorepo-bot
parent 8de4a1befe
commit d830ccbf28
38 changed files with 168 additions and 134 deletions
@@ -222,7 +222,7 @@ inspection.common.if.parts.disable.highlight.tail.call=Do not highlight common p
inspection.common.if.parts.family.else.if.description='else if' can be merged
inspection.common.if.parts.family.else.if=Merge 'else if' statement
inspection.common.if.parts.family=Extract common parts of 'if' statement
inspection.common.if.parts.settings.highlight.when.tail.call=Highlight when last common statement is call
inspection.common.if.parts.settings.highlight.when.tail.call=Highlight when the last common statement is a call
inspection.compiler.javac.quirks.anno.array.comma.fix=Remove trailing comma
inspection.compiler.javac.quirks.anno.array.comma.problem=Trailing comma in annotation array initializer may cause compilation error in some Javac versions (e.g. JDK 5 and JDK 6).
inspection.compiler.javac.quirks.name=Javac quirks
@@ -236,12 +236,13 @@ inspection.data.flow.simplify.to.assignment.quickfix.name=Simplify to normal ass
inspection.data.flow.turn.off.constant.references.quickfix=Don't report values which are guaranteed to be constant
inspection.data.flow.turn.off.nullable.returning.notnull.quickfix=Don't report nullable methods which always return not-null value
inspection.data.flow.turn.off.true.asserts.quickfix=Don't report always true assertions
inspection.duplicate.throws.display.name=Duplicate throws
inspection.duplicate.throws.display.name=Duplicate 'throws'
inspection.duplicate.throws.ignore.subclassing.option=Ignore exceptions subclassing others
inspection.duplicate.throws.more.general.problem=There is a more general exception, ''{0}'', in the throws list already.
inspection.duplicate.throws.problem=Duplicate throws
inspection.duplicate.throws.more.general.problem=There is a more general exception, ''{0}'', in the <code>throws</code> list already.
inspection.duplicate.throws.problem=Duplicate <code>throws</code>
inspection.equals.hashcode.only.one.defined.problem.descriptor=Class has {0} defined but does not define {1}
inspection.export.results.can.be.final.description=Declaration can have final modifier
inspection.expression.can.be.replaced.with.message=Expression can be replaced with ''{0}''
inspection.field.not.used.in.to.string.description2=Field ''{0}'' is not used in ''toString()'' method
inspection.field.not.used.in.to.string.description=Method ''{0}'' is not used in ''toString()'' method
inspection.implicit.subclass.display.forClass=Class ''{0}'' could be implicitly subclassed and must not be final
@@ -63,7 +63,7 @@ public class UseCompareMethodInspection extends AbstractBaseJavaLocalInspectionT
}
private void register(CompareInfo info, PsiElement nameElement) {
holder.registerProblem(nameElement, JavaAnalysisBundle.message("inspection.can.be.replaced.with.message", info.myClass.getClassName() + ".compare"),
holder.registerProblem(nameElement, JavaAnalysisBundle.message("inspection.expression.can.be.replaced.with.message", info.myClass.getClassName() + ".compare"),
new ReplaceWithPrimitiveCompareFix(info.getReplacementText()));
}
};
@@ -140,9 +140,9 @@ fix.parameter.type.text=Make ''{0}'' take parameter of type ''{1}'' here
fix.return.type.family=Fix return type
fix.return.type.or.predecessor.text=Make ''{0}'' return ''{1}'' or predecessor
fix.return.type.text=Make ''{0}'' return ''{1}''
fix.throws.list.family=Fix throws list
fix.throws.list.add.exception=Add ''{0}'' to ''{1}'' throws list
fix.throws.list.remove.exception=Remove ''{0}'' from ''{1}'' throws list
fix.throws.list.family=Fix 'throws' list
fix.throws.list.add.exception=Add ''{0}'' to ''{1}'' 'throws' list
fix.throws.list.remove.exception=Remove ''{0}'' from ''{1}'' 'throws' list
fix.modifiers.family=Fix modifiers
anonymous.class.presentation=Anonymous class derived from {0}
@@ -1,21 +1,17 @@
<html>
<body>
Reports duplicate exceptions in a method throws list.
For example:
<code><pre>
<b>void</b> f() <b>throws</b> Exception, <b>Exception</b> {
}
</pre></code>
<br>
The inspection also warns if one exception subclasses another.
For example:
<code><pre>
<b>void</b> f() <b>throws</b> <b>IOException</b>, Exception {
}
</pre></code>
Reports duplicate exceptions in a method <code>throws</code> list.
<!-- tooltip end -->
<p>Example:</p>
<pre>
void f() throws Exception, Exception {}
</pre>
<p>After the quick-fix is applied, the result looks like this:</p>
<pre>
void f() throws Exception {}
</pre>
<p>
Use the checkbox below to ignore exceptions subclassing others.
Use the checkbox below to ignore exceptions subclassing others.
</p>
</body>
</html>
@@ -1,11 +1,13 @@
<html>
<body>
The inspection detects a situation where Java 9 module A requires Java 9 module B, but A doesn't use any package from B.
Also, requiring the module 'java.base' is redundant.
<p>
The fix deletes the 'requires' directive for such redundant dependencies.
If the deleted dependency re-exported modules that are actually used, the fix adds 'requires' directive for these modules.
Reports situations where a Java 9 module <code>A</code> requires a Java 9 module <code>B</code>,
but <code>A</code> doesn't use any package from <code>B</code>.
Also, requiring the module <code>java.base</code> is redundant.
<!-- tooltip end -->
<p>
The fix deletes the <code>requires</code> directive for such redundant dependencies.
If the deleted dependency re-exported modules that are actually used, the fix adds a <code>requires</code> directive for these modules.
</p>
<small>New in 2017.1</small>
</body>
</html>
@@ -1,19 +1,18 @@
<html>
<body>
Suggests to replace records with ordinary classes.
The inspection could be useful if you need to move a Java record
to codebases that use earlier Java versions.
Suggests to replace a <code>record</code> by an ordinary <code>class</code>.
This inspection makes it possible to move a Java <code>record</code> to a codebase using an earlier Java version.
<p>
Note that the resulting class is not completely equivalent to the original record:
Note that the resulting <code>class</code> is not completely equivalent to the original <code>record</code>:
</p>
<ul>
<li>the resulting class no longer extends <code>java.lang.Record</code>,
so <code>instanceof Record</code> returns false.</li>
<li>the resulting <code>class</code> no longer extends <code>java.lang.Record</code>,
so <code>instanceof Record</code> returns <code>false</code>.</li>
<li>reflection methods like <code>Class.isRecord()</code> and
<code>Class.getRecordComponents()</code> produce different results.</li>
<li>the generated <code>hashCode()</code> implementation may produce a different result
because the formula to calculate record hashCode is deliberately not specified.</li>
<li>record serialization mechanism differs from that of ordinary classes.
because the formula to calculate <code>record</code> <code>hashCode</code> is deliberately not specified.</li>
<li><code>record</code> serialization mechanism differs from that of an ordinary <code>class</code>.
Refer to Java Object Serialization Specification for details.</li>
</ul>
<!-- tooltip end -->
@@ -21,7 +20,7 @@ to codebases that use earlier Java versions.
<pre>
record Point(int x, int y) {}
</pre>
This record will be converted to
<p>This record will be converted to:</p>
<pre>
final class Point {
private final int x;
@@ -32,21 +31,17 @@ This record will be converted to
this.y = y;
}
public int x() {
return x;
}
public int x() { return x; }
public int y() {
return y;
}
public int y() { return y; }
@Override
public boolean equals(Object obj) {
if (obj == this) return true;
if (obj == null || obj.getClass() != this.getClass()) return false;
var that = (Point) obj;
var that = (Point)obj;
return this.x == that.x &&
this.y == that.y;
this.y == that.y;
}
@Override
@@ -57,12 +52,12 @@ This record will be converted to
@Override
public String toString() {
return "Point[" +
"x=" + x + ", " +
"y=" + y + ']';
"x=" + x + ", " +
"y=" + y + ']';
}
}
</pre>
<p>This inspection only applies to language level 14 preview and 15 preview.</p>
<p>This inspection only applies from language level 15 preview.</p>
<p><small>New in 2020.3</small></p>
</body>
</html>
@@ -1,13 +1,21 @@
<html>
<body>
Suggests to use the static <code>Integer.compare()</code> method and similar methods where more verbose or less efficient constructs are
used. For example, <code>x &gt; y ? 1 : x &lt; y ? -1 : 0</code> or <code>Integer.valueOf(x).compareTo(y)</code> could be
replaced with <code>Integer.compare(x, y)</code>. If <code>x</code> and <code>y</code> are already boxed integers, then
<code>x.compareTo(y)</code> is suggested.
<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</p>
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;
</pre>
<p>After the quick-fix is applied, the result looks like this:</p>
<pre>
int z = Integer.compare(x, y);
</pre>
<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.
</p>
<p><small>New in 2017.2</small></p>
</body>
</html>
@@ -2,12 +2,12 @@ import java.io.*;
class X {
void f() throws
<warning descr="Duplicate throws">Exception</warning>,
<warning descr="Duplicate 'throws'">Exception</warning>,
Exception {
}
void f2() throws
Exception,
<warning descr="There is a more general exception, 'java.lang.Exception', in the throws list already.">IllegalArgumentException</warning> {
<warning descr="There is a more general exception, 'java.lang.Exception', in the 'throws' list already.">IllegalArgumentException</warning> {
}
void f3() throws
FileNotFoundException,
@@ -15,8 +15,8 @@ class X {
}
public void TTT() throws
<warning descr="Duplicate throws">FileNotFoundException</warning>,
<warning descr="Duplicate throws">EOFException</warning>,
<warning descr="Duplicate 'throws'">FileNotFoundException</warning>,
<warning descr="Duplicate 'throws'">EOFException</warning>,
FileNotFoundException,
EOFException {
}
@@ -1,4 +1,4 @@
// "Convert record to class" "true"
// "Convert 'record' to 'class'" "true"
import java.lang.annotation.*;
import java.util.Objects;
@@ -1,4 +1,4 @@
// "Convert record to class" "true"
// "Convert 'record' to 'class'" "true"
import java.lang.annotation.*;
import java.util.Objects;
@@ -1,6 +1,6 @@
import java.util.Objects;
// "Convert record to class" "true"
// "Convert 'record' to 'class'" "true"
final class Range implements Cloneable {
private final int x;
private final int y;
@@ -1,6 +1,6 @@
import java.util.Objects;
// "Convert record to class" "true"
// "Convert 'record' to 'class'" "true"
final class Range {
private final int x;
private final int y;
@@ -1,6 +1,6 @@
import java.util.Objects;
// "Convert record to class" "true"
// "Convert 'record' to 'class'" "true"
final class Range {
static final Range ZERO = new Range(0);
private final int x;
@@ -1,6 +1,6 @@
import java.util.Objects;
// "Convert record to class" "true"
// "Convert 'record' to 'class'" "true"
final class R<T> {
private final T t;
@@ -1,6 +1,6 @@
import java.util.Objects;
// "Convert record to class" "true"
// "Convert 'record' to 'class'" "true"
final class Rec {
private final int x;
private final int y;
@@ -1,4 +1,4 @@
// "Convert record to class" "true"
// "Convert 'record' to 'class'" "true"
class X {
private static final class R {
private R() {
@@ -1,4 +1,4 @@
// "Convert record to class" "true"
// "Convert 'record' to 'class'" "true"
final class R {
R() {
}
@@ -1,4 +1,4 @@
// "Convert record to class" "true"
// "Convert 'record' to 'class'" "true"
import java.util.Objects;
@@ -1,4 +1,4 @@
// "Convert record to class" "true"
// "Convert 'record' to 'class'" "true"
import java.lang.annotation.*;
@Target({ElementType.PARAMETER, ElementType.METHOD, ElementType.FIELD, ElementType.TYPE_USE})
@@ -1,4 +1,4 @@
// "Convert record to class" "true"
// "Convert 'record' to 'class'" "true"
import java.lang.annotation.*;
@Target(ElementType.FIELD)
@@ -1,4 +1,4 @@
// "Convert record to class" "true"
// "Convert 'record' to 'class'" "true"
<caret>record Range(int x, int y) implements Cloneable {
Range(int x, int y) {
if (x > y) {
@@ -1,4 +1,4 @@
// "Convert record to class" "true"
// "Convert 'record' to 'class'" "true"
record <caret>Range(int x, int y) {
/**
* Checks invariant
@@ -1,4 +1,4 @@
// "Convert record to class" "true"
// "Convert 'record' to 'class'" "true"
record <caret>Range(int x, int y) {
static final Range ZERO = new Range(0);
@@ -1,2 +1,2 @@
// "Convert record to class" "true"
// "Convert 'record' to 'class'" "true"
final record <caret>R<T>(T t) {}
@@ -1,2 +1,2 @@
// "Convert record to class" "true"
// "Convert 'record' to 'class'" "true"
record <caret>Rec(int x, int y
@@ -1,4 +1,4 @@
// "Convert record to class" "true"
// "Convert 'record' to 'class'" "true"
class X {
private record <caret>R() {}
}
@@ -1,2 +1,2 @@
// "Convert record to class" "true"
// "Convert 'record' to 'class'" "true"
record R() {<caret>}
@@ -1,4 +1,4 @@
// "Convert record to class" "true"
// "Convert 'record' to 'class'" "true"
/**
* Cool record.
@@ -1,6 +1,6 @@
import java.util.Objects;
// "Convert record to class" "true"
// "Convert 'record' to 'class'" "true"
final class Point {
private final double x;
private final double y;
@@ -1,6 +1,6 @@
import java.util.Objects;
// "Convert record to class" "true"
// "Convert 'record' to 'class'" "true"
public final class Point {
private final int x;
private final int y;
@@ -1,4 +1,4 @@
// "Convert record to class" "true"
// "Convert 'record' to 'class'" "true"
record Point(double x, double y) {
void foo() {}
}<caret>
@@ -1,2 +1,2 @@
// "Convert record to class" "true"
// "Convert 'record' to 'class'" "true"
public record Point(int x, int y) {}<caret>
@@ -12,12 +12,12 @@ public class SerializableRecordCanBeClassInspectionTest extends LightJavaInspect
public void testSerializableVersionUIDWithoutSerial() {
doTest("import java.io.Serializable;\n" +
"record <warning descr=\"Record can be converted to a class\"><caret>R</warning>() implements Serializable {\n" +
"record <warning descr=\"'record' can be converted to 'class'\"><caret>R</warning>() implements Serializable {\n" +
" @MyAnn\n" +
" private static final long serialVersionUID = 1;\n" +
" static long number = 10;\n" +
"}");
checkQuickFix("Convert record to class", "import java.io.Serial;\n" +
checkQuickFix("Convert 'record' to 'class'", "import java.io.Serial;\n" +
"import java.io.Serializable;\n" +
"\n" +
"final class R implements Serializable {\n" +
@@ -50,13 +50,13 @@ public class SerializableRecordCanBeClassInspectionTest extends LightJavaInspect
public void testSerializableVersionUIDWithSerial() {
doTest("import java.io.Serial;\n" +
"import java.io.Serializable;\n" +
"record <warning descr=\"Record can be converted to a class\"><caret>R</warning>() implements Serializable {\n" +
"record <warning descr=\"'record' can be converted to 'class'\"><caret>R</warning>() implements Serializable {\n" +
" @Serial" +
" @MyAnn\n" +
" private static final long serialVersionUID = 1;\n" +
" static long number = 10;\n" +
"}");
checkQuickFix("Convert record to class", "import java.io.Serial;\n" +
checkQuickFix("Convert 'record' to 'class'", "import java.io.Serial;\n" +
"import java.io.Serializable;\n" +
"\n" +
"final class R implements Serializable {\n" +
@@ -88,10 +88,10 @@ public class SerializableRecordCanBeClassInspectionTest extends LightJavaInspect
public void testWithoutSerialVersionUID() {
doTest("import java.io.Serializable;\n" +
"record <warning descr=\"Record can be converted to a class\"><caret>R</warning>() implements Serializable {\n" +
"record <warning descr=\"'record' can be converted to 'class'\"><caret>R</warning>() implements Serializable {\n" +
" static long number = 10;\n" +
"}");
checkQuickFix("Convert record to class", "import java.io.Serial;\n" +
checkQuickFix("Convert 'record' to 'class'", "import java.io.Serial;\n" +
"import java.io.Serializable;\n" +
"\n" +
"final class R implements Serializable {\n" +
@@ -122,12 +122,12 @@ public class SerializableRecordCanBeClassInspectionTest extends LightJavaInspect
public void testSerialVersionUIDWithWrongModifier() {
doTest("import java.io.Serializable;\n" +
"record <warning descr=\"Record can be converted to a class\"><caret>R</warning>() implements Serializable {\n" +
"record <warning descr=\"'record' can be converted to 'class'\"><caret>R</warning>() implements Serializable {\n" +
" static long number = 10;\n" +
" @MyAnn\n" +
" private static long serialVersionUID = 10;\n" + // not final
"}");
checkQuickFix("Convert record to class", "import java.io.Serializable;\n" +
checkQuickFix("Convert 'record' to 'class'", "import java.io.Serializable;\n" +
"\n" +
"final class R implements Serializable {\n" +
" static long number = 10;\n" +
@@ -40,8 +40,8 @@ assignment.to.declared.variable.problem.descriptor=Variable ''{0}'' is initializ
assignment.to.itself.problem.descriptor=Variable ''{0}'' is assigned to itself
assignment.to.itself.quickfix.name=Remove self assignment
bean.property=Bean Property
boolean.method.is.always.inverted.display.name=Boolean method is always inverted
boolean.method.is.always.inverted.problem.descriptor=Boolean method <code>#ref</code> is always inverted
boolean.method.is.always.inverted.display.name='boolean' method is always inverted
boolean.method.is.always.inverted.problem.descriptor=<code>boolean</code> method <code>#ref</code> is always inverted
button.add.blank=Add Blank
button.add.class=Add Class...
button.add=Add...
@@ -1305,8 +1305,8 @@ update.external.annotations=Update External Annotations
intention.create.switch.statement=Create switch statement
sort.threads.by.type=Sort Threads by Type
sort.threads.by.name=Sort Threads by Name
inspection.message.record.can.be.converted.to.class=Record can be converted to a class
intention.family.name.convert.record.to.class=Convert record to class
inspection.message.record.can.be.converted.to.class='record' can be converted to 'class'
intention.family.name.convert.record.to.class=Convert 'record' to 'class'
class.can.be.record.display.name=Class can be a record
class.can.be.record.quick.fix=Convert to a record
class.can.be.record.suggest.renaming.accessors=Suggest renaming get/is-accessors
@@ -1,25 +1,38 @@
<html>
<body>
Reports methods with a <b>boolean</b> return type, which are only used in a negated context.
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.
<p>
For example:
<code><pre>
<b>class</b> C {
<b>boolean</b> inverted() {
<b>return</b> <b>true</b>;
}
<b>void</b> f() {
<b>if</b> (!inverted()) {
<b>return</b>;
}
}
<b>boolean</b> member = !inverted();
}
</pre></code>
<!-- tooltip end -->
<p>
<p>Example:</p>
<pre>
class C {
boolean alwaysInverted() {
return true;
}
void f() {
if (!alwaysInverted()) {
return;
}
}
boolean member = !alwaysInverted();
}
</pre>
<p>After the quick-fix is applied (the function name can be changed), the result looks like this:</p>
<pre>
class C {
boolean notInvertedAnymore() {
return false;
}
void f() {
if (notInvertedAnymore()) {
return;
}
}
boolean member = notInvertedAnymore();
}
</pre>
</body>
</html>
@@ -1,9 +1,10 @@
<html>
<body>
Inspection that can extract common parts from branches of if statement.
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>Before:</p>
<pre><code>
<p>Example:</p>
<pre>
if (x > 12) {
doSomethingBefore();
doSomethingDifferent1();
@@ -13,9 +14,9 @@ Inspection that can extract common parts from branches of if statement.
doSomethingDifferent2();
doSomethingAfter();
}
</code></pre>
<p>After:</p>
<pre><code>
</pre>
<p>After the quick-fix is applied, the result looks like this:</p>
<pre>
doSomethingBefore();
if (x > 12) {
doSomethingDifferent1();
@@ -23,7 +24,7 @@ Inspection that can extract common parts from branches of if statement.
doSomethingDifferent2();
}
doSomethingAfter();
</code></pre>
</pre>
<p><small>Updated in 2018.1</small></p>
</body>
</html>
@@ -1,10 +1,16 @@
<html>
<body>
Reports <b>return</b> statements inside of <b>finally</b>
blocks. While occasionally intended, such <b>return</b> statements may mask exceptions thrown, and
tremendously complicate debugging.
Reports <code>return</code> statements inside of <code>finally</code> blocks.
While occasionally intended, such <code>return</code> statements may mask thrown exceptions,
and tremendously complicate debugging.
<!-- tooltip end -->
<p>
<p>Example:</p>
<pre>
try {
foo();
} finally {
if (bar()) return;
}
</pre>
</body>
</html>
@@ -1,18 +1,30 @@
<html>
<body>
Reports unnecessary local variables, which add
nothing to the comprehensibility of a method. 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.
Reports unnecessary local variables, which add nothing to the comprehensibility of a method.
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() {
boolean b = true;
return b;
}
</pre>
<p>After the quick-fix is applied, the result looks like this:</p>
<pre>
boolean yes() {
return true;
}
</pre>
<p>
Use the first checkbox below to have this inspection ignore variables which are immediately
returned or thrown. Some coding styles suggest using such variables for clarity and
ease of debugging.
<p>
Use the second checkbox below to have this inspection ignore variable which are annotated.
Use the first checkbox below to have this inspection ignore immediately returned or thrown variables.
Some coding styles suggest using such variables for clarity and ease of debugging.
</p>
<p>
Use the second checkbox below to have this inspection ignore annotated variables.
</p>
</body>
</html>