Skip to main content

Data-driven screening to find source code that need refactoring

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

git-outlier-0.0.2.tar.gz (21.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

git_outlier-0.0.2-py3-none-any.whl (20.0 kB view details)

Uploaded Python 3

File details

Details for the file git-outlier-0.0.2.tar.gz.

File metadata

  • Download URL: git-outlier-0.0.2.tar.gz
  • Upload date:
  • Size: 21.0 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for git-outlier-0.0.2.tar.gz
Algorithm Hash digest
SHA256 9be8a745790d9bc254ccddffade55337e18af273d2d7aaeec6d016ecda6bfdc9
MD5 6b81a500c7403358d9d2d648fd942533
BLAKE2b-256 d2383244be317b5472e2ac8b45889c6e01f7d15dcc90cb2013bcae2d7fecb1bf

See more details on using hashes here.

File details

Details for the file git_outlier-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: git_outlier-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 20.0 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for git_outlier-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 51d18f2be82d92b4a5ac1b682fe4954596ac68781078f55dd368e68f41a036e1
MD5 7c6f1aabe6d0c35880d764cec4ebad3b
BLAKE2b-256 a341c8c51a6b23883e35cb0d39e1383dbd5e9faf42ff2b93617baf6c6b18f6d7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page