Development of an internal social media platform with personalised dashboards for students
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

DESCRIPTION.rst 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. McCabe complexity checker
  2. =========================
  3. Ned's script to check McCabe complexity.
  4. This module provides a plugin for ``flake8``, the Python code checker.
  5. Installation
  6. ------------
  7. You can install, upgrade, uninstall ``mccabe`` with these commands::
  8. $ pip install mccabe
  9. $ pip install --upgrade mccabe
  10. $ pip uninstall mccabe
  11. Standalone script
  12. -----------------
  13. The complexity checker can be used directly::
  14. $ python -m mccabe --min 5 mccabe.py
  15. ("185:1: 'PathGraphingAstVisitor.visitIf'", 5)
  16. ("71:1: 'PathGraph.to_dot'", 5)
  17. ("245:1: 'McCabeChecker.run'", 5)
  18. ("283:1: 'main'", 7)
  19. ("203:1: 'PathGraphingAstVisitor.visitTryExcept'", 5)
  20. ("257:1: 'get_code_complexity'", 5)
  21. Plugin for Flake8
  22. -----------------
  23. When both ``flake8 2.0`` and ``mccabe`` are installed, the plugin is
  24. available in ``flake8``::
  25. $ flake8 --version
  26. 2.0 (pep8: 1.4.2, pyflakes: 0.6.1, mccabe: 0.2)
  27. By default the plugin is disabled. Use the ``--max-complexity`` switch to
  28. enable it. It will emit a warning if the McCabe complexity of a function is
  29. higher that the value::
  30. $ flake8 --max-complexity 10 coolproject
  31. ...
  32. coolproject/mod.py:1204:1: C901 'CoolFactory.prepare' is too complex (14)
  33. This feature is quite useful to detect over-complex code. According to McCabe,
  34. anything that goes beyond 10 is too complex.
  35. Links
  36. -----
  37. * Feedback and ideas: http://mail.python.org/mailman/listinfo/code-quality
  38. * Cyclomatic complexity: http://en.wikipedia.org/wiki/Cyclomatic_complexity.
  39. * Ned Batchelder's script:
  40. http://nedbatchelder.com/blog/200803/python_code_complexity_microtool.html
  41. Changes
  42. -------
  43. 0.6.1 - 2017-01-26
  44. ``````````````````
  45. * Fix signature for ``PathGraphingAstVisitor.default`` to match the signature
  46. for ``ASTVisitor``
  47. 0.6.0 - 2017-01-23
  48. ``````````````````
  49. * Add support for Python 3.6
  50. * Fix handling for missing statement types
  51. 0.5.3 - 2016-12-14
  52. ``````````````````
  53. * Report actual column number of violation instead of the start of the line
  54. 0.5.2 - 2016-07-31
  55. ``````````````````
  56. * When opening files ourselves, make sure we always name the file variable
  57. 0.5.1 - 2016-07-28
  58. ``````````````````
  59. * Set default maximum complexity to -1 on the class itself
  60. 0.5.0 - 2016-05-30
  61. ``````````````````
  62. * PyCon 2016 PDX release
  63. * Add support for Flake8 3.0
  64. 0.4.0 - 2016-01-27
  65. ``````````````````
  66. * Stop testing on Python 3.2
  67. * Add support for async/await keywords on Python 3.5 from PEP 0492
  68. 0.3.1 - 2015-06-14
  69. ``````````````````
  70. * Include ``test_mccabe.py`` in releases.
  71. * Always coerce the ``max_complexity`` value from Flake8's entry-point to an
  72. integer.
  73. 0.3 - 2014-12-17
  74. ````````````````
  75. * Computation was wrong: the mccabe complexity starts at 1, not 2.
  76. * The ``max-complexity`` value is now inclusive. E.g.: if the
  77. value is 10 and the reported complexity is 10, then it passes.
  78. * Add tests.
  79. 0.2.1 - 2013-04-03
  80. ``````````````````
  81. * Do not require ``setuptools`` in setup.py. It works around an issue
  82. with ``pip`` and Python 3.
  83. 0.2 - 2013-02-22
  84. ````````````````
  85. * Rename project to ``mccabe``.
  86. * Provide ``flake8.extension`` setuptools entry point.
  87. * Read ``max-complexity`` from the configuration file.
  88. * Rename argument ``min_complexity`` to ``threshold``.
  89. 0.1 - 2013-02-11
  90. ````````````````
  91. * First release