JUCS - Journal of Universal Computer Science 20(5): 746-771, doi: 10.3217/jucs-020-05-0746
A Catalogue of Refactorings to Remove Incomplete Annotations
expand article infoFlavio Medeiros, Márcio Ribeiro, Rohit Gheyi§, Baldoino Fonseca|
‡ Federal University of Campina Grande, Campina Grande, Brazil§ Campina Grande, Brazil| Federal University of Alagoas, Maceio, Brazil
Open Access
Developers use the C Preprocessor (CPP) to handle portability and variability in program families of different sizes and domains. However, despite the widely use of the CPP in practice, it is often criticised due to its negative impact on code quality and maintainability, tool development, and its error-prone characteristics. In particular, developers aggravate these problems when using incomplete annotations, i.e., directives encompassing only parts of syntactical units. In a previous work, we performed an empirical study on 41 C program family releases and found that almost 90% of syntax errors occur in incomplete annotations. There are some refactorings to remove incomplete annotations proposed in the literature. However, they clone code and increase Lines of Code (LOC). To avoid incomplete annotations and their intrinsic problems, in this article we propose a catalogue of refactorings that converts incomplete annotations into complete ones without cloning code. We implement an Eclipse plug-in to help developers applying our refactorings automatically. To evaluate our catalogue, we performed a study to analyse questions related to code cloning, LOC, and number of directives. To answer our research questions, we analyse releases of 12 C program families of different domains ranging from 4.9 thousand to 1.5 million LOC. The results show that our catalogue can remove all incomplete annotations without cloning code, and increasing only in 0.04% the LOC and in 2.10% the number of directives.
refactoring, C language, preprocessors, program families