PyPi version Python compatibility Travis master status AppVeyor master status dependency status for latest release Documentation Coverage Codacy


Mine your SCM for insight on your software. A work of love inspired by Adam Tornhill’s books.

Code metrics is a simple Python module that leverage pandas and your source control management (SCM) tool togenerate insight on your code base.

  • pandas: for data munching.
  • lizard: for code complexity calculation.
  • (script): for line counts from cloc
  • For now, only Subversion and git are supported.


To install codemetrics, simply use pip:

pip install codemetrics


This is a simple tool that makes it easy to retrieve information from your Source Control Management (SCM) repository and hopefully gain insight from it.

import codemetrics as cm
import cm.git

log_df = cm.get_git_log()
ages_df = cm.get_ages(log_df)

To retrieve the number of lines changed by revision with Subversion:

import codemetrics as cm
import cm.git

log_df = cm.get_svn_log().set_index(['revision', 'path'])
log_df.loc[:, ['added', 'removed']] = log_df.reset_index().\
                                         apply(cm.svn.get_diff_stats, chunks=False)

See module documentation for more advanced functions or the example notebook


Licensed under the term of MIT License. See attached file LICENSE.txt.