{"id":13572318,"url":"https://github.com/rubik/radon","last_synced_at":"2025-05-14T00:09:00.273Z","repository":{"id":4741976,"uuid":"5891360","full_name":"rubik/radon","owner":"rubik","description":"Various code metrics for Python code","archived":false,"fork":false,"pushed_at":"2024-10-20T09:52:54.000Z","size":2723,"stargazers_count":1811,"open_issues_count":36,"forks_count":122,"subscribers_count":33,"default_branch":"master","last_synced_at":"2025-04-23T17:06:22.508Z","etag":null,"topics":["cli","code-analysis","python","quality-assurance","static-analysis"],"latest_commit_sha":null,"homepage":"http://radon.readthedocs.org/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rubik.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGELOG","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2012-09-20T18:58:58.000Z","updated_at":"2025-04-23T08:12:56.000Z","dependencies_parsed_at":"2024-01-16T22:18:40.695Z","dependency_job_id":"6b0c0f50-6ab4-4615-84cb-060651d25404","html_url":"https://github.com/rubik/radon","commit_stats":{"total_commits":515,"total_committers":61,"mean_commits":8.442622950819672,"dds":0.1631067961165048,"last_synced_commit":"3b75f7905337a02f526ee2deb356267fc4e9f9fb"},"previous_names":[],"tags_count":51,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubik%2Fradon","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubik%2Fradon/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubik%2Fradon/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubik%2Fradon/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rubik","download_url":"https://codeload.github.com/rubik/radon/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254044068,"owners_count":22005068,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","code-analysis","python","quality-assurance","static-analysis"],"created_at":"2024-08-01T14:01:19.944Z","updated_at":"2025-05-14T00:08:55.231Z","avatar_url":"https://github.com/rubik.png","language":"Python","funding_links":[],"categories":["Python","Debugging \u0026 Profiling \u0026 Tracing","Code Metrics \u0026 Complexity","Programming Languages"],"sub_categories":["For Python"],"readme":"Radon\n=====\n\n.. image:: https://img.shields.io/coveralls/rubik/radon/master.svg?style=for-the-badge\n    :alt: Coveralls badge\n    :target: https://coveralls.io/r/rubik/radon?branch=master\n\n.. image:: https://img.shields.io/pypi/v/radon.svg?style=for-the-badge\n    :alt: PyPI latest version badge\n    :target: https://pypi.python.org/pypi/radon\n\n.. image:: https://img.shields.io/pypi/l/radon.svg?style=for-the-badge\n    :alt: Radon license\n    :target: https://pypi.python.org/pypi/radon\n\n.. raw::  html\n\n    \u003cp\u003e\u003ca href=\"https://hellogithub.com/repository/bbca7606a6b1412da1312d68ae81d781\" target=\"_blank\"\u003e\u003cimg src=\"https://abroad.hellogithub.com/v1/widgets/recommend.svg?rid=bbca7606a6b1412da1312d68ae81d781\u0026claim_uid=pO5Q0JkFzC8IPr9\u0026theme=dark\" alt=\"Featured｜HelloGitHub\" style=\"width: 250px; height: 54px;\" width=\"250\" height=\"54\" /\u003e\u003c/a\u003e\u003c/p\u003e\n\n----\n\nRadon is a Python tool that computes various metrics from the source code.\nRadon can compute:\n\n* **McCabe's complexity**, i.e. cyclomatic complexity\n* **raw** metrics (these include SLOC, comment lines, blank lines, \u0026c.)\n* **Halstead** metrics (all of them)\n* **Maintainability Index** (the one used in Visual Studio)\n\nRequirements\n------------\n\nRadon will run from **Python 2.7** to **Python 3.12** (except Python versions\nfrom 3.0 to 3.3) with a single code base and without the need of tools like\n2to3 or six. It can also run on **PyPy** without any problems (currently PyPy\n3.5 v7.3.1 is used in tests).\n\nRadon depends on as few packages as possible. Currently only `mando` is\nstrictly required (for the CLI interface). `colorama` is also listed as a\ndependency but if Radon cannot import it, the output simply will not be\ncolored.\n\n**Note**:\n**Python 2.6** was supported until version 1.5.0. Starting from version 2.0, it\nis not supported anymore.\n\nInstallation\n------------\n\nWith Pip:\n\n.. code-block:: sh\n\n    $ pip install radon\n\nIf you want to configure Radon from `pyproject.toml` and you run Python \u003c3.11,\nyou'll need the extra `toml` dependency:\n\n.. code-block:: sh\n\n   $ pip install radon[toml]\n\nOr download the source and run the setup file:\n\n.. code-block:: sh\n\n    $ python setup.py install\n\nUsage\n-----\n\nRadon can be used either from the command line or programmatically.\nDocumentation is at https://radon.readthedocs.org/.\n\nCyclomatic Complexity Example\n-----------------------------\n\nQuick example:\n\n.. code-block:: sh\n\n    $ radon cc sympy/solvers/solvers.py -a -nc\n    sympy/solvers/solvers.py\n        F 346:0 solve - F\n        F 1093:0 _solve - F\n        F 1434:0 _solve_system - F\n        F 2647:0 unrad - F\n        F 110:0 checksol - F\n        F 2238:0 _tsolve - F\n        F 2482:0 _invert - F\n        F 1862:0 solve_linear_system - E\n        F 1781:0 minsolve_linear_system - D\n        F 1636:0 solve_linear - D\n        F 2382:0 nsolve - C\n\n    11 blocks (classes, functions, methods) analyzed.\n    Average complexity: F (61.0)\n\nExplanation:\n\n* ``cc`` is the radon command to compute Cyclomatic Complexity\n* ``-a`` tells radon to calculate the average complexity at the end. Note that\n  the average is computed among the *shown* blocks. If you want the total\n  average, among all the blocks, regardless of what is being shown, you should\n  use ``--total-average``.\n* ``-nc`` tells radon to print only results with a complexity rank of C or\n  worse. Other examples: ``-na`` (from A to F), or ``-nd`` (from D to F).\n* The letter *in front of* the line numbers represents the type of the block\n  (**F** means function, **M** method and **C** class).\n\nActually it's even better: it's got colors!\n\n.. image:: https://cloud.githubusercontent.com/assets/238549/3707477/5793aeaa-1435-11e4-98fb-00e0bd8137f5.png\n    :alt: A screen of Radon's cc command\n\n\n**Note about file encoding**\n\nOn some systems, such as Windows, the default encoding is not UTF-8. If you are\nusing Unicode characters in your Python file and want to analyze it with Radon,\nyou'll have to set the `RADONFILESENCODING` environment variable to `UTF-8`.\n\n\nOn a Continuous Integration server\n----------------------------------\n\nIf you are looking to use `radon` on a CI server you may be better off with\n`xenon \u003chttps://github.com/rubik/xenon\u003e`_. Although still experimental, it will\nfail (that means exiting with a non-zero exit code) when various thresholds are\nsurpassed. `radon` is more of a reporting tool, while `xenon` is a monitoring\none.\n\nIf you are looking for more complete solutions, read the following sections.\n\nCodacy\n++++++++++++\n\n`Codacy \u003chttps://www.codacy.com/\u003e`_ uses Radon `by default \u003chttps://support.codacy.com/hc/en-us/articles/213632009-Engines#other-tools\u003e`_ to calculate metrics from the source code.\n\nCode Climate\n++++++++++++\n\nRadon is available as a `Code Climate Engine \u003chttps://docs.codeclimate.com/docs/list-of-engines\u003e`_.\nTo understand how to add Radon's checks to your Code Climate Platform, head\nover to their documentation:\nhttps://docs.codeclimate.com/v1.0/docs/radon\n\ncoala Analyzer\n++++++++++++++\n\nRadon is also supported in `coala \u003chttp://coala.io/\u003e`_. To add Radon's\nchecks to coala, simply add the ``RadonBear`` to one of the sections in\nyour ``.coafile``.\n\nCodeFactor\n++++++++++++\n\n`CodeFactor \u003chttps://www.codefactor.io/\u003e`_ uses Radon `out-of-the-box \u003chttps://support.codefactor.io/i24-analysis-tools-open-source\u003e`_ to calculate Cyclomatic Complexity.\n\nUsage with Jupyter Notebooks\n----------------------------\n\nRadon can be used with ``.ipynb`` files to inspect code metrics for Python cells. Any ``%`` macros will be ignored in the metrics.\n\n.. note::\n\n   Jupyter Notebook support requires the optional ``nbformat`` package. To install, run ``pip install nbformat``.\n\nTo enable scanning of Jupyter notebooks, add the ``--include-ipynb`` flag.\n\nTo enable reporting of individual cells, add the ``--ipynb-cells`` flag.\n\nQuick example:\n\n.. code-block:: sh\n\n    $ radon raw --include-ipynb --ipynb-cells .\n    example.ipynb\n        LOC: 63\n        LLOC: 37\n        SLOC: 37\n        Comments: 3\n        Single comments: 2\n        Multi: 10\n        Blank: 14\n        - Comment Stats\n            (C % L): 5%\n            (C % S): 8%\n            (C + M % L): 21%\n    example.ipynb:[0]\n        LOC: 0\n        LLOC: 0\n        SLOC: 0\n        Comments: 0\n        Single comments: 0\n        Multi: 0\n        Blank: 0\n        - Comment Stats\n            (C % L): 0%\n            (C % S): 0%\n            (C + M % L): 0%\n    example.ipynb:[1]\n        LOC: 2\n        LLOC: 2\n        SLOC: 2\n        Comments: 0\n        Single comments: 0\n        Multi: 0\n        Blank: 0\n        - Comment Stats\n            (C % L): 0%\n            (C % S): 0%\n            (C + M % L): 0%\n\n\n\nLinks\n-----\n\n* Documentation: https://radon.readthedocs.org\n* PyPI: http://pypi.python.org/pypi/radon\n* Issue Tracker: https://github.com/rubik/radon/issues\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frubik%2Fradon","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frubik%2Fradon","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frubik%2Fradon/lists"}