4 Summary: McCabe checker, plugin for flake8
5 Home-page: https://github.com/pycqa/mccabe
7 Author-email: tarek@ziade.org
8 Maintainer: Ian Stapleton Cordasco
9 Maintainer-email: graffatcolmingov@gmail.com
10 License: Expat license
11 Keywords: flake8 mccabe
13 Classifier: Development Status :: 5 - Production/Stable
14 Classifier: Environment :: Console
15 Classifier: Intended Audience :: Developers
16 Classifier: License :: OSI Approved :: MIT License
17 Classifier: Operating System :: OS Independent
18 Classifier: Programming Language :: Python
19 Classifier: Programming Language :: Python :: 3.6
20 Classifier: Programming Language :: Python :: 3.7
21 Classifier: Programming Language :: Python :: 3.8
22 Classifier: Programming Language :: Python :: 3.9
23 Classifier: Programming Language :: Python :: 3.10
24 Classifier: Topic :: Software Development :: Libraries :: Python Modules
25 Classifier: Topic :: Software Development :: Quality Assurance
26 Requires-Python: >=3.6
29 McCabe complexity checker
30 =========================
32 Ned's script to check McCabe complexity.
34 This module provides a plugin for ``flake8``, the Python code checker.
40 You can install, upgrade, or uninstall ``mccabe`` with these commands::
43 $ pip install --upgrade mccabe
44 $ pip uninstall mccabe
50 The complexity checker can be used directly::
52 $ python -m mccabe --min 5 mccabe.py
53 ("185:1: 'PathGraphingAstVisitor.visitIf'", 5)
54 ("71:1: 'PathGraph.to_dot'", 5)
55 ("245:1: 'McCabeChecker.run'", 5)
57 ("203:1: 'PathGraphingAstVisitor.visitTryExcept'", 5)
58 ("257:1: 'get_code_complexity'", 5)
64 When both ``flake8 2+`` and ``mccabe`` are installed, the plugin is
65 available in ``flake8``::
68 2.0 (pep8: 1.4.2, pyflakes: 0.6.1, mccabe: 0.2)
70 By default the plugin is disabled. Use the ``--max-complexity`` switch to
71 enable it. It will emit a warning if the McCabe complexity of a function is
72 higher than the provided value::
74 $ flake8 --max-complexity 10 coolproject
76 coolproject/mod.py:1204:1: C901 'CoolFactory.prepare' is too complex (14)
78 This feature is quite useful for detecting over-complex code. According to McCabe,
79 anything that goes beyond 10 is too complex.
81 Flake8 has many features that mccabe does not provide. Flake8 allows users to
82 ignore violations reported by plugins with ``# noqa``. Read more about this in
84 <http://flake8.pycqa.org/en/latest/user/violations.html#in-line-ignoring-errors>`__.
85 To silence violations reported by ``mccabe``, place your ``# noqa: C901`` on
86 the function definition line, where the error is reported for (possibly a
93 * Feedback and ideas: http://mail.python.org/mailman/listinfo/code-quality
95 * Cyclomatic complexity: http://en.wikipedia.org/wiki/Cyclomatic_complexity
97 * Ned Batchelder's script:
98 http://nedbatchelder.com/blog/200803/python_code_complexity_microtool.html
100 * McCabe complexity: http://en.wikipedia.org/wiki/Cyclomatic_complexity
109 * Drop support for all versions of Python lower than 3.6
111 * Add support for Python 3.8, 3.9, and 3.10
113 * Fix option declaration for Flake8
118 * Fix signature for ``PathGraphingAstVisitor.default`` to match the signature
124 * Add support for Python 3.6
126 * Fix handling for missing statement types
131 * Report actual column number of violation instead of the start of the line
136 * When opening files ourselves, make sure we always name the file variable
141 * Set default maximum complexity to -1 on the class itself
146 * PyCon 2016 PDX release
148 * Add support for Flake8 3.0
153 * Stop testing on Python 3.2
155 * Add support for async/await keywords on Python 3.5 from PEP 0492
160 * Include ``test_mccabe.py`` in releases.
162 * Always coerce the ``max_complexity`` value from Flake8's entry-point to an
168 * Computation was wrong: the mccabe complexity starts at 1, not 2.
170 * The ``max-complexity`` value is now inclusive. E.g.: if the
171 value is 10 and the reported complexity is 10, then it passes.
179 * Do not require ``setuptools`` in setup.py. It works around an issue
180 with ``pip`` and Python 3.
186 * Rename project to ``mccabe``.
188 * Provide ``flake8.extension`` setuptools entry point.
190 * Read ``max-complexity`` from the configuration file.
192 * Rename argument ``min_complexity`` to ``threshold``.