lieteral

Introduction

The literal first bug is widely spread throughout the Sakai code base. This bug is mostly harmless, but causes the throwing of null pointer exceptions if a given instance is null. In other words, Sakai becomes stronger and more stable when the assumption is removed from the code base.

String poor;
    if (poor.equals("rich")) {
      Blah;
}

Throws a nullpointer where as does not:
    if ( "rich".equals(poor))   

Further checking for null no longer becomes necessary e.g.:

   if  ((poor == null) || (poor.equals("rich"))) 
is simplified to:
   if ( "rich".equals(poor))  

At the time of writing, there were 2000 lines in the Sakai code base. You can find a nightly report found at the following location:

A simple Perl/Regex based script that has the potential to replace 1100 instances reports once a night via the following link:

The script is not perfect, as it does not take into account removing the now unnecessary null check for some of the lines modified.

Potential workflow

  1. Download trunk
  2. Run advisor Perl script, replacing 1100 instances
  3. hand nudge the lines in the report you do not agree with
  4. Compile
  5. Commit
  6. By hand, Remove the other instances of the bugs reported
  7. Commit