sourcery-analytics is a library and command-line interface (CLI) for analyzing the code quality of Python packages, modules, or source code.
Project description
Sourcery Analytics
sourcery-analytics
is a command line tool and library for statically analyzing Python code quality.
Get started by installing using pip
:
pip install sourcery-analytics
This will install sourcery-analytics
as a command-line tool.
To analyze a single Python file, use the analyze
subcommand:
sourcery-analytics analyze path/to/file.py
Example:
sourcery-analytics analyze sourcery_analytics/analysis.py
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━┓
┃ Method ┃ length ┃ cyclomatic_complexity ┃ cognitive_complexity ┃ working_memory ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━┩
│ sourcery_analytics.analysis.analyze │ 5 │ 1 │ 0 │ 8 │
│ sourcery_analytics.analysis.analyze_methods │ 4 │ 1 │ 1 │ 12 │
└─────────────────────────────────────────────┴────────┴───────────────────────┴──────────────────────┴────────────────┘
Alternatively, import and run analysis using the library:
from sourcery_analytics import analyze_methods
source = """
def cast_spell(self, spell):
if self.power < spell.power:
raise InsufficientPower
print(f"{self.name} cast {spell.name}!")
"""
analyze_methods(source)
# [{'method_qualname': '.cast_spell', 'method_length': 3, 'method_cyclomatic_complexity': 1, 'method_cognitive_complexity': 1, 'method_working_memory': 6}]
For more, see the docs.
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
sourcery-analytics-1.0.1.tar.gz
(15.3 kB
view hashes)
Built Distribution
Close
Hashes for sourcery_analytics-1.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d71e75571372c809f0a4356b987fd24749a629e18d7b8418a6f6e52c215fd890 |
|
MD5 | d54870ad8b2bf2468bc2482a50b3dd98 |
|
BLAKE2b-256 | 835e4aa2b1f170d85bb2e07bafcbf8a88f058a71718082cc0dac5bed8262dd03 |