radon 6.0.1
pip install radon
Released:
Code Metrics in Python
Navigation
Verified details
These details have been verified by PyPIMaintainers
π Avatar for Michele.Lacchia from gravatar.comMichele.Lacchia
Unverified details
These details have not been verified by PyPIProject links
Meta
- License: MIT License (MIT)
- Author: Michele Lacchia
- Tags static , analysis , code , complexity , metrics
Classifiers
- Development Status
- Environment
- Intended Audience
- License
- Operating System
- Programming Language
- Topic
Project description
π Travis-CI badge
π Coveralls badge
π PyPI latest version badge
π Radon license
Radon is a Python tool that computes various metrics from the source code. Radon can compute:
McCabeβs complexity, i.e. cyclomatic complexity
raw metrics (these include SLOC, comment lines, blank lines, &c.)
Halstead metrics (all of them)
Maintainability Index (the one used in Visual Studio)
Requirements
Radon will run from Python 2.7 to Python 3.8 (except Python versions from 3.0 to 3.3) with a single code base and without the need of tools like 2to3 or six. It can also run on PyPy without any problems (currently PyPy 3.5 v7.3.1 is used in tests).
Radon depends on as few packages as possible. Currently only mando is strictly required (for the CLI interface). colorama is also listed as a dependency but if Radon cannot import it, the output simply will not be colored.
Note: Python 2.6 was supported until version 1.5.0. Starting from version 2.0, it is not supported anymore.
Installation
With Pip:
$pipinstallradon
If you want to configure Radon from pyproject.toml and you run Python <3.11, youβll need the extra toml dependency:
$pipinstallradon[toml]
Or download the source and run the setup file:
$pythonsetup.pyinstall
Usage
Radon can be used either from the command line or programmatically. Documentation is at https://radon.readthedocs.org/.
Cyclomatic Complexity Example
Quick example:
$radonccsympy/solvers/solvers.py-a-ncsympy/solvers/solvers.pyF346:0solve-FF1093:0_solve-FF1434:0_solve_system-FF2647:0unrad-FF110:0checksol-FF2238:0_tsolve-FF2482:0_invert-FF1862:0solve_linear_system-EF1781:0minsolve_linear_system-DF1636:0solve_linear-DF2382:0nsolve-C11blocks(classes,functions,methods)analyzed.Averagecomplexity:F(61.0)
Explanation:
cc is the radon command to compute Cyclomatic Complexity
-a tells radon to calculate the average complexity at the end. Note that the average is computed among the shown blocks. If you want the total average, among all the blocks, regardless of what is being shown, you should use --total-average.
-nc tells radon to print only results with a complexity rank of C or worse. Other examples: -na (from A to F), or -nd (from D to F).
The letter in front of the line numbers represents the type of the block (F means function, M method and C class).
Actually itβs even better: itβs got colors!
π A screen of Radon's cc commandNote about file encoding
On some systems, such as Windows, the default encoding is not UTF-8. If you are using Unicode characters in your Python file and want to analyze it with Radon, youβll have to set the RADONFILESENCODING environment variable to UTF-8.
On a Continuous Integration server
If you are looking to use radon on a CI server you may be better off with xenon. Although still experimental, it will fail (that means exiting with a non-zero exit code) when various thresholds are surpassed. radon is more of a reporting tool, while xenon is a monitoring one.
If you are looking for more complete solutions, read the following sections.
Codacy
Codacy uses Radon by default to calculate metrics from the source code.
Code Climate
Radon is available as a Code Climate Engine. To understand how to add Radonβs checks to your Code Climate Platform, head over to their documentation: https://docs.codeclimate.com/v1.0/docs/radon
coala Analyzer
Radon is also supported in coala. To add Radonβs checks to coala, simply add the RadonBear to one of the sections in your .coafile.
CodeFactor
CodeFactor uses Radon out-of-the-box to calculate Cyclomatic Complexity.
Usage with Jupyter Notebooks
Radon can be used with .ipynb files to inspect code metrics for Python cells. Any % macros will be ignored in the metrics.
To enable scanning of Jupyter notebooks, add the --include-ipynb flag.
To enable reporting of individual cells, add the --ipynb-cells flag.
Quick example:
$radonraw--include-ipynb--ipynb-cells.example.ipynbLOC:63LLOC:37SLOC:37Comments:3Singlecomments:2Multi:10Blank:14-CommentStats(C%L):5%(C%S):8%(C+M%L):21%example.ipynb:[0]LOC:0LLOC:0SLOC:0Comments:0Singlecomments:0Multi:0Blank:0-CommentStats(C%L):0%(C%S):0%(C+M%L):0%example.ipynb:[1]LOC:2LLOC:2SLOC:2Comments:0Singlecomments:0Multi:0Blank:0-CommentStats(C%L):0%(C%S):0%(C+M%L):0%
Links
Documentation: https://radon.readthedocs.org
Issue Tracker: https://github.com/rubik/radon/issues
Project details
Verified details
These details have been verified by PyPIMaintainers
π Avatar for Michele.Lacchia from gravatar.comMichele.Lacchia
Unverified details
These details have not been verified by PyPIProject links
Meta
- License: MIT License (MIT)
- Author: Michele Lacchia
- Tags static , analysis , code , complexity , metrics
Classifiers
- Development Status
- Environment
- Intended Audience
- License
- Operating System
- Programming Language
- Topic
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file radon-6.0.1.tar.gz.
File metadata
- Download URL: radon-6.0.1.tar.gz
- Upload date:
- Size: 1.9 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d1ac0053943a893878940fedc8b19ace70386fc9c9bf0a09229a44125ebf45b5
|
|
| MD5 |
8c0ba595d9f98729065c1fcd60871c71
|
|
| BLAKE2b-256 |
b16d98e61600febf6bd929cf04154537c39dc577ce414bafbfc24a286c4fa76d
|
File details
Details for the file radon-6.0.1-py2.py3-none-any.whl.
File metadata
- Download URL: radon-6.0.1-py2.py3-none-any.whl
- Upload date:
- Size: 52.8 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
632cc032364a6f8bb1010a2f6a12d0f14bc7e5ede76585ef29dc0cecf4cd8859
|
|
| MD5 |
f43fa37a3da11b3783e050142cc45cd7
|
|
| BLAKE2b-256 |
93f7d00d9b4a0313a6be3a3e0818e6375e15da6d7076f4ae47d1324e7ca986a1
|
