diff --git a/.ci/files/all-java.xml b/.ci/files/all-java.xml index b4d887b09b..1297187f73 100644 --- a/.ci/files/all-java.xml +++ b/.ci/files/all-java.xml @@ -106,7 +106,7 @@ - + diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/UnnecessaryConversionRule.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/UnnecessaryBoxingRule.java similarity index 98% rename from pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/UnnecessaryConversionRule.java rename to pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/UnnecessaryBoxingRule.java index 36f3cf3381..3ac1554cac 100644 --- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/UnnecessaryConversionRule.java +++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/UnnecessaryBoxingRule.java @@ -24,7 +24,7 @@ import net.sourceforge.pmd.lang.java.types.ast.ExprContext; /** * */ -public class UnnecessaryConversionRule extends AbstractJavaRulechainRule { +public class UnnecessaryBoxingRule extends AbstractJavaRulechainRule { private static final Set INTERESTING_NAMES = setOf( "valueOf", @@ -38,7 +38,7 @@ public class UnnecessaryConversionRule extends AbstractJavaRulechainRule { "doubleValue" ); - public UnnecessaryConversionRule() { + public UnnecessaryBoxingRule() { super(ASTMethodCall.class, ASTConstructorCall.class); } diff --git a/pmd-java/src/main/resources/category/java/codestyle.xml b/pmd-java/src/main/resources/category/java/codestyle.xml index d7a26f2042..55a830efb6 100644 --- a/pmd-java/src/main/resources/category/java/codestyle.xml +++ b/pmd-java/src/main/resources/category/java/codestyle.xml @@ -1477,6 +1477,37 @@ public class Foo { + + + Reports explicit conversions that may safely be removed, either because + they would implicitly take place (eg widening a `byte` to an `int`), or + because they're semantically a noop (eg unboxing a value to rebox it immediately). + + This handles widening conversion between primitives, boxing and unboxing + conversions (which since Java 5 are inserted by the compiler implicitly). + Unnecessary casts that command a conversion are reported by {% rule UnnecessaryCast %} + instead. + + 3 + + + + - - - Reports explicit conversions that may safely be removed, either because - they would implicitly take place (eg widening a `byte` to an `int`), or - because they're semantically a noop (eg unboxing a value to rebox it immediately). - - This handles widening conversion between primitives, boxing and unboxing - conversions (which since Java 5 are inserted by the compiler implicitly). - Unnecessary casts that command a conversion are reported by {% rule UnnecessaryCast %} - instead. - - 3 - - - -