Data-driven screening to find source code that need refactoring
Project description
git-outlier
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for git_outlier-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 51d18f2be82d92b4a5ac1b682fe4954596ac68781078f55dd368e68f41a036e1 |
|
MD5 | 7c6f1aabe6d0c35880d764cec4ebad3b |
|
BLAKE2b-256 | a341c8c51a6b23883e35cb0d39e1383dbd5e9faf42ff2b93617baf6c6b18f6d7 |