Issue No. 08 - Aug. (2013 vol. 39)
DOI Bookmark: http://doi.ieeecomputersociety.org/10.1109/TSE.2013.7
Michael Pradel , ETH Zurich, Zurich
Thomas R. Gross , ETH Zurich, Zurich
When calling a method that requires multiple arguments, programmers must pass the arguments in the expected order. For statically typed languages, the compiler helps programmers by checking that the type of each argument matches the type of the formal parameter. Unfortunately, types are futile for methods with multiple parameters of the same type. How can a programmer check that equally typed arguments are passed in the correct order? This paper presents two simple, yet effective, static program analyses that detect problems related to the order of equally typed arguments. The key idea is to leverage identifier names to infer the semantics of arguments and their intended positions. The analyses reveal problems that affect the correctness, understandability, and maintainability of a program, such as accidentally reversed arguments and misleading parameter names. Most parts of the analyses are language-agnostic. We evaluate the approach with 24 real-world programs written in Java and C. Our results show the analyses to be effective and efficient. One analysis reveals anomalies in the order of equally typed arguments; it finds 54 relevant problems with a precision of 82 percent. The other analysis warns about misleading parameter names and finds 31 naming bugs with a precision of 39 percent.
Java, Access control, Engines, Feature extraction, Context, Robustness, Program processors, method arguments, Testing and debugging, maintenance, documentation, static program analysis, anomaly detection
Michael Pradel, Thomas R. Gross, "Name-Based Analysis of Equally Typed Method Arguments", IEEE Transactions on Software Engineering, vol. 39, no. , pp. 1127-1143, Aug. 2013, doi:10.1109/TSE.2013.7