summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudiu Popa <pcmanticore@gmail.com>2016-07-07 15:05:00 +0100
committerClaudiu Popa <pcmanticore@gmail.com>2016-07-07 15:05:00 +0100
commita7c16df256b73545ef3c64a8757fac2ca7e28433 (patch)
treebb8120079244f0989dd06a06cfea37f9a6a216d4
parent361211ef02834c38a34359634043d43c2cee3a4b (diff)
downloadpylint-git-a7c16df256b73545ef3c64a8757fac2ca7e28433.tar.gz
Document the mccabe extension.
-rw-r--r--ChangeLog3
-rw-r--r--doc/extensions.rst42
-rw-r--r--doc/whatsnew/1.6.rst12
3 files changed, 55 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 4e5f93f79..feaa43df3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -7,6 +7,9 @@ What's New in Pylint 1.6.0?
Release date: 2016-07-03
+ * Added a new extension, `pylint.extensions.mccabe`, for warning
+ about complexity in code.
+
* Deprecate support for --optimize-ast. Part of #975.
* Deprecate support for the HTML output. Part of #975.
diff --git a/doc/extensions.rst b/doc/extensions.rst
index 3b35d21e2..d9b82a8ef 100644
--- a/doc/extensions.rst
+++ b/doc/extensions.rst
@@ -169,3 +169,45 @@ you can use the ``bad-functions`` option::
$ pylint a.py --load-plugins=pylint.extensions.bad_builtin --bad-functions=apply,reduce
...
+
+
+Complexity checker
+------------------
+
+You can now use this plugin for finding complexity issues in your code base.
+
+Activate it through ``pylint --load-plugins=pylint.extensions.mccabe``. It introduces
+a new warning, ``too-complex``, which is emitted when a code block has a complexity
+higher than a preestablished value, which can be controlled through the
+``max-complexity`` option, such as in this example::
+
+ $ cat a.py
+ def f10():
+ """McCabe rating: 11"""
+ myint = 2
+ if myint == 5:
+ return myint
+ elif myint == 6:
+ return myint
+ elif myint == 7:
+ return myint
+ elif myint == 8:
+ return myint
+ elif myint == 9:
+ return myint
+ elif myint == 10:
+ if myint == 8:
+ while True:
+ return True
+ elif myint == 8:
+ with myint:
+ return 8
+ else:
+ if myint == 2:
+ return myint
+ return myint
+ return myint
+ $ pylint a.py --load-plugins=pylint.extensions.mccabe
+ R:1: 'f10' is too complex. The McCabe rating is 11 (too-complex)
+ $ pylint a.py --load-plugins=pylint.extensions.mccabe --max-complexity=50
+ $
diff --git a/doc/whatsnew/1.6.rst b/doc/whatsnew/1.6.rst
index 64ad73ec6..a811c5146 100644
--- a/doc/whatsnew/1.6.rst
+++ b/doc/whatsnew/1.6.rst
@@ -12,8 +12,8 @@ Summary -- Release highlights
Nothing major.
-New checks
-==========
+New checkers
+============
* We added a new recommendation check, ``consider-iterating-dictionary``,
which is emitted when a dictionary is iterated by using ``.keys()``.
@@ -59,6 +59,14 @@ New checks
in both places.
+* We added a new extension plugin, 'pylint.extensions.mccabe', which can be used
+ for warning about the complexity in the code.
+
+ You can enable it as in::
+
+ $ pylint module_or_project --load-plugins=pylint.extensions.mccabe
+
+
New features
============