Code sniffer: a risk based smell detection framework to enhance code quality using static code analysis
Ahmad Tahmid, Md. Nurul Ahad Tawhid, Sumon Ahmed, Kazi Muheymin Sakib · International Journal of Software Engineering Technology and Applications · 2017
To maintain software and enhance its code quality, code smell, i.e., undesired design flaws need to be detected. However, as the system size increases, manual smell detection becomes difficult. In this paper, a static code analysis framework, named code sniffer, is proposed to detect code smells with predicting their risk severity. This has been calculated using code metrics, and defined as low, moderate and high. The system consists of three main components: parser extracts a syntax tree from the given source code to identify the code structure. The syntax tree is searched against the syntax of class and method. Analyser searches found classes and methods against various code syntax to identify key features like line of code (LOC), number of properties (NOP), etc. In smell and risk detector, code smells, risky code segments and their severity are detected as a set of quantitative values (using LOC, NOP, etc.) using which classes and methods are judged. A comparative case study of this risk based static analyser is performed with a dynamic analyser, FxCop, and the comparison results support each other.