Automated detection of code smells caused by null checking conditions in Java programs
Kriangchai Sirikul, Chitsutha Soomlek · 2016
A null object in Java is occurred when an object is not initialized properly, but a property or a method in the object is called; resulting in the null pointer exception problem and low software quality. To solve this problem, developers usually create a number of null checking conditions in their codes. Duplicated null checking conditions affect the code quality. The duplicated code makes a computer program repeatedly and exhaustively checks for null value, therefore, it reduces the performance of the program. This research involves automatically detecting the code smells caused by null checking conditions in Java by using regular expression. The research specifically focuses on detecting (i) introduce null object, (ii) duplicated code, and (iii) null checking in a string comparison problem. Thirteen Java open-source projects were employed to verify and validate our approach. The detection results were significantly improved when using regular expression comparing to using Abstract Syntax Tree (AST) for detecting code smells caused by null checking conditions in Java programs.