diff --git a/java/java-impl/src/inspectionDescriptions/ConditionalBreakInInfiniteLoop.html b/java/java-impl/src/inspectionDescriptions/ConditionalBreakInInfiniteLoop.html index 4bcec8baa059..dbb4d43a8557 100644 --- a/java/java-impl/src/inspectionDescriptions/ConditionalBreakInInfiniteLoop.html +++ b/java/java-impl/src/inspectionDescriptions/ConditionalBreakInInfiniteLoop.html @@ -1,19 +1,19 @@
-Detects conditional breaks at the beginning or end of a loop and suggests to use a loop condition instead. +Reports conditional breaks at the beginning or end of a loop and suggests to use a loop condition instead, to create shorter code. +Example: +
+ while (true) {
+ if (i == 23) break;
+ i++;
+ }
+
+After the quick fix is applied the result looks like: +
+ while (i != 23) {
+ i++;
+ }
+
-Example:
-
- while(true) {
- if(i == 23) break;
- i++;
- }
-
Will be replaced with: -
- while(i != 23) {
- i++;
- }
-
@Contract annotations. The types of issues that can be reported are:
+true when the contract says false)Example: +
+ // method has no parameters, but contract expects 1
+ @Contract("_ -> fail")
+ void x() {
+ throw new AssertionError();
+ }
+
\ No newline at end of file
diff --git a/java/java-impl/src/inspectionDescriptions/Convert2streamapi.html b/java/java-impl/src/inspectionDescriptions/Convert2streamapi.html
index daaa27b60cf9..4936f7e39403 100644
--- a/java/java-impl/src/inspectionDescriptions/Convert2streamapi.html
+++ b/java/java-impl/src/inspectionDescriptions/Convert2streamapi.html
@@ -1,7 +1,25 @@
-Reports loops which can be replaced with stream API calls.
--The Stream API is not available under Java 7 or earlier JVMs. +Reports loops which can be replaced with stream API calls using lambda expressions. +This inspection only reports if the configured language level is 8 or higher. + +
Example: +
+ boolean check(List<String> data) {
+ for (String e : data) {
+ String trimmed = e.trim();
+ if (!trimmed.startsWith("xyz")) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+After the quick fix is applied the result looks like: +
+ boolean check(List<String> data) {
+ return data.stream().map(String::trim).allMatch(trimmed -> trimmed.startsWith("xyz"));
+ }
+
\ No newline at end of file
diff --git a/java/java-impl/src/inspectionDescriptions/FrequentlyUsedInheritorInspection.html b/java/java-impl/src/inspectionDescriptions/FrequentlyUsedInheritorInspection.html
index f9fd4585da4b..69f52635463f 100644
--- a/java/java-impl/src/inspectionDescriptions/FrequentlyUsedInheritorInspection.html
+++ b/java/java-impl/src/inspectionDescriptions/FrequentlyUsedInheritorInspection.html
@@ -1,8 +1,24 @@
-The inspection finds commonly used class/interface that could be extended/implemented instead of extending too broad interface or class.
+Reports when a more specific commonly used class or interface could be extended or implemented, instead of the current one.
+The super class needs to be located inside the project source files and
+the project needs to use the IntelliJ IDEA build system for this inspection to work.
+By default this inspection does not highlight in the editor, but only provides a quick fix.
+Example: +
+ class MyInheritor implements A {} // B suggested on the A reference
+
+ interface A {}
+
+ abstract class B implements A {}
+
+ abstract class C1 extends B {}
+ abstract class C2 extends B {}
+ abstract class C3 extends B {}
+ abstract class C4 extends B {}
+ abstract class C5 extends B {}
+
-The inspection works only if a project is built using IntelliJ IDEA build system and a super class is located inside project source files.
New in 2017.2 \ No newline at end of file diff --git a/java/java-impl/src/inspectionDescriptions/Java9CollectionFactory.html b/java/java-impl/src/inspectionDescriptions/Java9CollectionFactory.html index eacef9533e37..65d14d2ed1d4 100644 --- a/java/java-impl/src/inspectionDescriptions/Java9CollectionFactory.html +++ b/java/java-impl/src/inspectionDescriptions/Java9CollectionFactory.html @@ -1,18 +1,39 @@
-This inspection helps to convert unmodifiable collections created before Java 9 to new collection factory methods -likeList.of or Set.of. Also since Java 10 the conversion to List.copyOf, etc. could be suggested.
+Reports java.util.Collections unmodifiable collection calls,
+that can be converted to newer collection factory methods.
+These can be replaced with e.g. List.of() or Set.of() introduced in Java 9,
+or List.copyOf() introduced in Java 10.
+
+Not that, in contrast to java.util.Collections methods, the Java 9 collection factory methods
+
null values
+ null arguments to query methods like List.contains() or Map.get() of the collections returned.
+Example: +
+ List<Integer> even = Collections.unmodifiableList(
+ Arrays.asList(2, 4, 6, 8, 10, 2));
+ List<Integer> evenCopy = Collections.unmodifiableList(
+ new ArrayList<>(list1));
+
+After the quick fix is applied the result looks like: +
+ List<Integer> even = List.of(2, 4, 6, 8, 10, 2);
+ List<Integer> evenCopy = List.copyOf(list);
+
+This inspection only reports if the configured language level is 9 or higher. + -
Note that Java 9 collection factory methods do not accept null values. Also, set elements and map keys are required to be different. -It's not always possible to statically check whether original elements are different and not null. Using the checkbox you may enforce -the inspection to warn only if original elements are compile-time constants.
- Also it should be noted that some query methods like Collection.contains() or Map.get
- don't tolerate nulls as well. E.g., Collection.contains()
- throws a NullPointerException instead of returning false.
- Thus, even if the collection is initialized with non-null values only, the semantics of the code may change after migration.
-
This inspection is available since Java 9 only.
-New in 2017.2 +Use the first checkbox below to only report if the supplied arguments are compile-time constants. +This reduces the chance of changes in behaviour, +because it's not always possible to statically check whether original elements are unique and notnull.
+
+Use the second checkbox to suggest a Map.ofEntries() replacement for unmodifiable maps with more than 10 entries.
+
New in 2017.2 \ No newline at end of file diff --git a/java/java-impl/src/inspectionDescriptions/OptionalGetWithoutIsPresent.html b/java/java-impl/src/inspectionDescriptions/OptionalGetWithoutIsPresent.html index 21f180bbadbe..11cc20be3145 100644 --- a/java/java-impl/src/inspectionDescriptions/OptionalGetWithoutIsPresent.html +++ b/java/java-impl/src/inspectionDescriptions/OptionalGetWithoutIsPresent.html @@ -1,7 +1,15 @@
-Reports Optional.get() method calls without an earlier check that the optional has a value. -If the optional is empty, calling Optional.get() will throw an exception. +ReportsOptional.get() method calls without an earlier check that the optional has a value.
+If the optional is empty, calling Optional.get() will throw an exception.
+Example: +
+ void x(List<Integer> list) {
+ final Optional<Integer> optional =
+ list.stream().filter(x -> x > 10).findFirst();
+ final Integer result = optional.get(); // problem here
+ }
+
\ No newline at end of file
diff --git a/java/java-impl/src/inspectionDescriptions/ReadWriteStringCanBeUsed.html b/java/java-impl/src/inspectionDescriptions/ReadWriteStringCanBeUsed.html
index be3045358a1f..31b2db847cb0 100644
--- a/java/java-impl/src/inspectionDescriptions/ReadWriteStringCanBeUsed.html
+++ b/java/java-impl/src/inspectionDescriptions/ReadWriteStringCanBeUsed.html
@@ -1,7 +1,19 @@
-Reports code fragments that could be replaced via the Files.readString and Files.writeString
-methods introduced in Java 11.
+Reports code fragments that read or write a String as bytes using java.nio.file.Files.
+These can be replaced with calls to the Files.readString() and Files.writeString() methods, introduced in Java 11.
+Example: +
+ String s = "example";
+ Files.write(Paths.get("out.txt"), s.getBytes(StandardCharsets.UTF_8), StandardOpenOption.WRITE);
+ s = new String(Files.readAllBytes(Paths.get("in.txt")), StandardCharsets.ISO_8859_1);
+
+After the quick fix is applied the result looks like: +
+ String s = "example";
+ Files.writeString(Paths.get("out.txt"), s, StandardOpenOption.WRITE);
+ s = Files.readString(Paths.get("in.txt"), StandardCharsets.ISO_8859_1);
+
New in 2018.3
diff --git a/java/java-impl/src/inspectionDescriptions/SlowAbstractSetRemoveAll.html b/java/java-impl/src/inspectionDescriptions/SlowAbstractSetRemoveAll.html index 3855fb3a912d..4602e4907b4d 100644 --- a/java/java-impl/src/inspectionDescriptions/SlowAbstractSetRemoveAll.html +++ b/java/java-impl/src/inspectionDescriptions/SlowAbstractSetRemoveAll.html @@ -1,16 +1,23 @@ -The implementation of the'java.util.AbstractSet#removeAll' method determines which is the smaller of this set and the
-specified collection, by invoking the size method on each. If this set has fewer elements, then the implementation iterates over
-this set, checking each element returned by the iterator in turn to see if it is contained in the specified collection. If it is
-so contained, it is removed from this set with the iterator's remove method. If the specified collection has fewer elements, then
-the implementation iterates over the specified collection, removing from this set each element returned by the iterator, using this
-set's remove method.
-
-It means that if the collection to remove is of equal or larger size than the set, then the implementation of the
-'java.util.List#contains' method is called, which in many implementations they will perform costly linear
-searches.
-
java.util.Set.removeAll() with a java.util.List argument.
+Such a call can be slow when the size of the argument is greater or equal than the size of the set,
+and the set is a subclass of java.util.AbstractSet.
+In this case List.contains() is called for every element in the set, which will perform a linear search.
+Example: +
+ public void check(String... ss) {
+ // possible O(n^2) complexity
+ mySet.removeAll(List.of(ss));
+ }
+
+After the quick fix is applied the result looks like: +
+ public void check(String... ss) {
+ // O(n) complexity
+ List.of(ss).forEach(mySet::remove);
+ }
+
New in 2020.3
diff --git a/java/java-impl/src/inspectionDescriptions/SuspiciousNameCombination.html b/java/java-impl/src/inspectionDescriptions/SuspiciousNameCombination.html index 77f9661b5e2a..a0232f20caa9 100644 --- a/java/java-impl/src/inspectionDescriptions/SuspiciousNameCombination.html +++ b/java/java-impl/src/inspectionDescriptions/SuspiciousNameCombination.html @@ -1,15 +1,21 @@ -Reports assignments and function calls where the name of the variable to which -a value is assigned or the function parameter does not seem to match the name of the value assigned to it. -For example: -
+Reports assignments and function calls where the name of the target variable or the function parameter does not match the name of the value assigned to it.
+Example:
+
int x = 0;
- int y = x;
or
+ int y = x;
+
+or
+
int x = 0, y = 0;
- Rectangle rc = new Rectangle(y, x, 20, 20);
-The configuration pane allows to specify the names which should not be used together: the error is reported
+ Rectangle rc = new Rectangle(y, x, 20, 20);
+
+
+The first panel below allows to specify the names which should not be used together: an error is reported if the parameter name or assignment target name contains words from one group and the name of the assigned or passed variable contains words from a different group. +
The second panel below allows to specify methods that should not be checked but do have a potentially suspicious name.
+For example the Integer.compare() parameters are named x and y, but are unrelated to coordinates.
\ No newline at end of file
diff --git a/java/java-impl/src/inspectionDescriptions/TextBlockBackwardMigration.html b/java/java-impl/src/inspectionDescriptions/TextBlockBackwardMigration.html
index 360158064b08..a4b13168fb3f 100644
--- a/java/java-impl/src/inspectionDescriptions/TextBlockBackwardMigration.html
+++ b/java/java-impl/src/inspectionDescriptions/TextBlockBackwardMigration.html
@@ -1,6 +1,7 @@
Example:
@@ -12,7 +13,7 @@ Suggests to replace text block with a regular string literal.
hello();
""");
-can be replaced with
+After the quick fix is applied the result looks like:
Object obj = engine.eval("function hello() {\n" +
" print('\"Hello, world\"');\n" +
diff --git a/java/java-impl/src/inspectionDescriptions/UnnecessaryModuleDependencyInspection.html b/java/java-impl/src/inspectionDescriptions/UnnecessaryModuleDependencyInspection.html
index f3497b239590..646b1c72a06a 100644
--- a/java/java-impl/src/inspectionDescriptions/UnnecessaryModuleDependencyInspection.html
+++ b/java/java-impl/src/inspectionDescriptions/UnnecessaryModuleDependencyInspection.html
@@ -1,7 +1,5 @@
-Lists modules which contain redundant dependencies on other modules.
-These dependencies can be safely removed.
-
+Reports dependencies from one module to another, which are not used and can be safely removed.
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/AssertBetweenInconvertibleTypes.html b/plugins/InspectionGadgets/src/inspectionDescriptions/AssertBetweenInconvertibleTypes.html
index a97fbed51db1..f5cb9fdcb479 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/AssertBetweenInconvertibleTypes.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/AssertBetweenInconvertibleTypes.html
@@ -1,20 +1,15 @@
-Reports calls to assertion methods with “expected” and “actual” arguments of incompatible types. Such calls often indicate that there is a bug.
-The inspection applies to the following methods:
-
- - org.junit.Assert.assertEquals(), org.junit.Assert.assertNotEquals()
- - org.junit.Assert.assertSame(), org.junit.Assert.assertNotSame()
- - org.assertj.core.api.Assert.isEqualTo(), org.assertj.core.api.Assert.isNotEqualTo()
- - org.assertj.core.api.Assert.isSameAs(), org.assertj.core.api.Assert.isNotSameAs()
-
-The assertNotEquals() and isNotEqualTo() methods are also reported,
-however they are highlighted with a weak warning to take into account the case when the equals() contract is tested.
-
-Test samples where the warning is fired:
-assertEquals("1", 1);
-assertNotSame(new int[0], 0);
-// weak warning, because of a possible false positive case
-assertThat(foo).as("user type").isNotEqualTo(bar);
+Reports calls to assertion methods where the “expected” and “actual” arguments are of incompatible types.
+Such calls often indicate that there is a bug in the test.
+This inspection checks the relevant JUnit, TestNG as well as AssertJ methods.
+Examples:
+
+ assertEquals("1", 1);
+ assertNotSame(new int[0], 0);
+
+ // weak warning, may just test the equals() contract
+ assertThat(foo).as("user type").isNotEqualTo(bar);
+
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/CachedNumberConstructorCall.html b/plugins/InspectionGadgets/src/inspectionDescriptions/CachedNumberConstructorCall.html
index 948019ee508a..e5cee5219ebe 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/CachedNumberConstructorCall.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/CachedNumberConstructorCall.html
@@ -1,19 +1,29 @@
-Reports any attempt to instantiate a new Long,
-Integer, Short or
-Byte object from a primitive long,
-integer, short or
-byte
-argument. It may be more efficient to use the static method valueOf()
-here (introduced in Java 5), which will cache objects for values between -128 and
+Reports any attempt to instantiate a new Long,
+Integer, Short or
+Byte object from a primitive long,
+integer, short or
+byte
+argument. It may be more efficient to use the static method valueOf()
+here (introduced in Java 5), which by default will cache objects for values between -128 and
127 inclusive.
+Example:
+
+ Integer i = new Integer(1);
+ Long l = new Long(1L);
+
+After the quick fix is applied the result looks like:
+
+ Integer i = Integer.valueOf(1);
+ Long l = Long.valueOf(1L);
+
This inspection only reports if the language level of the project or module is 5 or higher
-Use the first checkbox below to ignore calls to number constructors with a String argument.
+Use the first checkbox below to ignore calls to number constructors with a String argument.
Use the second checkbox to only report calls to deprecated constructors.
-Long, Integer, Short andByte constructors are deprecated since JDK 9.
+Long, Integer, Short andByte constructors are deprecated since JDK 9.
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/IfCanBeAssertion.html b/plugins/InspectionGadgets/src/inspectionDescriptions/IfCanBeAssertion.html
index cff6e519b6e8..86bef8781b28 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/IfCanBeAssertion.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/IfCanBeAssertion.html
@@ -1,14 +1,21 @@
-Reports if statements (with no else branch) throwing java.lang.Throwable.
+Reports if statements which only throw a java.lang.Throwable from the then branch,
+and don't have an else branch.
+Also reports Guava's Preconditions.checkNotNull().
+These can be replaced with an assert statement, or Objects.requireNonNull() call.
+Example:
+
+ if (x == 2) throw new RuntimeException("fail");
+ if (y == null) throw new AssertionError();
+ Preconditions.checkNotNull(z, "z");
+
+After the quick fix is applied the result looks like:
+
+ assert x != 2 : "fail";
+ Objects.requireNonNull(y);
+ Objects.requireNonNull(z, "z");
+
-
For example:
-if (param == 2) throw new Exception();
-
or guava's:
-Preconditions.checkNotNull(param, message)
-
-Quick fix replaces it with an assert statement.
-Example:
-assert param != 2;
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/InnerClassMayBeStatic.html b/plugins/InspectionGadgets/src/inspectionDescriptions/InnerClassMayBeStatic.html
index 578f60b2d618..43af57c224a9 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/InnerClassMayBeStatic.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/InnerClassMayBeStatic.html
@@ -1,12 +1,34 @@
-Reports any inner classes which may safely be made static.
-An inner class may be static if it doesn't reference its enclosing instance.
+Reports any inner classes which may safely be made static.
+An inner class may be static if it doesn't reference its enclosing instance.
-A static inner class does not keep an implicit reference to its enclosing instance.
+A static inner class does not keep an implicit reference to its enclosing instance.
This prevents a common cause of memory leaks and uses less memory per instance of the class.
-
-
+
Example:
+
+ public class Outer {
+ class Inner { // not static
+ public void foo() {
+ bar("x");
+ }
+ private void bar(String string) {}
+ }
+ }
+
+After the quick fix is applied the result looks like:
+
+ public class Outer {
+ static class Inner {
+ public void foo() {
+ bar("x");
+ }
+
+ private void bar(String string) {}
+ }
+ }
+
+
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/MathRandomCastToInt.html b/plugins/InspectionGadgets/src/inspectionDescriptions/MathRandomCastToInt.html
index 68b0e2b4fdee..3cfd29540f45 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/MathRandomCastToInt.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/MathRandomCastToInt.html
@@ -1,13 +1,21 @@
-Reports any calls to Math.random() which are immediately
-cast to int. Casting a double between 0.0 (inclusive) and
-1.0 (exclusive) will always round down to zero. A Math.random() value
-should first be multiplied with some factor before casting it to an int to
+Reports any calls to Math.random() which are immediately
+cast to int. Casting a double between 0.0 (inclusive) and
+1.0 (exclusive) will always round down to zero. A Math.random() value
+should first be multiplied with some factor before casting it to an int to
get a value between zero (inclusive) and the multiplication factor (exclusive).
-Another possible solution would be to use the nextInt() method of
-java.util.Random.
-
+Another possible solution would be to use the nextInt() method of
+java.util.Random.
+Example:
+
+ int r = (int)Math.random() * 10;
+
+After the quick fix is applied the result looks like:
+
+ int r = (int)(Math.random() * 10);
+
+
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/MethodRefCanBeReplacedWithLambda.html b/plugins/InspectionGadgets/src/inspectionDescriptions/MethodRefCanBeReplacedWithLambda.html
index 7cda3de0c8d2..a093f33764e9 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/MethodRefCanBeReplacedWithLambda.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/MethodRefCanBeReplacedWithLambda.html
@@ -1,8 +1,16 @@
-Reports method references, like MyClass::myMethod and myObject::myMethod.
- The quick fix for the inspection replaces the method reference with an equivalent lambda expression that invokes the method.
-
For example, the method reference System.out::println is replaced with
-s -> System.out.println(s)
+Reports method references, like MyClass::myMethod and myObject::myMethod,
+to allow them to be replaced with an equivalent lambda expression.
+Lambda expressions can be easier to modify than method references.
+By default this inspection does not highlight in the editor, but only provides a quick fix.
+
Example:
+
+ System.out::println
+
+After the quick fix is applied the result looks like:
+
+ s -> System.out.println(s)
+
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ObjectEquality.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ObjectEquality.html
index 3ac67e9a0581..a40f691d679c 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/ObjectEquality.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ObjectEquality.html
@@ -1,13 +1,25 @@
-Reports any use of == or !=to test for Object equality, rather than the equals() method.
-Comparisons to null are not reported.
-Comparison of arrays, Strings or Numbers using == are also not reported, there are separate inspections for these three problems.
+Reports any use of == or !=to test for Object equality, rather than the equals() method.
+Comparisons to null are not reported.
+Comparison of arrays, Strings or Numbers using == are reported by separate inspections.
+Comparing objects using == or != is usually a bug, because it compares objects by identity instead of equality.
+Example:
+
+ if (list1 == list2) {
+ return;
+ }
+
+After the quick fix is applied the result looks like:
+
+ if (Object.equals(list1, list2)) {
+ return;
+ }
+
Use the checkboxes below to indicate whether uses of == between objects of
an enumerated type, final class types without equals implementation or types with private constructors should be reported by this inspection.
-
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/PointlessBooleanExpression.html b/plugins/InspectionGadgets/src/inspectionDescriptions/PointlessBooleanExpression.html
index 61ada9110afe..050415bb6907 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/PointlessBooleanExpression.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/PointlessBooleanExpression.html
@@ -1,11 +1,21 @@
Reports pointless or pointlessly
-complicated boolean expressions. Such expressions include anding with true,
-oring with false,
-equality comparison with a boolean literal, or negation of a boolean literal. Such expressions may be the result of automated refactorings
-not completely followed through to completion, and in any case are unlikely to be what the developer
-intended to do.
+complicated boolean expressions. Such expressions include &&-ing with true,
+||-ing with false,
+equality comparison with a boolean literal, or negation of a boolean literal. Such expressions can be simplified.
+Example:
+
+ boolean a = !(x && false);
+ boolean b = false || x;
+ boolean c = x != true;
+
+After the quick fix is applied the result looks like:
+
+ boolean a = true;
+ boolean b = x;
+ boolean c = !x;
+
Use the checkbox below to ignore named constants when determining if an expression is pointless.
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/SuspiciousInvocationHandlerImplementation.html b/plugins/InspectionGadgets/src/inspectionDescriptions/SuspiciousInvocationHandlerImplementation.html
index 7fd7bce192e5..c12773b0ed3b 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/SuspiciousInvocationHandlerImplementation.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/SuspiciousInvocationHandlerImplementation.html
@@ -1,22 +1,23 @@
-Reports the implementations of InvocationHandler.invoke that do not proxy standard
+Reports the implementations of InvocationHandler that do not proxy standard
Object methods like hashCode(), equals(), and toString().
Failing to handle these methods might cause unexpected problems upon calling them on a proxy instance.
-
- Example:
-
+Example:
- Runnable myProxy = (Runnable) Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(),
- new Class[] {Runnable.class}, (proxy, method, params) -> {
- System.out.println("Hello World!");
- return null;
- });
+ InvocationHandler myHandler = (proxy, method, params) -> {
+ System.out.println("Hello World!");
+ return null;
+ };
+ Runnable myProxy = (Runnable) Proxy.newProxyInstance(
+ Thread.currentThread().getContextClassLoader(),
+ new Class[] {Runnable.class}, myHandler
+ );
- The code snippet above is designed to only proxy the Runnable.run() method. However, the calls to Object’s
- virtual methods are dispatched as well, which may lead to problems like NullPointerException on trying
- to add myProxy to a HashSet.
+ The code snippet above is designed to only proxy the Runnable.run() method.
+ However, calls to any Object methods, like hashCode(), are proxied as well.
+ This can lead to problems like a NullPointerException when adding myProxy to a HashSet for example.
New in 2020.2
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/UnconstructableTestCase.html b/plugins/InspectionGadgets/src/inspectionDescriptions/UnconstructableTestCase.html
index 85faeda22492..db7f4a458773 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/UnconstructableTestCase.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/UnconstructableTestCase.html
@@ -1,9 +1,20 @@
-Reports non-abstract JUnit test cases which do not
+Reports non-abstract JUnit test cases which do not
expose a public no-arg constructor or a public constructor which takes a single string
-as an argument. Such test cases will be unrunnable by most JUnit test runners, including
-IDEA's.
+as an argument. Such test cases will not be runnable by most JUnit test runners.
+Example:
+
+public class MyTest {
+
+ private MyTest() {} // no-arg constructor is private
+
+ @Test
+ public void testSomething() {
+ assertEquals(1, 1);
+ }
+}
+
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryReturn.html b/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryReturn.html
index b7401081d90f..82344ad95fc7 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryReturn.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryReturn.html
@@ -1,14 +1,24 @@
-Reports on any unnecessary return statements at the end of constructors and methods returning
-void. These may be safely removed.
-
-At present, this inspection is disabled in JSP files.
+Reports return statements at the end of constructors and methods returning
+void. These are unnecessary and may be safely removed.
+
This inspection does not report in JSP files.
+
Example:
+
+ void message() {
+ System.out.println("Hello World");
+ return;
+ }
+
+After the quick fix is applied the result looks like:
+
+ void message() {
+ System.out.println("Hello World");
+ }
+
-Use the checkbox below to let this inspection ignore return statements in the then branch of if statements
-which also have an else branch.
-
-
+Use the checkbox below to ignore return statements in the then branch of if statements
+which also have an else branch.
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryStringEscape.html b/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryStringEscape.html
index e976c77d3275..15c46a727f9d 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryStringEscape.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryStringEscape.html
@@ -1,8 +1,21 @@
-Reports unnecessarily escaped characters in String and optionally char literals.
-For example \' in a String literal or \n in a Java 13 Preview text block.
-The escaped tab character \t is not reported.
+Reports unnecessarily escaped characters in String and optionally char literals.
+The escaped tab character \t is not reported, because it would otherwise be invisible.
+Examples:
+
+ String s = "\'Scare\' quotes";
+ String t = """
+ All you need is\n\tLove\n""";
+
+After the quick fix is applied the result looks like:
+
+ String s = "'Scare' quotes";
+ String t = """
+ All you need is
+ \tLove
+ """;
+
New in 2019.3
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/UnusedLabel.html b/plugins/InspectionGadgets/src/inspectionDescriptions/UnusedLabel.html
index 189c5a21619f..34bfb8c63656 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/UnusedLabel.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/UnusedLabel.html
@@ -1,8 +1,22 @@
-Reports unused code labels.
+Reports labels which are not the target of any break or continue statements.
+For example:
+
+ label: for (int i = 0; i < 10; i++) {
+ if (i == 3) {
+ break;
+ }
+ }
+
+After the quick fix is applied the result looks like:
+
+ for (int i = 0; i < 10; i++) {
+ if (i == 3) {
+ break;
+ }
+ }
+
-
-
\ No newline at end of file