Rename rule
This commit is contained in:
5 files changed
+35
-34
No files matched your search
@@ -106,7 +106,7 @@
|
||||
<rule ref="category/java/codestyle.xml/UnnecessaryAnnotationValueElement"/>
|
||||
<rule ref="category/java/codestyle.xml/UnnecessaryCast"/>
|
||||
<rule ref="category/java/codestyle.xml/UnnecessaryConstructor"/>
|
||||
<rule ref="category/java/codestyle.xml/UnnecessaryConversion"/>
|
||||
<rule ref="category/java/codestyle.xml/UnnecessaryBoxing"/>
|
||||
<rule ref="category/java/codestyle.xml/UnnecessaryFullyQualifiedName"/>
|
||||
<!-- <rule ref="category/java/codestyle.xml/UnnecessaryImport"/> -->
|
||||
<rule ref="category/java/codestyle.xml/UnnecessaryLocalBeforeReturn"/>
|
||||
|
||||
+2
-2
@@ -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<String> INTERESTING_NAMES = setOf(
|
||||
"valueOf",
|
||||
@@ -38,7 +38,7 @@ public class UnnecessaryConversionRule extends AbstractJavaRulechainRule {
|
||||
"doubleValue"
|
||||
);
|
||||
|
||||
public UnnecessaryConversionRule() {
|
||||
public UnnecessaryBoxingRule() {
|
||||
super(ASTMethodCall.class, ASTConstructorCall.class);
|
||||
}
|
||||
|
||||
@@ -1477,6 +1477,37 @@ public class Foo {
|
||||
</example>
|
||||
</rule>
|
||||
|
||||
<rule name="UnnecessaryBoxing"
|
||||
language="java"
|
||||
since="7.0.0"
|
||||
minimumLanguageVersion="1.5"
|
||||
message="Unnecessary {0}"
|
||||
class="net.sourceforge.pmd.lang.java.rule.codestyle.UnnecessaryBoxingRule"
|
||||
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#unnecessaryboxing">
|
||||
<description>
|
||||
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.
|
||||
</description>
|
||||
<priority>3</priority>
|
||||
<example><![CDATA[
|
||||
{
|
||||
// Instead of
|
||||
Integer integer = Integer.valueOf(2);
|
||||
// you may just write
|
||||
Integer integer = 2;
|
||||
|
||||
int i = integer.intValue(); // similarly for unboxing
|
||||
}
|
||||
]]>
|
||||
</example>
|
||||
</rule>
|
||||
|
||||
<!-- This is only restricted to java 5+ because the rule doesn't support
|
||||
the type system pre-java5, where there were no autoboxing conversions. -->
|
||||
<rule name="UnnecessaryCast"
|
||||
@@ -1572,36 +1603,6 @@ public class Foo {
|
||||
</example>
|
||||
</rule>
|
||||
|
||||
<rule name="UnnecessaryConversion"
|
||||
language="java"
|
||||
since="7.0.0"
|
||||
message="Unnecessary {0}"
|
||||
class="net.sourceforge.pmd.lang.java.rule.codestyle.UnnecessaryConversionRule"
|
||||
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_bestpractices.html#unnecessaryboxing">
|
||||
<description>
|
||||
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.
|
||||
</description>
|
||||
<priority>3</priority>
|
||||
<example><![CDATA[
|
||||
{
|
||||
// Instead of
|
||||
Integer integer = Integer.valueOf(2);
|
||||
// you may just write
|
||||
Integer integer = 2;
|
||||
|
||||
int i = integer.intValue(); // similarly for unboxing
|
||||
}
|
||||
]]>
|
||||
</example>
|
||||
</rule>
|
||||
|
||||
<rule name="UnnecessaryFullyQualifiedName"
|
||||
language="java"
|
||||
since="5.0"
|
||||
|
||||
+1
-1
@@ -6,6 +6,6 @@ package net.sourceforge.pmd.lang.java.rule.codestyle;
|
||||
|
||||
import net.sourceforge.pmd.testframework.PmdRuleTst;
|
||||
|
||||
public class UnnecessaryConversionTest extends PmdRuleTst {
|
||||
public class UnnecessaryBoxingTest extends PmdRuleTst {
|
||||
// no additional unit tests
|
||||
}
|
||||
Reference in new issue
Block a user