{ "info": { "author": "Ilya Lebedev", "author_email": "melevir@gmail.com", "bugtrack_url": null, "classifiers": [ "Environment :: Console", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Topic :: Software Development :: Documentation", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: Software Development :: Quality Assurance" ], "description": "# congnitive-complexity\n\n[![Build Status](https://travis-ci.org/Melevir/cognitive_complexity.svg?branch=master)](https://travis-ci.org/Melevir/cognitive_complexity)\n[![Maintainability](https://api.codeclimate.com/v1/badges/853d47d353e7becc9f09/maintainability)](https://codeclimate.com/github/Melevir/cognitive_complexity/maintainability)\n[![Test Coverage](https://api.codeclimate.com/v1/badges/853d47d353e7becc9f09/test_coverage)](https://codeclimate.com/github/Melevir/cognitive_complexity/test_coverage)\n[![PyPI version](https://badge.fury.io/py/cognitive-complexity.svg)](https://badge.fury.io/py/cognitive-complexity)\n![PyPI - Python Version](https://img.shields.io/pypi/pyversions/cognitive-complexity)\n\nLibrary to calculate Python functions cognitive complexity via code.\n\n## Installation\n\n```bash\npip install cognitive_complexity\n```\n\n## Usage\n\n```python\n>>> import ast\n\n>>> funcdef = ast.parse(\"\"\"\n... def f(a):\n... return a * f(a - 1) # +1 for recursion\n... \"\"\").body[0]\n\n>>> from cognitive_complexity.api import get_cognitive_complexity\n>>> get_cognitive_complexity(funcdef)\n1\n```\n\n## What is cognitive complexity\n\nHere are some readings about cognitive complexity:\n\n- [Cognitive Complexity, Because Testability != Understandability](https://blog.sonarsource.com/cognitive-complexity-because-testability-understandability);\n- [Cognitive Complexity: A new way of measuring understandability](https://www.sonarsource.com/docs/CognitiveComplexity.pdf),\n white paper by G. Ann Campbell;\n- [Cognitive Complexity: the New Guide to Refactoring for Maintainable Code](https://www.youtube.com/watch?v=5C6AGTlKSjY);\n- [Cognitive Complexity](https://docs.codeclimate.com/docs/cognitive-complexity)\n from CodeClimate docs;\n- [Is Your Code Readable By Humans? Cognitive Complexity Tells You](https://www.tomasvotruba.cz/blog/2018/05/21/is-your-code-readable-by-humans-cognitive-complexity-tells-you/).\n\n## Realization details\n\nThis is not precise realization of original algorithm\nproposed by [G. Ann Campbell](https://github.com/ganncamp),\nbut it gives rather similar results.\nThe algorithm gives complexity points for breaking control flow, nesting,\nrecursion, stacks logic operation etc.\n\n## Contributing\n\nWe would love you to contribute to our project. It's simple:\n\n- Create an issue with bug you found or proposal you have. Wait for\n approve from maintainer.\n- Create a pull request. Make sure all checks are green.\n- Fix review comments if any.\n- Be awesome.\n\nHere are useful tips:\n\n- You can run all checks and tests with `make check`. Please do it\n before TravisCI does.\n- We use [BestDoctor python styleguide](https://github.com/best-doctor/guides/blob/master/guides/python_styleguide.md).\n Sorry, styleguide is available only in Russian for now.\n- We respect [Django CoC](https://www.djangoproject.com/conduct/).\n Make soft, not bullshit.", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/Melevir/cognitive_complexity", "keywords": "flake8", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "cognitive-complexity", "package_url": "https://pypi.org/project/cognitive-complexity/", "platform": "", "project_url": "https://pypi.org/project/cognitive-complexity/", "project_urls": { "Homepage": "https://github.com/Melevir/cognitive_complexity" }, "release_url": "https://pypi.org/project/cognitive-complexity/1.2.0/", "requires_dist": null, "requires_python": ">=3.6", "summary": "Library to calculate Python functions cognitive complexity via code", "version": "1.2.0", "yanked": false, "yanked_reason": null }, "last_serial": 7754422, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "c054b074f45e14fa613099f48cfdeb25", "sha256": "0fd05e459e0bf3aa7d970cdd67ec01f3d645484c2e99ab04e3ec534e5670c787" }, "downloads": -1, "filename": "cognitive_complexity-0.0.1.tar.gz", "has_sig": false, "md5_digest": "c054b074f45e14fa613099f48cfdeb25", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2996, "upload_time": "2019-10-30T16:16:04", "upload_time_iso_8601": "2019-10-30T16:16:04.976392Z", "url": "https://files.pythonhosted.org/packages/67/3f/fd289239dfc4f9dab310c38bbf348fa56719bcfbfa7a68f9e2f8009670dc/cognitive_complexity-0.0.1.tar.gz", "yanked": false, "yanked_reason": null } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "a674ab0025b9abaa56b9539bd1259ce2", "sha256": "f0c8a237abbbb4ba9e50a3011c0a591e26f7bd6500f029a8b3f01ad81e57b299" }, "downloads": -1, "filename": "cognitive_complexity-0.0.2.tar.gz", "has_sig": false, "md5_digest": "a674ab0025b9abaa56b9539bd1259ce2", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 3082, "upload_time": "2019-11-04T03:55:00", "upload_time_iso_8601": "2019-11-04T03:55:00.854827Z", "url": "https://files.pythonhosted.org/packages/bd/c0/7ed02b29c19fcfda05a5a8cbdc79cf18e6ae6d3a290c83f43d351abc8a38/cognitive_complexity-0.0.2.tar.gz", "yanked": false, "yanked_reason": null } ], "0.0.3": [ { "comment_text": "", "digests": { "md5": "abd6c2ff6d61f3fb90262ca516159601", "sha256": "56e17a38608bffbc937a95454b458fbb2a16fdd700196624ff3a40726807696e" }, "downloads": -1, "filename": "cognitive_complexity-0.0.3.tar.gz", "has_sig": false, "md5_digest": "abd6c2ff6d61f3fb90262ca516159601", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 3286, "upload_time": "2019-11-04T04:07:03", "upload_time_iso_8601": "2019-11-04T04:07:03.601693Z", "url": "https://files.pythonhosted.org/packages/9f/a2/7105f2854850ab71125bdf023c654346e363268123a93e691c67567afadd/cognitive_complexity-0.0.3.tar.gz", "yanked": false, "yanked_reason": null } ], "0.0.4": [ { "comment_text": "", "digests": { "md5": "abc4b7be008f16122b0cf990e0966028", "sha256": "8a456bf2871a40c73f33c937ec0b42bc2daaefafa850b3158b0f7a2a91af2b64" }, "downloads": -1, "filename": "cognitive_complexity-0.0.4.tar.gz", "has_sig": false, "md5_digest": "abc4b7be008f16122b0cf990e0966028", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 3299, "upload_time": "2019-11-06T08:40:47", "upload_time_iso_8601": "2019-11-06T08:40:47.292220Z", "url": "https://files.pythonhosted.org/packages/d4/03/db204a4deb84cc1a3d0c8c34e2ed079b636825902c2f86b9d84963afe978/cognitive_complexity-0.0.4.tar.gz", "yanked": false, "yanked_reason": null } ], "1.0.0": [ { "comment_text": "", "digests": { "md5": "0042caa31de41ff10470c3bedd30420c", "sha256": "fa1a2446cac6d7f187ab110181fae1bcc06c26a94f488cdead45ca4775372964" }, "downloads": -1, "filename": "cognitive_complexity-1.0.0.tar.gz", "has_sig": false, "md5_digest": "0042caa31de41ff10470c3bedd30420c", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 4337, "upload_time": "2020-07-06T18:23:16", "upload_time_iso_8601": "2020-07-06T18:23:16.814716Z", "url": "https://files.pythonhosted.org/packages/69/d8/7eca180abcac4ac11cecfe0619e8026b556a8427b89a2e7d74450ce878cc/cognitive_complexity-1.0.0.tar.gz", "yanked": false, "yanked_reason": null } ], "1.1.0": [ { "comment_text": "", "digests": { "md5": "10dff62563a6ba5b0e16cf105065d19e", "sha256": "aeb9b71b48c7374a194c61ee70fb29d22977fe2b34da52a3236168ebf97d1f3a" }, "downloads": -1, "filename": "cognitive_complexity-1.1.0.tar.gz", "has_sig": false, "md5_digest": "10dff62563a6ba5b0e16cf105065d19e", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 4416, "upload_time": "2020-07-11T12:47:36", "upload_time_iso_8601": "2020-07-11T12:47:36.950061Z", "url": "https://files.pythonhosted.org/packages/8c/c3/d76e8de0773a56964754b0e5bea52ee5898ba8f1f824983d7de58d799efc/cognitive_complexity-1.1.0.tar.gz", "yanked": false, "yanked_reason": null } ], "1.2.0": [ { "comment_text": "", "digests": { "md5": "637d3616db0d617396b1490040930905", "sha256": "3c2b433a9e41502932f6aa629e1f57a5e8f145956c54facbb5241a9492af6fb7" }, "downloads": -1, "filename": "cognitive_complexity-1.2.0.tar.gz", "has_sig": false, "md5_digest": "637d3616db0d617396b1490040930905", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 4419, "upload_time": "2020-07-22T05:41:30", "upload_time_iso_8601": "2020-07-22T05:41:30.898464Z", "url": "https://files.pythonhosted.org/packages/df/30/bf0cba61064d284bd0228ad8f6f54e49c6d9f87b2d79a4fe22e32ef55370/cognitive_complexity-1.2.0.tar.gz", "yanked": false, "yanked_reason": null } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "637d3616db0d617396b1490040930905", "sha256": "3c2b433a9e41502932f6aa629e1f57a5e8f145956c54facbb5241a9492af6fb7" }, "downloads": -1, "filename": "cognitive_complexity-1.2.0.tar.gz", "has_sig": false, "md5_digest": "637d3616db0d617396b1490040930905", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 4419, "upload_time": "2020-07-22T05:41:30", "upload_time_iso_8601": "2020-07-22T05:41:30.898464Z", "url": "https://files.pythonhosted.org/packages/df/30/bf0cba61064d284bd0228ad8f6f54e49c6d9f87b2d79a4fe22e32ef55370/cognitive_complexity-1.2.0.tar.gz", "yanked": false, "yanked_reason": null } ], "vulnerabilities": [] }