{"id":13746003,"url":"https://github.com/rubik/xenon","last_synced_at":"2025-05-15T03:08:33.447Z","repository":{"id":14133681,"uuid":"16839110","full_name":"rubik/xenon","owner":"rubik","description":"Monitoring tool based on radon","archived":false,"fork":false,"pushed_at":"2024-10-21T10:27:41.000Z","size":86,"stargazers_count":251,"open_issues_count":6,"forks_count":22,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-05-11T17:36:55.585Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://xenon.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":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-02-14T14:19:20.000Z","updated_at":"2025-05-08T12:16:22.000Z","dependencies_parsed_at":"2024-06-18T12:18:08.303Z","dependency_job_id":"79e17a3f-8d08-4b0d-bad8-64543c2b3ef7","html_url":"https://github.com/rubik/xenon","commit_stats":{"total_commits":115,"total_committers":10,"mean_commits":11.5,"dds":0.07826086956521738,"last_synced_commit":"9d06d21515d9956d4c270aa04b05d4f1751f9516"},"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubik%2Fxenon","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubik%2Fxenon/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubik%2Fxenon/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubik%2Fxenon/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rubik","download_url":"https://codeload.github.com/rubik/xenon/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253805846,"owners_count":21967054,"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":[],"created_at":"2024-08-03T06:00:42.596Z","updated_at":"2025-05-15T03:08:28.434Z","avatar_url":"https://github.com/rubik.png","language":"Python","funding_links":[],"categories":["Code Metrics \u0026 Complexity"],"sub_categories":[],"readme":"xenon\n=====\n\n.. image:: https://img.shields.io/coveralls/rubik/xenon/master.svg\n    :alt: Coveralls badge\n    :target: https://coveralls.io/r/rubik/xenon?branch=master\n\n.. image:: https://img.shields.io/pypi/v/xenon.svg\n    :alt: PyPI latest version badge\n    :target: https://pypi.python.org/pypi/xenon/\n\n.. image:: https://img.shields.io/pypi/format/xenon.svg\n    :alt: Download format\n    :target: http://pythonwheels.com/\n\n.. image:: https://img.shields.io/pypi/l/xenon.svg\n    :alt: Xenon license\n    :target: https://pypi.python.org/pypi/xenon/\n\n\n----\n\nXenon is a monitoring tool based on `Radon \u003chttps://github.com/rubik/radon/\u003e`_.\nIt monitors your code's complexity.  Ideally, Xenon is run every time you\ncommit code. Through command line options, you can set various thresholds for\nthe **complexity** of your code. It will fail (i.e. it will exit with a\nnon-zero exit code) when any of these requirements is not met.\n\nInstallation\n------------\n\nWith Pip:\n\n.. code-block:: sh\n\n   $ pip install xenon\n\nOr download the source and run the setup file (requires setuptools):\n\n.. code-block:: sh\n\n   $ python setup.py install\n\nXenon is tested with Python versions **2.7** and **3.6** to **3.12** as well as\n**PyPy**.\n\nUsage\n-----\n\nTypically you would use Xenon in two scenarios:\n\n1. As a ``git commit`` hook: to make sure that your code never exceeds some\n   complexity values.\n\n2. On a **continuous integration** server: as a part of your build, to keep\n   under control, as above, your code's complexity. See Xenon's\n   `.travis.yml file`_ for an example usage.\n\nThe command line\n++++++++++++++++\n\nEverything boils down to Xenon's command line usage.\nTo control which files are analyzed, you use the options ``-e, --exclude`` and\n``-i, --ignore``. Both accept a comma-separated list of glob patterns. The\nvalue usually needs quoting at the command line, to prevent the shell from\nexpanding the pattern (in case there is only one). Every filename is matched\nagainst the *exclude* patterns. Every directory name is matched against the\n*ignore* patterns.  If any of the patterns matches, Xenon won't even descend\ninto them.\n\nThe actual threshold values are defined through these options:\n\n* ``-a, --max-average``: Threshold for the *average* complexity (across all the\n  codebase).\n* ``-m, --max-modules``: Threshold for *modules* complexity.\n* ``-b, --max-absolute``: *Absolute* threshold for *block* complexity.\n\n\nAll of these options are inclusive.\n\nAn actual example\n+++++++++++++++++\n\n.. code-block:: sh\n\n   $ xenon --max-absolute B --max-modules A --max-average A\n\nor, more succinctly:\n\n.. code-block:: sh\n\n   $ xenon -b B -m A -a A\n\nWith these options Xenon will exit with a non-zero exit code if any of the\nfollowing conditions is met:\n\n* At least one block has a rank higher than ``B`` (i.e. ``C``, ``D``, ``E`` or\n  ``F``).\n* At least one module has a rank higher than ``A``.\n* The average complexity (among all of the analyzed blocks) is ranked with\n  ``B`` or higher.\n\nPre-commit hook\n+++++++++++++++\n\nXenon can be used in combination with `pre-commit \u003chttps://pre-commit.com/\u003e`_ as follows:\n\n.. code-block:: yaml\n\n    # monitor code complexity\n    - repo: https://github.com/rubik/xenon\n      rev: v0.9.0\n      hooks:\n      - id: xenon\n        args: ['--max-absolute=B', '--max-modules=B', '--max-average=A']\n\nNote: due to how options are passed to commands by pre-commit, make sure to\npass values either with an equals sign like in the above example, or by\nsplitting them as separate list items, e.g. ``['--max-absolute', 'B']``.\n\nOther resources\n---------------\n\nFor more information regarding cyclomatic complexity and static analysis in\nPython, please refer to Radon's documentation, the project on which Xenon is\nbased on:\n\n* More on cyclomatic complexity:\n  http://radon.readthedocs.org/en/latest/intro.html\n* More on Radon's ranking:\n  http://radon.readthedocs.org/en/latest/commandline.html#the-cc-command\n\n\n.. _.travis.yml file: https://github.com/rubik/xenon/blob/master/.travis.yml\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frubik%2Fxenon","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frubik%2Fxenon","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frubik%2Fxenon/lists"}