codemetrics
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.
cloc.pl (script): for line counts from cloc
For now, only Subversion and git are supported.
Installation
To install codemetrics, simply use pip:
pip install codemetrics
Usage
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
project = cm.GitProject('path/to/project')
loc_df = cm.get_cloc(project, cloc_program='/path/to/cloc')
log_df = cm.get_log(project)
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
project = cm.SvnProject('path/to/project')
log_df = cm.get_log(project).set_index(['revision', 'path'])
log_df.loc[:, ['added', 'removed']] = log_df.reset_index().\
groupby('revision').\
apply(cm.svn.get_diff_stats, chunks=False)
See module documentation for more advanced functions or the example notebook where codemetrics is applied to pandas.
There is also an example notebook running codemetrics on the pandas code base, and the example html export of that notebook output (some features are missing like the display of file names when hovering on the circles).
License
Licensed under the term of MIT License. See attached file LICENSE.txt.
Credits
This package was inspired by Adam Tornhill’s books.
This package was created with Cookiecutter.
Release files for codemetrics 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| codemetrics-1.0.0.tar.gz | 53.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| codemetrics-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 81.9 kB
Release files / codemetrics-1.0.0.tar.gz
| Download URL | codemetrics-1.0.0.tar.gz |
|---|---|
| Size | 53.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ecccf6f6531d7d3ecd1bdfae5e93af38f185505e6dd70100d5a21e2e28170abe
|
|
BLAKE2b-256 checksum How to use checksums |
061c3f071173090e89772c8c3d69c8c26de0958600458d12897917fe67e77ba1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 15, 2025.
Transparency logRelease files / codemetrics-1.0.0-py3-none-any.whl
| Download URL | codemetrics-1.0.0-py3-none-any.whl |
|---|---|
| Size | 28.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
10b2487518aa7c3e37fad984313aed3efbe071e15fae01832ba900216f407605
|
|
BLAKE2b-256 checksum How to use checksums |
731fc0564d3c66210f55f139bf9e0ae8d7fe8e48ba751862bfd6e2be1d6006b1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 15, 2025.
Transparency log