Detecting Anomalies in the Order of Equally-typed Method Arguments


Motivation

Image to be a programmer who wants to call a method setEndPoints(int, int). You must pass two arguments of type int. But what should you pass as the first argument and what as the second argument? Methods like this can cause three kinds of problems:

  • Bugs, if you pass arguments in the wrong order.
  • Confused programmers, if the names of the formal parameters in the declaration of the method are badly chosen.
  • Maintenance problems, if you pass argument correctly, but the argument's names suggest a different order.
We developed a simple yet effective technique to detect these problems with little effort.


Paper

A paper describing our approach has been accepted for ISSTA 2011:

Michael Pradel and Thomas R. Gross.
Detecting Anomalies in the Order of Equally-typed Method Arguments
International Symposium on Software Testing and Analysis (ISSTA 2011)


Implementation

You can download the source code of our implementation. The tool, Argument Analyzer, is implemented as an Eclipse plugin. It depends in the SecondString project (a library of of string comparison techniques). Once you have the plugin running in Eclipse, you can right click on a Java project and select Argument Analyzer - Anomaly Detection. The tool will analyze all method calls in this project and print a list of anomalies.

Version 2.0 (September 2012)

A revised version of ArgumentAnalyzer that provides higher recall and precision, as well as support for C (in addition to Java). We have tested the implementation with Eclipse 3.7.1. You'll need the Eclipse JDT and the Eclipse CDT. The source code is made available under the GNU Lesser General Public License.

Version 1.0 (May 2011)

We used this version of ArgumentAnalyzer in the ISSTA'11 paper. We have tested the implementation with Eclipse 3.5.2. The source code is made available under the GNU General Public License.


Evaluation

The code base we use to evaluate the approach (the source code of the programs from the DaCapo benchmark suite) is available upon request.