{"id":18468742,"url":"https://github.com/pycqa/mccabe","last_synced_at":"2025-12-11T21:04:30.633Z","repository":{"id":7045095,"uuid":"8323509","full_name":"PyCQA/mccabe","owner":"PyCQA","description":"McCabe complexity checker for Python","archived":false,"fork":false,"pushed_at":"2024-08-09T08:37:27.000Z","size":114,"stargazers_count":655,"open_issues_count":9,"forks_count":60,"subscribers_count":15,"default_branch":"master","last_synced_at":"2025-05-14T09:07:22.438Z","etag":null,"topics":["complexity","complexity-analysis","flake8","flake8-extensions","flake8-plugin","linter-flake8","linter-plugin","mccabe","python"],"latest_commit_sha":null,"homepage":"pypi.python.org/pypi/mccabe","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"mxcl/PromiseKit","license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PyCQA.png","metadata":{"files":{"readme":"README.rst","changelog":null,"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":"2013-02-20T22:19:04.000Z","updated_at":"2025-05-11T16:25:38.000Z","dependencies_parsed_at":"2023-01-13T14:14:44.065Z","dependency_job_id":"63e27586-f506-400c-8808-a3c0662445f1","html_url":"https://github.com/PyCQA/mccabe","commit_stats":{"total_commits":110,"total_committers":26,"mean_commits":4.230769230769231,"dds":0.6818181818181819,"last_synced_commit":"60cf21c21f8e5880f9907561c53732e80d1be400"},"previous_names":["flintwork/mccabe"],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PyCQA%2Fmccabe","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PyCQA%2Fmccabe/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PyCQA%2Fmccabe/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PyCQA%2Fmccabe/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PyCQA","download_url":"https://codeload.github.com/PyCQA/mccabe/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254110374,"owners_count":22016391,"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":["complexity","complexity-analysis","flake8","flake8-extensions","flake8-plugin","linter-flake8","linter-plugin","mccabe","python"],"created_at":"2024-11-06T10:08:03.264Z","updated_at":"2025-12-11T21:04:25.578Z","avatar_url":"https://github.com/PyCQA.png","language":"Python","readme":"McCabe complexity checker\n=========================\n\nNed's script to check McCabe complexity.\n\nThis module provides a plugin for ``flake8``, the Python code checker.\n\n\nInstallation\n------------\n\nYou can install, upgrade, or uninstall ``mccabe`` with these commands::\n\n  $ pip install mccabe\n  $ pip install --upgrade mccabe\n  $ pip uninstall mccabe\n\n\nStandalone script\n-----------------\n\nThe complexity checker can be used directly::\n\n  $ python -m mccabe --min 5 mccabe.py\n  (\"185:1: 'PathGraphingAstVisitor.visitIf'\", 5)\n  (\"71:1: 'PathGraph.to_dot'\", 5)\n  (\"245:1: 'McCabeChecker.run'\", 5)\n  (\"283:1: 'main'\", 7)\n  (\"203:1: 'PathGraphingAstVisitor.visitTryExcept'\", 5)\n  (\"257:1: 'get_code_complexity'\", 5)\n\n\nPlugin for Flake8\n-----------------\n\nWhen both ``flake8 2+`` and ``mccabe`` are installed, the plugin is\navailable in ``flake8``::\n\n  $ flake8 --version\n  2.0 (pep8: 1.4.2, pyflakes: 0.6.1, mccabe: 0.2)\n\nBy default the plugin is disabled.  Use the ``--max-complexity`` switch to\nenable it.  It will emit a warning if the McCabe complexity of a function is\nhigher than the provided value::\n\n    $ flake8 --max-complexity 10 coolproject\n    ...\n    coolproject/mod.py:1204:1: C901 'CoolFactory.prepare' is too complex (14)\n\nThis feature is quite useful for detecting over-complex code.  According to McCabe,\nanything that goes beyond 10 is too complex.\n\nFlake8 has many features that mccabe does not provide. Flake8 allows users to\nignore violations reported by plugins with ``# noqa``. Read more about this in\n`their documentation\n\u003chttp://flake8.pycqa.org/en/latest/user/violations.html#in-line-ignoring-errors\u003e`__.\nTo silence violations reported by ``mccabe``, place your ``# noqa: C901`` on\nthe function definition line, where the error is reported for (possibly a\ndecorator).\n\n\nLinks\n-----\n\n* Feedback and ideas: http://mail.python.org/mailman/listinfo/code-quality\n\n* Cyclomatic complexity: http://en.wikipedia.org/wiki/Cyclomatic_complexity\n\n* Ned Batchelder's script:\n  http://nedbatchelder.com/blog/200803/python_code_complexity_microtool.html\n\n* McCabe complexity: http://en.wikipedia.org/wiki/Cyclomatic_complexity\n\n\nChanges\n-------\n\n0.7.0 - 2022-01-23\n``````````````````\n\n* Drop support for all versions of Python lower than 3.6\n\n* Add support for Python 3.8, 3.9, and 3.10\n\n* Fix option declaration for Flake8\n\n0.6.1 - 2017-01-26\n``````````````````\n\n* Fix signature for ``PathGraphingAstVisitor.default`` to match the signature\n  for ``ASTVisitor``\n\n0.6.0 - 2017-01-23\n``````````````````\n\n* Add support for Python 3.6\n\n* Fix handling for missing statement types\n\n0.5.3 - 2016-12-14\n``````````````````\n\n* Report actual column number of violation instead of the start of the line\n\n0.5.2 - 2016-07-31\n``````````````````\n\n* When opening files ourselves, make sure we always name the file variable\n\n0.5.1 - 2016-07-28\n``````````````````\n\n* Set default maximum complexity to -1 on the class itself\n\n0.5.0 - 2016-05-30\n``````````````````\n\n* PyCon 2016 PDX release\n\n* Add support for Flake8 3.0\n\n0.4.0 - 2016-01-27\n``````````````````\n\n* Stop testing on Python 3.2\n\n* Add support for async/await keywords on Python 3.5 from PEP 0492\n\n0.3.1 - 2015-06-14\n``````````````````\n\n* Include ``test_mccabe.py`` in releases.\n\n* Always coerce the ``max_complexity`` value from Flake8's entry-point to an\n  integer.\n\n0.3 - 2014-12-17\n````````````````\n\n* Computation was wrong: the mccabe complexity starts at 1, not 2.\n\n* The ``max-complexity`` value is now inclusive.  E.g.: if the\n  value is 10 and the reported complexity is 10, then it passes.\n\n* Add tests.\n\n\n0.2.1 - 2013-04-03\n``````````````````\n\n* Do not require ``setuptools`` in setup.py.  It works around an issue\n  with ``pip`` and Python 3.\n\n\n0.2 - 2013-02-22\n````````````````\n\n* Rename project to ``mccabe``.\n\n* Provide ``flake8.extension`` setuptools entry point.\n\n* Read ``max-complexity`` from the configuration file.\n\n* Rename argument ``min_complexity`` to ``threshold``.\n\n\n0.1 - 2013-02-11\n````````````````\n* First release\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpycqa%2Fmccabe","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpycqa%2Fmccabe","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpycqa%2Fmccabe/lists"}