title: Java: Sonar compulsory constructor
body: <p>We're using Sonar for code analysis. For classes something like this</p>
  
  <pre><code>public class Car {
    private Engine engine; 
  
    // getter setter for engine
  }
  </code></pre>
  
  <p>we get errors such as </p>
  
  <p><code>Non-abstract classes and enums with non-static, private members should explicitly initialize those members, either in a constructor or with a default value.
  </code></p>
  
  <p>We usually serialize our objects with Jackson, so constructor is not used anywhere in our code. So why do I still need to write a constructor? Would it make sense to disable this rule?  <a href="https://rules.sonarsource.com/java/RSPEC-1258" rel="nofollow noreferrer">Rule Link</a></p>
  
  <p>Another thing, if I change code as below</p>
  
  <pre><code>private Engine engine = null;
  </code></pre>
  
  <p>The error is not thrown. By default, all Java references are assigned with a null value. Is this line fooling Sonar? Should this be a bug in Sonar?</p>