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

resources.report.rules.pmd.NullAssignment.html Maven / Gradle / Ivy



NullAssignment


NullAssignment

Assigning a "null" to a variable (outside of its declaration) is usually bad form. Some times, the assignment is an indication that the programmer doesn't completely understand what is going on in the code. NOTE: This sort of assignment may in rare cases be useful to encourage garbage collection. If that's what you're using it for, by all means, disregard this rule :-)

This rule is defined by the following Java class: net.sourceforge.pmd.rules.design.NullAssignmentRule

Example:

                
 
 public class Foo {
   public void bar() {
     Object x = null; // This is OK.
     x = new Object();
     // Big, complex piece of code here.
     x = null; // This is BAD.
     // Big, complex piece of code here.
   }
 }

 
      
            




© 2015 - 2025 Weber Informatics LLC | Privacy Policy