Skip to main content
PyPi version Python compatibility GitHub Workflow Python application AppVeyor main status Libraries.io dependency status for latest release Documentation Coverage Codacy

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

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)

Source distribution for codemetrics 1.0.0
File Size Uploaded
codemetrics-1.0.0.tar.gz 53.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for codemetrics 1.0.0
File Interpreter ABI Platform
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 log

Release 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

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

0.11.7

3 release files

0.11.6

2 release files

0.11.5

1 release file

0.11.4

1 release file

0.11.3

2 release files

0.11.2

2 release files

0.11.1

2 release files

0.11.0

2 release files

0.10.0

2 release files

0.9.6

1 release file

0.9.5

1 release file

0.9.4

1 release file

0.9.3

1 release file

0.9.2

1 release file

0.9.1

1 release file

0.9.0

1 release file

0.8.2

1 release file

0.8.1

1 release file

0.8.0

1 release file

0.7.1

1 release file

0.7.0

1 release file

0.6.1

1 release file

0.6

1 release file

0.5.2

1 release file

0.5.1

1 release file

0.5

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page