Skip to content

Persper/code-analytics

Repository files navigation

Persper Code Analytics Tool

This project implements the DevRank algorithm for quantiying the structural value of code contributions as described in

J. Ren*, H. Yin*, Q. Hu, A. Fox, W. Koszek. Towards Quantifying the Development Value of Code Contributions. In FSE (NIER), 2018.

This repo contains a central code analyzer written in python, which given a target git repository, invokes language-specific call graph server to construct the call-commit graph (union of all commits' call graphs) while it iterates through the commits of the repository being analzyed. The resulted call-commit graph is stored in the CallCommitGraph class, which knows how to compute DevRanks for functions, commits, and developers.

Get Started

The following procedure is tested on Ubuntu 16.04 LTS.

  1. Install Python (>=3.6)

Download and install Python 3.6+: https://www.python.org/downloads/.

Also, create a symbolic link from python3 to python since some scripts reply on it.

sudo ln -s /usr/bin/python3 /usr/bin/python
  1. Install python dependencies (we recommend to use pipenv)
pipenv install
  1. Update git

In order to uset the --indent-heuristic option of git diff, we require git version >= 2.11. Use the following commands to upgrade:

sudo add-apt-repository ppa:git-core/ppa -y
sudo apt-get update
sudo apt-get install git -y
git --version
  1. Add project directory to path

Add the following line to your ~/.bashrc file.

export PYTHONPATH=$PYTHONPATH:/path/to/dir

To update your path for the remainder of the session.

source ~/.bashrc
  1. Install srcML for parsing C/C++ and Java

Please download from here and follow the instructions.

srcML also needs libarchive-dev and libcurl4-openssl-dev. Install them with the following commands:

sudo apt install libarchive-dev
sudo apt install libcurl4-openssl-dev
  1. Check setup correctness

As the test process will create Git repositories, set up your global Git user name and email before testing:

git config --global user.email "[email protected]"
git config --global user.name "Your Name"

Run the test process:

pipenv run pytest test/test_analytics

You should see all tests passed.

Report Test Coverage

We use coverage.py and pytest-cov to compute test coverage:

# Execution
pytest --cov=persper/ test/test_analytics

# Reporting
coverage html

# then visit htmlcov/index.html in your browser