resources.report.rules.pmd.RedundantFieldInitializer.html Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sanity4j Show documentation
Show all versions of sanity4j Show documentation
Sanity4J was created to simplify running multiple static code
analysis tools on the Java projects. It provides a single entry
point to run all the selected tools and produce a consolidated
report, which presents all findings in an easily accessible
manner.
RedundantFieldInitializer
RedundantFieldInitializer
Java will initialize fields with known default values so any explicit initialization of those same defaults is redundant and results in a larger class file (approximately three additional bytecode instructions per field).
This rule is defined by the following Java class: net.sourceforge.pmd.lang.java.rule.optimizations.RedundantFieldInitializerRule
Example(s):
public class C {
boolean b = false; // examples of redundant initializers
byte by = 0;
short s = 0;
char c = 0;
int i = 0;
long l = 0;
float f = .0f; // all possible float literals
doable d = 0d; // all possible double literals
Object o = null;
MyClass mca[] = null;
int i1 = 0, ia1[] = null;
class Nested {
boolean b = false;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy