{"id":532,"library":"mccabe","title":"McCabe Code Complexity Checker","description":"McCabe is a Python library that provides a plugin for flake8, the Python code checker. It's used to analyze the cyclomatic complexity (McCabe complexity) of functions and methods in Python code, helping developers identify potentially over-complex code that might be difficult to understand, test, or maintain. The current version is 0.7.0. Its release cadence is slow, often aligning with updates to supported Python versions.","status":"active","version":"0.7.0","language":"python","source_language":"en","source_url":"https://github.com/pycqa/mccabe","tags":["linter","code quality","complexity","flake8-plugin","static analysis"],"install":[{"cmd":"pip install mccabe flake8","lang":"bash","label":"Install with Flake8"},{"cmd":"pip install mccabe","lang":"bash","label":"Install Standalone"}],"dependencies":[{"reason":"McCabe primarily functions as a plugin for flake8, integrating its complexity checks into the broader linting workflow.","package":"flake8"}],"imports":[{"note":"While this is the internal entry point for flake8 to discover the plugin, end-users typically do not import McCabeChecker directly. Its functionality is accessed via the `flake8` command-line tool.","symbol":"McCabeChecker","correct":"from mccabe import McCabeChecker"}],"quickstart":{"code":"# To analyze a file using mccabe via flake8:\n# 1. Install both libraries\n# pip install mccabe flake8\n\n# 2. Run flake8 with the --max-complexity flag\n# (e.g., to flag functions with complexity > 10)\n# flake8 --max-complexity 10 your_module.py\n\n# Example of a simple Python file to check:\n# your_module.py\ndef high_complexity_function(a, b):\n    if a > 0:\n        if b > 0:\n            print('Both positive')\n        else:\n            print('A positive, B not')\n    elif a < 0:\n        if b < 0:\n            print('Both negative')\n        else:\n            print('A negative, B not')\n    else:\n        print('A is zero')\n\n# To use mccabe as a standalone script (less common):\n# python -m mccabe --min 5 your_module.py","lang":"python","description":"McCabe is most commonly used as a plugin for `flake8`. After installing both `mccabe` and `flake8`, you enable McCabe checks by running `flake8` with the `--max-complexity` option, specifying the threshold at which a warning (C901) should be emitted. Alternatively, it can be run as a standalone script using `python -m mccabe`."},"warnings":[{"fix":"Ensure your project runs on Python 3.6 or newer when using mccabe 0.7.0 or later.","message":"Version 0.7.0 and later dropped support for Python versions older than 3.6.","severity":"breaking","affected_versions":"0.7.0+"},{"fix":"Use the `--max-complexity N` flag when running `flake8` (e.g., `flake8 --max-complexity 10`). Alternatively, configure it in a `setup.cfg`, `.flake8`, or `tox.ini` file under the `[flake8]` section, e.g., `max-complexity = 10`.","message":"When used with flake8, the mccabe plugin is disabled by default. You must explicitly enable it by setting the maximum complexity threshold.","severity":"gotcha","affected_versions":"All versions with flake8 integration"},{"fix":"Place `# noqa: C901` directly on the line where the `def` keyword or the decorator above it appears for the function you want to ignore.","message":"To ignore a specific McCabe complexity violation (C901) for a function, the `# noqa: C901` comment must be placed on the function definition line, not just any line within the function.","severity":"gotcha","affected_versions":"All versions with flake8 integration"}],"env_vars":null,"search_vec":"'0.7.0':58 'align':65 'analysi':80 'analyz':24 'cadenc':61 'checker':4,19 'code':2,18,36,44,73 'complex':3,27,29,43,75 'current':55 'cyclomat':26 'develop':38 'difficult':48 'flake8':15,77 'flake8-plugin':76 'function':31 'help':37 'identifi':39 'librari':9 'linter':72 'maintain':53 'mccabe':1,5,28 'method':33 'might':46 'often':64 'over-complex':41 'plugin':13,78 'potenti':40 'provid':11 'python':8,17,35,70 'qualiti':74 'releas':60 'slow':63 'static':79 'support':69 'test':51 'understand':50 'updat':67 'use':22 'version':56,71","created_at":"2026-03-28T15:17:40.630401+00:00","updated_at":"2026-04-16T16:28:11.164203+00:00","problems":{"verify_error":"error: Failed to parse: `mccabe flake8`\n  Caused by: Expected one of `@`, `(`, `<`, `=`, `>`, `~`, `!`, `;`, found `f`\nmccabe flake8\n       ^"},"ecosystem":"pypi","meta_description":null,"install_score":100,"quickstart_score":80,"quickstart_tag":"verified","pypi_latest":"0.7.0","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/pycqa/mccabe","docs":null,"changelog":null,"pypi":"https://pypi.org/project/mccabe/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["testing"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"install_fail","verified_at":"2026-06-28","last_verified":"2026-06-28","next_check":"2026-07-05","install_tag":"verified"}}