diff --git a/java/java-impl/src/inspectionDescriptions/AccessStaticViaInstance.html b/java/java-impl/src/inspectionDescriptions/AccessStaticViaInstance.html index b904e91adbbf..d5ab6a10faa3 100644 --- a/java/java-impl/src/inspectionDescriptions/AccessStaticViaInstance.html +++ b/java/java-impl/src/inspectionDescriptions/AccessStaticViaInstance.html @@ -1,16 +1,19 @@ -Shows references to static methods and fields -via a class instance rather than a class itself.
-
-Example:
-String s = String.valueOf(0); // correct: static method qualified with class name
-String s1 = s.valueOf(0); // wrong: static method qualified with class instance
-
-While allowed by Java Language Specification, -referring to static members via instance variables makes the code confusing -as the reader may think that the result of the method depends on the instance.
-
-Quick fix: replaces the instance variable with the class name. +

Shows references to static methods and fields via a class instance rather than a class itself. While + allowed by Java Language Specification, referring to static members via instance variables makes the + code confusing as the reader may think that the result of the method depends on the instance.

+

Quick-fix replaces the instance variable with the class name.

+

Example:

+
+  String s1 = s.valueOf(0);
+
+

After the quick-fix is applied the result looks like:

+
+  String s = String.valueOf(0);
+
+ +

+ \ No newline at end of file diff --git a/java/java-impl/src/inspectionDescriptions/JavaReflectionInvocation.html b/java/java-impl/src/inspectionDescriptions/JavaReflectionInvocation.html index 1a720645362e..d7a4a43b6531 100644 --- a/java/java-impl/src/inspectionDescriptions/JavaReflectionInvocation.html +++ b/java/java-impl/src/inspectionDescriptions/JavaReflectionInvocation.html @@ -1,15 +1,14 @@ -The inspection checks that the arguments provided to Method.invoke() and Constructor.newInstance() -match the signature specified in Class.getMethod() and Class.getConstructor() - +Checks that the arguments provided to Method.invoke() and Constructor.newInstance() +match the signature specified in Class.getMethod() and Class.getConstructor()

Example:

-

+
   Method m = myObj.getClass().getMethod("myMethod", int.class);
   // the argument should be an int value
   m.invoke(myObj, "abc");
-
- +
+

New in 2017.2

\ No newline at end of file diff --git a/java/java-impl/src/inspectionDescriptions/ManualMinMaxCalculation.html b/java/java-impl/src/inspectionDescriptions/ManualMinMaxCalculation.html index 027f28b3eb28..d96c4c65f8a9 100644 --- a/java/java-impl/src/inspectionDescriptions/ManualMinMaxCalculation.html +++ b/java/java-impl/src/inspectionDescriptions/ManualMinMaxCalculation.html @@ -4,17 +4,23 @@ Reports cases where the minimum or the maximum of two numbers can be calculated Math.max() or Math.min() instead of doing it manually.

Example:

-  public int getMinWeight(int typeDiffWeight, int rawTypeDiffWeight) {
-    return (rawTypeDiffWeight < typeDiffWeight ? rawTypeDiffWeight : typeDiffWeight);
+  public int min(int a, int b) {
+    return b < a ? b : a;
   }
 
-

Will be replaced with:

+

After the fix is applied, the result will be like this:

-  public int getMinWeight(int typeDiffWeight, int rawTypeDiffWeight) {
-    return Math.min(rawTypeDiffWeight, typeDiffWeight);
+  public int min(int a, int b) {
+    return Math.min(a, b);
   }
 
+

+ Use the checkbox below to disable this inspection for double and float + This might be useful because quick-fix may slightly break semantics for float/ + double when handling NaN. Thought in most cases it will actually fix + the subtle bug when users did not care about NaN. +

New in 2019.2

\ No newline at end of file diff --git a/java/java-impl/src/inspectionDescriptions/OptionalAssignedToNull.html b/java/java-impl/src/inspectionDescriptions/OptionalAssignedToNull.html index 4dc0effdd3e5..35a68cd50c0c 100644 --- a/java/java-impl/src/inspectionDescriptions/OptionalAssignedToNull.html +++ b/java/java-impl/src/inspectionDescriptions/OptionalAssignedToNull.html @@ -1,13 +1,25 @@ -This inspection warns when null is assigned to Optional variable or returned from method returning - Optional. It's recommended to use Optional.empty() (or Optional.absent() for Guava) to denote - an empty value. -

- Use checkbox below to report also comparisons like optional == null. While in rare cases (e.g. lazily initialized optional field) - this might be correct, usually optional variable is never null, and probably optional.isPresent() was intended. -

+Reports null assigned to Optional variable or returned from method returning Optional. +It's recommended to use Optional.empty() (or Optional.absent() for Guava) to denote an empty value. +

Example:

+
+  Optional<Integer> foo(boolean flag) {
+    return flag ? Optional.of(42) : null;
+  }
+
+

After the fix is applied, the result will be like this:

+
+  Optional<Integer> foo(boolean flag) {
+    return flag ? Optional.of(42) : Optional.empty();
+  }
+
+

+ Use the checkbox below to report also comparisons like optional == null. While in rare cases (e.g. lazily initialized + optional field) this might be correct, usually optional variable is never null, and probably optional.isPresent() was + intended. +

This inspection only reports if the language level of the project or module is 8 or higher

New in 2017.2 diff --git a/java/java-impl/src/inspectionDescriptions/OptionalToIf.html b/java/java-impl/src/inspectionDescriptions/OptionalToIf.html index a872297f2ad8..5d77e18b0258 100644 --- a/java/java-impl/src/inspectionDescriptions/OptionalToIf.html +++ b/java/java-impl/src/inspectionDescriptions/OptionalToIf.html @@ -1,23 +1,23 @@ -Reports Optional call chains which could be replaced with a sequence of 'if' statements. - -

Example: -


+Reports Optional call chains which could be replaced with a sequence of if statements.
+

Example:

+
   return Optional.ofNullable(name)
     .map(this::extractInitials)
     .map(initials -> initials.toUpperCase(Locale.ENGLISH))
     .orElseGet(this::getDefault);
-
-

can be replaced with

-

+
+

After the fix is applied, the result will be like this:

+
   if (name != null) {
     String initials = extractInitials(name);
     if (initials != null) return initials.toUpperCase(Locale.ENGLISH);
   }
   return getDefault();
-
-

This inspection only reports if the configured language level is 8 or higher.

+
+ +

This inspection only reports if the language level of the project or module is 8 or higher

New in 2020.2

\ No newline at end of file diff --git a/java/java-impl/src/inspectionDescriptions/RedundantExplicitVariableType.html b/java/java-impl/src/inspectionDescriptions/RedundantExplicitVariableType.html index 8d41211d13e5..ca9f834d0fc4 100644 --- a/java/java-impl/src/inspectionDescriptions/RedundantExplicitVariableType.html +++ b/java/java-impl/src/inspectionDescriptions/RedundantExplicitVariableType.html @@ -1,5 +1,20 @@ -Reports redundant local variable types. Theses types can be inferred from the context and thus be replaced with var. +Reports redundant local variable types. Theses types can be inferred from the context and thus be replaced with var. +

Example:

+
+  void test(InputStream s) {
+    try (InputStream in = s) {}
+  }
+
+

After the fix is applied, the result will be like this:

+
+  void test(InputStream s) {
+    try (var in = s) {}
+  }
+
+ +

+ \ No newline at end of file diff --git a/java/java-impl/src/inspectionDescriptions/RedundantRecordConstructor.html b/java/java-impl/src/inspectionDescriptions/RedundantRecordConstructor.html index e5027fac3042..5e34f721f8ef 100644 --- a/java/java-impl/src/inspectionDescriptions/RedundantRecordConstructor.html +++ b/java/java-impl/src/inspectionDescriptions/RedundantRecordConstructor.html @@ -1,7 +1,8 @@ -Reports redundant constructors declared inside Java records. Examples: -


+Reports redundant constructors declared inside Java records.
+

Examples:

+
   record Point(int x, int y) {
     public Point {} // could be removed
   }
@@ -21,7 +22,7 @@ Reports redundant constructors declared inside Java records. Examples:
       this.to = to;
     }
   }
-
+

This inspection only reports if the configured language level is 14 Preview or 15 Preview.

New in 2020.1

diff --git a/java/java-impl/src/inspectionDescriptions/RedundantUnmodifiable.html b/java/java-impl/src/inspectionDescriptions/RedundantUnmodifiable.html index 4ba18a182c21..a601eee26bce 100644 --- a/java/java-impl/src/inspectionDescriptions/RedundantUnmodifiable.html +++ b/java/java-impl/src/inspectionDescriptions/RedundantUnmodifiable.html @@ -1,13 +1,17 @@ -Reports redundant calls to unmodifiable collection wrappers within the Collections class. -If the argument that is passed to an unmodifiable collection wrapper is already immutable, such wrapping becomes pointless. +Reports redundant calls to unmodifiable collection wrappers within the +Collections class. If the argument that is passed to an unmodifiable +collection wrapper is already immutable, such wrapping becomes pointless.

Example:

-Collections.unmodifiableList(Collections.singletonList("abc"));
-
+  Collections.unmodifiableList(Collections.singletonList("abc"));
 
-In order to detect the methods that return unmodifiable collections, the inspection uses the org.jetbrains.annotations.Unmodifiable and org.jetbrains.annotations.UnmodifiableView annotations. Use them to extend the inspection to your own unmodifiable collection wrappers. +In order to detect the methods that return unmodifiable collections, the +inspection uses the org.jetbrains.annotations.Unmodifiable +and org.jetbrains.annotations.UnmodifiableView annotations. +Use them to extend the inspection to your own unmodifiable collection +wrappers.

New in 2020.3

diff --git a/java/java-impl/src/inspectionDescriptions/ReplaceNullCheck.html b/java/java-impl/src/inspectionDescriptions/ReplaceNullCheck.html index 4ed0614963fd..e1defe8ab800 100644 --- a/java/java-impl/src/inspectionDescriptions/ReplaceNullCheck.html +++ b/java/java-impl/src/inspectionDescriptions/ReplaceNullCheck.html @@ -1,20 +1,23 @@ -This inspection suggests to replace null check with Objects/Stream static method. - -Example: -

+Suggests replacing null check with Objects/Stream static method.
+

Example:

+
 if (message == null) {
   application.messageStorage().save(new EmptyMessage());
 } else {
   application.messageStorage().save(message);
 }
-
-

can be replaced with

-

+
+

After the quick-fix is applied the result looks like:

+
   application.messageStorage()
     .save(Objects.requireNonNullElseGet(message, () -> new EmptyMessage()));
-
+
+ +

+ Use the checkbox below to not warn if length of replacement bigger than original. +

New in 2017.3

\ No newline at end of file diff --git a/java/java-impl/src/inspectionDescriptions/Since15.html b/java/java-impl/src/inspectionDescriptions/Since15.html index b17d71f068de..a4766097b39d 100644 --- a/java/java-impl/src/inspectionDescriptions/Since15.html +++ b/java/java-impl/src/inspectionDescriptions/Since15.html @@ -1,7 +1,14 @@ -This inspection finds all usages of methods that have @since tag in -their documentation.

-This may be useful when development is performed under newer SDK version as the target platform for production.

+Reports usages of API which isn't available at the configured language level. API availability is defined +by the version specified in the @since tag in its documentation. This may be useful because +language level can differ from your project SDK and it is possible that there is no such API in JDK, on +which the code will be run. + +

+ Use the radio buttons below to forbid API usages respecting to project language level settings or custom + language level. +

+

New in 2018.2

diff --git a/java/java-impl/src/inspectionDescriptions/UseBulkOperation.html b/java/java-impl/src/inspectionDescriptions/UseBulkOperation.html index 1506af5521ba..03519a25302b 100644 --- a/java/java-impl/src/inspectionDescriptions/UseBulkOperation.html +++ b/java/java-impl/src/inspectionDescriptions/UseBulkOperation.html @@ -1,13 +1,29 @@ -Warns when calling some method in a loop (e.g. collection.add(x)) could be replaced when calling a bulk method -(e.g. collection.addAll(listOfX). -

- If checkbox "Use Arrays.asList() to wrap arrays" is checked, the inspection will warn even if the original code iterates over - an array while bulk method requires a Collection. In this case the quick-fix action will automatically - wrap an array with Arrays.asList() call. -

+Warns when calling some method in a loop (e.g. collection.add(x)) could be +replaced when calling a bulk method (e.g. collection.addAll(listOfX). +

Example:

+
+  void test(Collection<Integer> numbers) {
+    List<Integer> result = new ArrayList<>();
+    for (Integer i : numbers) {
+      result.add(i);
+    }
+  }
+
+

After the fix is applied, the result will be like this:

+
+  void test(Collection<Integer> numbers) {
+    List<Integer> result = new ArrayList<>();
+    result.addAll(numbers);
+  }
+
+

+ Use the checkbox below to warn even if the original code iterates over an array while + bulk method requires a Collection. In this case the quick-fix action will + automatically wrap an array with Arrays.asList() call. +

New in 2017.1 \ No newline at end of file diff --git a/java/openapi/resources/messages/JavaBundle.properties b/java/openapi/resources/messages/JavaBundle.properties index e07b60e1ed57..ae3c80da45ea 100644 --- a/java/openapi/resources/messages/JavaBundle.properties +++ b/java/openapi/resources/messages/JavaBundle.properties @@ -1233,7 +1233,7 @@ inspection.empty.method.display.name=Empty method inspection.unused.assignment.display.name=Unused assignment inspection.unchecked.warning.display.name=Unchecked warning inspection.convert.2.streamapi.display.name=Loop can be collapsed with Stream API -inspection.optional.to.if.display.name=Optional can be replaced with sequence of if statements +inspection.optional.to.if.display.name='Optional' can be replaced with sequence of 'if' statements inspection.stream.to.loop.display.name=Stream API call chain can be replaced with loop inspection.anonymous.2.method.ref.display.name=Anonymous type can be replaced with method reference inspection.convert.2.method.ref.display.name=Lambda can be replaced with method reference diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/resources/messages/InspectionGadgetsBundle.properties b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/resources/messages/InspectionGadgetsBundle.properties index 47728c4f4e21..9796eb1b3247 100644 --- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/resources/messages/InspectionGadgetsBundle.properties +++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/resources/messages/InspectionGadgetsBundle.properties @@ -493,7 +493,7 @@ readresolve.writereplace.protected.problem.descriptor=#ref() not de missing.serial.annotation.display.name=@Serial annotation could be used missing.serial.annotation.on.field.problem.descriptor=#ref can be annotated with @Serial annotation missing.serial.annotation.on.method.problem.descriptor=#ref() can be annotated with @Serial annotation -serial.annotation.used.on.wrong.member.display.name=@Serial annotation used on wrong member +serial.annotation.used.on.wrong.member.display.name='@Serial' annotation used on wrong member serial.annotation.used.on.wrong.member.problem.descriptor=Annotated member is not a part of the serialization mechanism serializable.record.contains.ignored.members.display.name='record' contains ignored members serializable.record.contains.ignored.field.problem.descriptor=#ref will be ignored during record serialization @@ -2127,7 +2127,7 @@ try.statement.with.multiple.resources.name='try' statement with multiple resourc try.statement.with.multiple.resources.quickfix=Split 'try' statement with multiple resources multi.catch.can.be.split.name=Multi-catch can be split into separate catch blocks multi.catch.can.be.split.quickfix=Split multi-catch into separate 'catch' blocks -assertion.can.be.if.name=Assertion can be replaced with if statement +assertion.can.be.if.name=Assertion can be replaced with 'if' statement assert.can.be.if.quickfix=Replace 'assert' with 'if' statement if.can.be.assertion.name=Statement can be replaced with 'assert' or 'Objects.requireNonNull' if.can.be.assertion.replace.with.assertion.quickfix=Replace statement with 'assert' statement @@ -2259,7 +2259,7 @@ inspection.constant.expression.fix.family.name=Compute constant value inspection.redundant.compare.call.display.name=Redundant 'compare()' method call inspection.redundant.compare.call.fix.name=Inline 'compare()' call -inspection.simplifiable.if.statement.display.name=If statement can be replaced with ?:, \\&\\&, ||, ==, or != expression +inspection.simplifiable.if.statement.display.name='if' statement can be replaced with conditional or boolean expression inspection.simplifiable.if.statement.message=If statement can be replaced with ''{0}'' inspection.simplifiable.if.statement.option.dont.warn.on.ternary=Don't suggest '?:' operator inspection.simplifiable.if.statement.fix.name=Replace ''if else'' with ''{0}'' diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/AssertionCanBeIf.html b/plugins/InspectionGadgets/src/inspectionDescriptions/AssertionCanBeIf.html index af62ac1b24eb..c1d28186c36a 100644 --- a/plugins/InspectionGadgets/src/inspectionDescriptions/AssertionCanBeIf.html +++ b/plugins/InspectionGadgets/src/inspectionDescriptions/AssertionCanBeIf.html @@ -1,11 +1,17 @@ -Reports assert statements. -For example,
-assert param != null; -

Quick fix replaces it with -if statement throwing an java.lang.AssertionError. -

Example:
-if (param == null) throw new AssertionError(); +Reports assert statements and suggests replacing them with +if statement throwing an java.lang.AssertionError. +

Example:

+
+  assert param != null;
+
+

After the quick-fix is applied the result looks like:

+
+  if (param == null) throw new AssertionError();
+
+ +

+ - + \ No newline at end of file diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/EqualsWithItself.html b/plugins/InspectionGadgets/src/inspectionDescriptions/EqualsWithItself.html index 5a3c9775862d..d53f4da96c1f 100644 --- a/plugins/InspectionGadgets/src/inspectionDescriptions/EqualsWithItself.html +++ b/plugins/InspectionGadgets/src/inspectionDescriptions/EqualsWithItself.html @@ -1,10 +1,22 @@ -Reports calls to equals() or compareTo() were an object is compared for equality with itself. -This means the argument and the qualifier to the call are identical, and it will always return true for equals() -or always 0 for compareTo(). -Also reports call to static methods Objects.equals(), Objects.deepEquals(), Arrays.equals(), Comparator.compare -and similar methods with two identical arguments. +Reports calls to equals() or compareTo() were an object is compared for equality +with itself. This means the argument and the qualifier to the call are identical, and it will always return +true for equals() or always 0 for compareTo(). Also +reports call to static methods Objects.equals(), Objects.deepEquals(), +Arrays.equals(), Comparator.compare and similar methods with two identical arguments. +

Example:

+
+  class Foo {
+    boolean foo(Object o) {
+        return o.equals(o); // bad
+    }
+
+    boolean bar(String[] ss) {
+        return Arrays.equals(ss, ss); // bad
+    }
+}
+

diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ExternalizableWithoutPublicNoArgConstructor.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ExternalizableWithoutPublicNoArgConstructor.html index e30510c244b6..ded6a6e1a943 100644 --- a/plugins/InspectionGadgets/src/inspectionDescriptions/ExternalizableWithoutPublicNoArgConstructor.html +++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ExternalizableWithoutPublicNoArgConstructor.html @@ -1,8 +1,10 @@ -Reports a Externalizable classes without a public no-argument constructor. -When an Externalizable object is reconstructed, an instance is created using the public no-arg constructor before the readExternal -method called. If a public no-arg constructor is not present a java.io.InvalidClassException will be thrown at runtime. +Reports a Externalizable classes without a public no-argument constructor. +When an Externalizable object is reconstructed, an instance is created using the public +no-arg constructor before the readExternal method called. If a public +no-arg constructor is not present a java.io.InvalidClassException will be +thrown at runtime.

diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/FillPermitsList.html b/plugins/InspectionGadgets/src/inspectionDescriptions/FillPermitsList.html index 284fe334d394..426b78ca019b 100644 --- a/plugins/InspectionGadgets/src/inspectionDescriptions/FillPermitsList.html +++ b/plugins/InspectionGadgets/src/inspectionDescriptions/FillPermitsList.html @@ -1,6 +1,16 @@ -Reports sealed classes whose permits clause doesn’t contain some of the subclasses from the same file. +Reports sealed classes whose permits clause doesn't contain some of the subclasses from the same file. +

Example:

+
+  sealed class A {}
+  final class B extends A {}
+
+

After the fix is applied, the result will be like this:

+
+  sealed class A permits B {}
+  final class B extends A {}
+

New in 2020.3

diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/JUnit5Platform.html b/plugins/InspectionGadgets/src/inspectionDescriptions/JUnit5Platform.html deleted file mode 100644 index 59741fb37c6d..000000000000 --- a/plugins/InspectionGadgets/src/inspectionDescriptions/JUnit5Platform.html +++ /dev/null @@ -1,10 +0,0 @@ - - -Reports classes annotated with @RunWith(JUnitPlatform.class) which provide no test methods. These classes won't start tests because -org.junit.vintage.engine.discovery.DefensiveAllDefaultPossibilitiesBuilder.DefensiveAnnotatedBuilder prevents recursion and -org.junit.vintage.engine.discovery.DefensiveAllDefaultPossibilitiesBuilder.DefensiveJUnit4Builder expects test methods - -

- New in 2017.2 - - \ No newline at end of file diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/LengthOneStringsInConcatenation.html b/plugins/InspectionGadgets/src/inspectionDescriptions/LengthOneStringsInConcatenation.html index 9a82ac031b17..a3617c031e75 100644 --- a/plugins/InspectionGadgets/src/inspectionDescriptions/LengthOneStringsInConcatenation.html +++ b/plugins/InspectionGadgets/src/inspectionDescriptions/LengthOneStringsInConcatenation.html @@ -1,7 +1,15 @@ -Reports String literals of length one being used in concatenation. -These literals may be replaced by equivalent character literals, gaining some performance enhancement. +Reports string literals of length one being used in concatenation. These literals +may be replaced by equivalent character literals, gaining some performance enhancement. +

Example:

+
+  String hello = hell + "o";
+
+

After the quick-fix is applied the result looks like:

+
+  String hello = hell + 'o';
+

diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/NewObjectEquality.html b/plugins/InspectionGadgets/src/inspectionDescriptions/NewObjectEquality.html index 3d9d766b9886..2e8fdd88f006 100644 --- a/plugins/InspectionGadgets/src/inspectionDescriptions/NewObjectEquality.html +++ b/plugins/InspectionGadgets/src/inspectionDescriptions/NewObjectEquality.html @@ -1,9 +1,21 @@ -Reports cases when == or != is applied to a newly allocated object -instead of an equals() call. Newly allocated objects cannot be equal to other objects, -thus the compared objects are always unequal. The inspection also may detect -newly created objects returned from simple methods. +Reports cases when == or != is applied to a newly allocated object +instead of an equals() call. Newly allocated objects cannot be equal to other +objects, thus the compared objects are always unequal. The inspection also may detect newly +created objects returned from simple methods. +

Example:

+
+  void test(Object obj) {
+    if (new Object() == obj) {...}
+  }
+
+

After the fix is applied, the result will be like this:

+
+  void test(Object obj) {
+    if (new Object().equals(obj)) {...}
+  }
+

New in 2018.3 diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/SerialAnnotationUsedOnWrongMember.html b/plugins/InspectionGadgets/src/inspectionDescriptions/SerialAnnotationUsedOnWrongMember.html index d045ea7ee481..8970ca609533 100644 --- a/plugins/InspectionGadgets/src/inspectionDescriptions/SerialAnnotationUsedOnWrongMember.html +++ b/plugins/InspectionGadgets/src/inspectionDescriptions/SerialAnnotationUsedOnWrongMember.html @@ -1,26 +1,26 @@ -Reports methods and fields in Serializable and Externalizable classes that are not suitable to be annotated with the java.io.Serial annotation. -

-Examples:
-

+Reports methods and fields in Serializable and Externalizable
+classes that are not suitable to be annotated with the java.io.Serial annotation.
+

Examples:

+
 class Test implements Serializable {
-  @Serial //The annotated field is not a part of serialization mechanism as it's not final
+  @Serial // The annotated field is not a part of serialization mechanism as it's not final
   private static long serialVersionUID = 7874493593505141603L;
 
-  @Serial //The annotated method is not a part of the serialization mechanism as it's not private
+  @Serial // The annotated method is not a part of the serialization mechanism as it's not private
   void writeObject(ObjectOutputStream out) throws IOException {
   }
 }
-
-
+
+
 class Test implements Externalizable {
-  @Serial //The annotated method is not a part of the serialization mechanism as it's inside Externalizable class
+  @Serial // The annotated method is not a part of the serialization mechanism as it's inside Externalizable class
   private void writeObject(ObjectOutputStream out) throws IOException {
   }
 }
-
-

To get more information about all valid cases, refer the documentation for java.io.Serial.

+
+

To get more information about all valid cases, refer the documentation for java.io.Serial.

This inspection only reports if the language level of the project or module is 14 or higher.

New in 2020.3

diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/SimplifiableIfStatement.html b/plugins/InspectionGadgets/src/inspectionDescriptions/SimplifiableIfStatement.html index b9012447b2c0..3ec768111c4c 100644 --- a/plugins/InspectionGadgets/src/inspectionDescriptions/SimplifiableIfStatement.html +++ b/plugins/InspectionGadgets/src/inspectionDescriptions/SimplifiableIfStatement.html @@ -1,19 +1,26 @@ -Reports 'if' statements which can be replaced with condition using '&&', '||' or '?:' operator. -The result is usually shorter, but not always more clear, so it's not advised to apply it everywhere. -Also this change may reduce compiled bytecode size which could be useful in some environments like Java ME. +Reports if statements that can be replaced with condition using &&, ||, +==, != or ?: operator. The result is usually shorter, but not always more +clear, so it's not advised to apply it everywhere. Also this change may reduce compiled bytecode size which could +be useful in some environments like Java ME. +

Example:

+
+  if (condition) return true; else return foo;
+
+

After the fix is applied, the result will be like this:

+
+  return condition || foo;
+
+

- Example: if (condition) return true; else return foo; could be replaced with - return condition || foo; -

- -

- Use the first checkbox to skip warning when '?:' operator is suggested. In this case only '&&' and '||' suggestions - will be highlighted. The fix action to replace with '?:' will still be available in the editor. + Use the first checkbox below to skip warning when ?: operator is suggested. In this case only + &&, ||, == and != suggestions will be highlighted. The + fix action to replace with ?:will still be available in the editor.

- Use the second checkbox to skip warning on 'if-else' chains. The fix action will still be available in the editor. + Use the second checkbox below to skip warning on if-else chains. The fix action will still be + available in the editor.

New in 2018.2

diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/TryFinallyCanBeTryWithResources.html b/plugins/InspectionGadgets/src/inspectionDescriptions/TryFinallyCanBeTryWithResources.html index c250857a33fc..12e6e6245dc6 100644 --- a/plugins/InspectionGadgets/src/inspectionDescriptions/TryFinallyCanBeTryWithResources.html +++ b/plugins/InspectionGadgets/src/inspectionDescriptions/TryFinallyCanBeTryWithResources.html @@ -1,8 +1,23 @@ -Reports try finally statements which can use Java 7 -Automatic Resource Management. A quickfix is available to convert the try finally -statement into a try with resources statement. +Reports try-finally statements which can use Java 7 Automatic Resource +Management. A quick-fix is available to convert the try-finally statement +into a try-with-resources statement. +

Example:

+
+  PrintStream printStream = new PrintStream(fileName);
+  try {
+    printStream.print(true);
+  } finally {
+    printStream.close();
+  }
+
+

A quick-fix is provided to pass the cause to constructor:

+
+  try (PrintStream printStream = new PrintStream(fileName)) {
+    printStream.print(true);
+  }
+

This inspection only reports if the language level of the project or module is 7 or higher

diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryTemporaryOnConversionFromString.html b/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryTemporaryOnConversionFromString.html index f6a80ed24593..49753b359874 100644 --- a/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryTemporaryOnConversionFromString.html +++ b/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryTemporaryOnConversionFromString.html @@ -2,15 +2,14 @@ Reports unnecessary creation of temporary objects when converting from Strings to primitive types. -

-For example: -

-    new Integer("3").intValue()
-
-will be reported, and can be automatically converted to: -
-    Integer.valueOf("3")
-
+

Example:

+
+  new Integer("3").intValue()
+
+

After the quick-fix is applied the result looks like:

+
+  Integer.valueOf("3")
+