Abstract:
Redundant null check can result in dead code, hinder code comprehension and efficiency, and indicate that the program may contain bugs. This paper proposes RedDetector, an approach to detect redundant null checks based on dataflow analysis. This approach could detect more redundant null checks by enhancing dataflow analysis. We collected 35 popular GitHub projects and manually collected their redundant null checks into a dataset. Based on the dataset, compared with a state-of-the-art tool, the precision and recall of the unreachable null check statements detected by RedDetector increased by 83.7 and 54.4 percentage points respectively. The precision and recall of the certainly-reachable null check statements detected by RedDetector increased by 75.4 and 44.7 percentage points.