radon

Various code metrics for Python code

https://github.com/rubik/radon

Science Score: 13.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (14.6%) to scientific vocabulary

Keywords

cli code-analysis python quality-assurance static-analysis

Keywords from Contributors

closember json-schema wsgi pydantic parsing hints pytest unit-testing python310 python311
Last synced: 6 months ago · JSON representation

Repository

Various code metrics for Python code

Basic Info
Statistics
  • Stars: 1,837
  • Watchers: 33
  • Forks: 122
  • Open Issues: 38
  • Releases: 0
Topics
cli code-analysis python quality-assurance static-analysis
Created over 13 years ago · Last pushed over 1 year ago
Metadata Files
Readme Changelog License Security

README.rst

Radon
=====

.. image:: https://img.shields.io/coveralls/rubik/radon/master.svg?style=for-the-badge
    :alt: Coveralls badge
    :target: https://coveralls.io/r/rubik/radon?branch=master

.. image:: https://img.shields.io/pypi/v/radon.svg?style=for-the-badge
    :alt: PyPI latest version badge
    :target: https://pypi.python.org/pypi/radon

.. image:: https://img.shields.io/pypi/l/radon.svg?style=for-the-badge
    :alt: Radon license
    :target: https://pypi.python.org/pypi/radon

.. raw::  html

    

Featured|HelloGitHub

---- 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.12** (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: .. code-block:: sh $ pip install radon If you want to configure Radon from `pyproject.toml` and you run Python <3.11, you'll need the extra `toml` dependency: .. code-block:: sh $ pip install radon[toml] Or download the source and run the setup file: .. code-block:: sh $ python setup.py install Usage ----- Radon can be used either from the command line or programmatically. Documentation is at https://radon.readthedocs.org/. Cyclomatic Complexity Example ----------------------------- Quick example: .. code-block:: sh $ radon cc sympy/solvers/solvers.py -a -nc sympy/solvers/solvers.py F 346:0 solve - F F 1093:0 _solve - F F 1434:0 _solve_system - F F 2647:0 unrad - F F 110:0 checksol - F F 2238:0 _tsolve - F F 2482:0 _invert - F F 1862:0 solve_linear_system - E F 1781:0 minsolve_linear_system - D F 1636:0 solve_linear - D F 2382:0 nsolve - C 11 blocks (classes, functions, methods) analyzed. Average complexity: 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! .. image:: https://cloud.githubusercontent.com/assets/238549/3707477/5793aeaa-1435-11e4-98fb-00e0bd8137f5.png :alt: A screen of Radon's cc command **Note 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. .. note:: Jupyter Notebook support requires the optional ``nbformat`` package. To install, run ``pip install nbformat``. To enable scanning of Jupyter notebooks, add the ``--include-ipynb`` flag. To enable reporting of individual cells, add the ``--ipynb-cells`` flag. Quick example: .. code-block:: sh $ radon raw --include-ipynb --ipynb-cells . example.ipynb LOC: 63 LLOC: 37 SLOC: 37 Comments: 3 Single comments: 2 Multi: 10 Blank: 14 - Comment Stats (C % L): 5% (C % S): 8% (C + M % L): 21% example.ipynb:[0] LOC: 0 LLOC: 0 SLOC: 0 Comments: 0 Single comments: 0 Multi: 0 Blank: 0 - Comment Stats (C % L): 0% (C % S): 0% (C + M % L): 0% example.ipynb:[1] LOC: 2 LLOC: 2 SLOC: 2 Comments: 0 Single comments: 0 Multi: 0 Blank: 0 - Comment Stats (C % L): 0% (C % S): 0% (C + M % L): 0% Links ----- * Documentation: https://radon.readthedocs.org * PyPI: http://pypi.python.org/pypi/radon * Issue Tracker: https://github.com/rubik/radon/issues

Owner

  • Name: Michele Lacchia
  • Login: rubik
  • Kind: user
  • Location: Your mind.

GitHub Events

Total
  • Issues event: 6
  • Watch event: 144
  • Issue comment event: 15
  • Push event: 5
  • Pull request event: 5
  • Fork event: 8
Last Year
  • Issues event: 6
  • Watch event: 144
  • Issue comment event: 15
  • Push event: 5
  • Pull request event: 5
  • Fork event: 8

Committers

Last synced: 9 months ago

All Time
  • Total Commits: 520
  • Total Committers: 60
  • Avg Commits per committer: 8.667
  • Development Distribution Score (DDS): 0.162
Past Year
  • Commits: 5
  • Committers: 1
  • Avg Commits per committer: 5.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Michele Lacchia m****a@g****m 436
Eric Chea e****c@c****m 6
John Pignata j****n@p****m 5
Robert Dougherty-Bliss r****s@g****m 5
schettino72 s****2@g****m 4
David Douard d****d@s****g 3
Joaquin Sargiotto j****o@g****m 2
Marc Abramowitz m****c@m****m 2
Anthony b****7@y****u 2
Andrew Shannon Brown a****n 2
AJ Slater aj@s****t 2
Anthony Shaw a****w@a****g 2
Carlos Borroto c****o@g****m 2
Bit Shift b****t@b****t 1
Andrii Oriekhov a****v@g****m 1
Andrew Kittredge a****e@g****m 1
Alvaro Jose k****c 1
Alexander Mankuta a****b@p****e 1
4l1fe 4****e 1
xxvv s****g@1****m 1
kernc k****e@g****m 1
justWerns a****i@g****m 1
franzhaas f****s@g****m 1
devdanzin 7****n 1
dependabot[bot] 4****] 1
ABaldwinHunter a****r@c****m 1
Alex Brandt a****l@a****m 1
Andrew S. Brown a****n@n****m 1
Chris Hulton c****s@c****m 1
Collin Stocks c****n@h****m 1
and 30 more...

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 78
  • Total pull requests: 54
  • Average time to close issues: 5 months
  • Average time to close pull requests: 2 months
  • Total issue authors: 74
  • Total pull request authors: 38
  • Average comments per issue: 2.58
  • Average comments per pull request: 2.54
  • Merged pull requests: 35
  • Bot issues: 0
  • Bot pull requests: 1
Past Year
  • Issues: 6
  • Pull requests: 5
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 6
  • Pull request authors: 4
  • Average comments per issue: 0.5
  • Average comments per pull request: 0.2
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • rwbogl (3)
  • kloczek (2)
  • kush96 (2)
  • karulis (1)
  • marcoquerque (1)
  • flazzarini (1)
  • donfiguerres (1)
  • Freed-Wu (1)
  • devdanzin (1)
  • rmorshea (1)
  • Chamomile-Cat (1)
  • edwinelisia (1)
  • DonJayamanne (1)
  • MartinThoma (1)
  • wuligaigai (1)
Pull Request Authors
  • devdanzin (4)
  • cclauss (3)
  • kieran-ryan (3)
  • tonybaloney (3)
  • douardda (3)
  • ajslater (2)
  • ecarrara (2)
  • benabel (2)
  • msabramo (2)
  • syubogdanov (2)
  • akx (2)
  • mhamdan91 (2)
  • duongdominhchau (2)
  • tribals (2)
  • joxl (1)
Top Labels
Issue Labels
question (1) docs (1)
Pull Request Labels
dependencies (1)

Packages

  • Total packages: 4
  • Total downloads:
    • pypi 1,638,970 last-month
  • Total docker downloads: 1,954,035
  • Total dependent packages: 101
    (may contain duplicates)
  • Total dependent repositories: 1,352
    (may contain duplicates)
  • Total versions: 122
  • Total maintainers: 1
pypi.org: radon

Code Metrics in Python

  • Versions: 55
  • Dependent Packages: 99
  • Dependent Repositories: 1,352
  • Downloads: 1,638,970 Last month
  • Docker Downloads: 1,954,035
Rankings
Dependent packages count: 0.3%
Dependent repos count: 0.3%
Downloads: 0.5%
Docker downloads count: 0.6%
Average: 1.3%
Stargazers count: 1.7%
Forks count: 4.4%
Maintainers (1)
Last synced: 6 months ago
proxy.golang.org: github.com/rubik/radon
  • Versions: 44
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Stargazers count: 1.7%
Forks count: 2.5%
Average: 6.1%
Dependent packages count: 9.6%
Dependent repos count: 10.8%
Last synced: 6 months ago
conda-forge.org: radon

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)

  • Versions: 16
  • Dependent Packages: 2
  • Dependent Repositories: 0
Rankings
Stargazers count: 9.7%
Forks count: 16.5%
Dependent packages count: 19.5%
Average: 20.0%
Dependent repos count: 34.0%
Last synced: 6 months ago
anaconda.org: radon

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)

  • Versions: 7
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Stargazers count: 18.9%
Forks count: 28.7%
Average: 36.3%
Dependent packages count: 39.8%
Dependent repos count: 57.7%
Last synced: 6 months ago

Dependencies

Dockerfile docker
  • alpine edge build
Pipfile pypi
  • coverage * develop
  • mock * develop
  • pytest * develop
  • pytest-mock * develop
  • tox * develop
  • colorama >=0.3,<0.4
  • mando >=0.3,<0.4
Pipfile.lock pypi
  • appdirs ==1.4.4 develop
  • coverage ==4.4 develop
  • distlib ==0.3.1 develop
  • filelock ==3.0.12 develop
  • mock ==2.0.0 develop
  • pbr ==5.5.1 develop
  • pluggy ==0.13.1 develop
  • py ==1.10.0 develop
  • pytest ==3.0.7 develop
  • pytest-mock ==1.6.0 develop
  • six ==1.15.0 develop
  • tox ==2.7.0 develop
  • virtualenv ==20.4.4 develop
  • colorama ==0.3.9
  • flake8 ==3.9.1
  • flake8-polyfill ==1.0.1
  • mando ==0.3.3
  • mccabe ==0.6.1
  • pycodestyle ==2.7.0
  • pyflakes ==2.3.1
requirements.txt pypi
  • colorama >=0.4.1
  • colorama ==0.4.1
  • mando >=0.6,<0.7
setup.py pypi
  • colorama >=0.4.1
  • colorama ==0.4.1
  • mando >=0.6,<0.7
test_requirements.txt pypi
  • argparse * test
  • coverage * test
  • coveralls * test
  • nbformat * test
  • pytest >=2.7 test
  • pytest >=5.0 test
  • pytest-mock * test
poetry.lock pypi
  • argparse 1.4.0 develop
  • attrs 22.2.0 develop
  • cachetools 5.3.0 develop
  • certifi 2022.12.7 develop
  • chardet 5.1.0 develop
  • charset-normalizer 2.0.12 develop
  • coverage 6.5.0 develop
  • coveralls 3.3.1 develop
  • distlib 0.3.6 develop
  • docopt 0.6.2 develop
  • exceptiongroup 1.1.1 develop
  • fastjsonschema 2.16.3 develop
  • filelock 3.10.4 develop
  • idna 3.4 develop
  • importlib-metadata 6.1.0 develop
  • importlib-resources 5.12.0 develop
  • iniconfig 2.0.0 develop
  • jsonschema 4.17.3 develop
  • jupyter-core 4.12.0 develop
  • nbformat 5.8.0 develop
  • packaging 23.0 develop
  • pkgutil-resolve-name 1.3.10 develop
  • platformdirs 3.1.1 develop
  • pluggy 1.0.0 develop
  • pyproject-api 1.5.1 develop
  • pyrsistent 0.19.3 develop
  • pytest 7.2.2 develop
  • pytest-mock 3.10.0 develop
  • pywin32 305 develop
  • requests 2.27.1 develop
  • tomli 2.0.1 develop
  • tox 4.4.7 develop
  • traitlets 5.9.0 develop
  • typing-extensions 4.5.0 develop
  • urllib3 1.26.15 develop
  • virtualenv 20.21.0 develop
  • zipp 3.15.0 develop
  • colorama 0.4.6
  • mando 0.7.1
  • six 1.16.0
pyproject.toml pypi
  • colorama --- - !ruby/hash:ActiveSupport::HashWithIndifferentAccess version: ">=0.4.1" markers: python_version > "3.4" - !ruby/hash:ActiveSupport::HashWithIndifferentAccess version: "==0.4.1" markers: python_version <= "3.4"
  • mando >=0.6,<0.8
  • python >=3.7,<4.0