Skip to main content

git-outlier

Code style: black codecov example workflow

Data-driven screening to find source code that need refactoring.

Still under development and not yet ready to be used.

Introduction

Run git-outlier to find source code files that are suitable candidates for refactoring. git-outlier finds outliers in a source code directory under git version control in three categories: complexity, churn, and combined complexity and churn. The top files are worthy of further investigation.

The combined complexity and churn outliers should be the top candidates for refactoring. The complexity and churn plot is divided into four equal zones. All zones are ok to be in except the right-top-zone; these files are both complex and change often. The source code in these files will probably be easier to change and maintain if they are refactored.

The source code is analyzed per file, so this requires your project to contain multiple source code files with logic entities in separate files to make sense.

There are different metrics of complexity available. Choose the one that makes most sense for you or try both. Files that are outliers regardless of chosen complexity metrics are top candidates for refactoring.

Installation

The latest release should be available via PyPI.

[sudo] pip install git-outlier

Usage

If installed as a package, it should be directly available in git as

git outlier

and use the same options as the python script.

The python script can be run with the following options.

usage: git_outlier.py [-h] [--languages LANGUAGES] [--metric METRIC] [--span SPAN] [--top TOP] [-v] [path]

Analyze a source directory that uses git as version handling system. The source files are analyzed for different type of 
outliers and these outliers can be good candidates for refactoring to increase maintainability. The source files are 
ranked in falling order after churn, complexity, and combined churn and complexity.

positional arguments:
  path                  The path to the source directory to be analyzed. Will default to current directory if not present.

optional arguments:
  -h, --help            show this help message and exit
  --languages LANGUAGES, -l LANGUAGES
                        List the programming languages you want to analyze. If left empty, it'll search for all 
                        recognized languages. Example: 'outlier -l cpp -l python' searches for C++ and Python code. The
                        available languages are: c, cpp, csharp, fortran, go, java, javascript, lua, objective-c, php, 
                        python, ruby, rust, scala, swift, typescript
  --metric METRIC, -m METRIC
                        Choose the complexity metric you would like to base the results on. Either cyclomatic complexity
                         'CCN' or lines of code without comments 'NLOC'. If not specified, the default is 'CCN'.
  --span SPAN, -s SPAN  The number (integer) of months the analysis will look at. Default is 12 months.
  --top TOP, -t TOP     The number (integer) of outliers to show. Note that for the combined churn and complexity 
                        outliers, there is no maximum. Default is 10.
  -v, --verbose         Show analysis details and debug info.

Supported languages

Supported languages

  • C
  • C++
  • C#
  • Fortran
  • Go
  • Java
  • JavaScript
  • Lua
  • Objective-c
  • Php
  • Python
  • Ruby
  • Rust
  • Scala
  • Swift
  • TypeScript

The code complexity is computed using lizard.

References

The idea comes from Michael Feathers' article Getting Empirical about Refactoring.

Release files for git-outlier 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for git-outlier 0.0.2
File Size Uploaded
git-outlier-0.0.2.tar.gz 21.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for git-outlier 0.0.2
File Interpreter ABI Platform
git_outlier-0.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 41.0 kB

Release files / git-outlier-0.0.2.tar.gz

Download URL git-outlier-0.0.2.tar.gz
Size 21.0 kB
Tags Source
SHA-256 checksum
How to use checksums
9be8a745790d9bc254ccddffade55337e18af273d2d7aaeec6d016ecda6bfdc9
BLAKE2b-256 checksum
How to use checksums
d2383244be317b5472e2ac8b45889c6e01f7d15dcc90cb2013bcae2d7fecb1bf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.6.0 pkginfo/1.7.0 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.8.10

Release files / git_outlier-0.0.2-py3-none-any.whl

Download URL git_outlier-0.0.2-py3-none-any.whl
Size 20.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
51d18f2be82d92b4a5ac1b682fe4954596ac68781078f55dd368e68f41a036e1
BLAKE2b-256 checksum
How to use checksums
a341c8c51a6b23883e35cb0d39e1383dbd5e9faf42ff2b93617baf6c6b18f6d7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.6.0 pkginfo/1.7.0 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.8.10

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files

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