All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.sonar.l10n.java.rules.squid.S3052.html Maven / Gradle / Ivy

There is a newer version: 8.6.0.37351
Show newest version

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