bug-metrics-research

The purpose of this repository is to make the script available to extract metrics from public software repositories. These metrics will be used for a research of doctoral student Jacson from UFG.

Metrics

All metrics were extracted using Understand software (https://scitools.com/feature/metrics/). Metrics are information used to evaluate the quality and complexity of software. This link (https://scitools.com/feature/metrics/) provides a description of Understand metrics.

Tools and Prerequisites

How to do?

  • After installing MySQL, create a database with the project name that will be parsed, in this case "tomcat". I would like to create this database with the same project name to keep the analysis organization of multiple projects. Import the data from SQL files from the "dump" directory to this created database. The "bug_and_files" table is where you can find the bugs analyzed and the commit information and which files to analyze.

  • 1 Create a directory on the root of your computer, for example "c: \ repos". This directory will be used to clone the project to be analyzed.

  • 2 Create a directory of your choice to clone this project. For example, "c: \ repos \ script". Within this directory clone this project with the git command:

$ git clone https://github.com/fr3d3rico/bug-metrics-research.git

A directory called "bug-metrics-research" will be created. Open and edit the files with the IDE or text editor of your choice.

  • 3 In the Java script project, go to the "Config.java" class and put this path from step 1 "c: \ repos \" in the "REPOSITORY_DIR" variable. Attention: Depending on your operating system you must place two bars. As in this example of Windows.

  • 4 Return to the directory from step 1 and download / clone the repository you want to analyze. In this case the Tomcat project (http://tomcat.apache.org/) will be analyzed. In the terminal, browse to the directory from step 1 and give the following command:

$ git clone https://github.com/apache/tomcat.git

The cloned project will be this on the github site: https://github.com/apache/tomcat.git

  • 5 Within the "c: \ repos" directory create a directory called "report" ("c: \ repos \ report") or with your preferred name. This directory will receive the logs generated by Understand in "CSV" format. Then go to the "Config.java" class and also change the path to the "REPORT_DIR" directory with the following path: "c: \ repos \ report \"

  • 6 Within the c: \ repos \ report \ directory create one with the name of the project in question, for example "tomcat". Getting like this: "c: \ repos \ report \ tomcat"

  • 7 In the "BugAcademicResearch.java" class, early on change the variable "PROJECT NAME" to "tomcat".

  • 8 Now let's set up Understand. The understand has a restriction. When parsing the files, it will grow the .udb file extension to 10mb, 50mb and so on. And with each analysis you do, it slows down and takes longer. So I chose to create an empty analysis file. This file will be in a backup directory, and with each bug, I add it again so that processing doesn't slow down to extract the metrics. That done I remove the file and restart it again copying the file from the backup directory. This way the processing was much faster.

After installing Understand, open the tool and create a new project: alt tag

Enter the project data. For example, to make it easier, if you are analyzing more than one project at a time, put the project name the same as the analyzed project name, for example, "tomcat". Enter the root directory of the cloned tomcat project. alt tag

Enter only the Java technology that will be analyzed. alt tag

Click on "Next" and finish the project creation. alt tag

Then configure the project informing the metrics that will be extracted. alt tag alt tag

Then browse to the directory where the project was cloned, for example, c: \ repos \ tomcat and see that there is the file "tomcat.udb". This file is only between 8 and 10kb.

Make a copy of this file to the Config.REPOSITORY_DIR + "backup" directory. This "backup" directory must be created and will be the storage location for the .udb files to prevent the Understand project from growing and becoming cumbersome to process.

  • 9 To execute the project, simply enter the root of the script project and execute the command:

$ gradle run

The script will query the database bugs. It will then checkout 1 previous commit from the bug commit. To check out the previous commit the command "git checkout ~ 1" is used. The script then checks which files will be analyzed and attempts to add them to the Understand project. Sometimes it happens that a commit has no file in bug-id. So in this case it will not be analyzed. If at least 1 file is present, the script will parse and then request the metrics for Understand.

  • 10 Understand will save the csv file for each bug analyzed in the report / PROJECT NAME path. The script will copy this file to the Config.REPORT_DIR directory to log the log.

Share!

Feel free to fork, change, improve or create a new project.