org.sonar.l10n.java.rules.squid.S3052.html Maven / Gradle / Ivy
The compiler automatically initializes class fields to their default values before setting them with any initialization values,
so there is no need to explicitly set a field to its default value. Further, under the logic that cleaner code is better code,
it's considered poor style to do so.
Noncompliant Code Example
public class MyClass {
int count = 0; // Noncompliant
// ...
}
Compliant Solution
public class MyClass {
int count;
// ...
}
Exceptions
Do not raise issues for final fields.
© 2015 - 2025 Weber Informatics LLC | Privacy Policy