A collection of python tools to inspect code quality.
python -m venv .venv/
source .venv/bin/activate
pip install inspectrGenerally, the syntax goes:
inspectr <subtool> [options] [files...]where <subtool> is one of the following:
authenticity: looks for TODO comments, empty try/except blocks, and stub functionsbare_ratio: checks for the ratio of bare excepts to meaningful exception usagecompare_funcs: compares function/method names across two directory versionscomplexity: analyzes algorithmic complexity of Python codecount_exceptions: counts how many of each type of exception there are (including bare except)duplicates: looks for occurrences of duplicate or similar code (>80% similarity, default: 10+ lines, 3+ occurrences)size_counts: various linecount-related code complexity checkswith_open: checks foropenin the absense ofwithand manual calls toclose()
All tools accept command-line options in the format --option-name value.
Options are passed as keyword arguments to the tool's main function. For example:
inspectr duplicates --block-size 15 --min-occur 2 file1.py file2.pyRecognized options include:
duplicates:--block-size N: number of consecutive lines in a block (default: 10)--min-occur N: minimum number of occurrences to report (default: 3
Note: any unrecognized options will be silently ignored.
The compare_funcs tool compares functions across two directory versions:
inspectr compare_funcs files_list.txt dir1 dir2where files_list.txt contains relative paths to compare, one per line.
First install in development mode with test dependencies, then run the tests:
git clone https://github.com/ajcm474/inspectr.git
cd inspectr
pip install -e ".[test]"
pytest tests/Please note: this project is in the early alpha stage, so don't expect the above subtool names to be stable between versions. I might even merge/split them at some point.