%global _empty_manifest_terminate_build 0 Name: python-cognitive-complexity Version: 1.3.0 Release: 1 Summary: Library to calculate Python functions cognitive complexity via code License: MIT URL: https://github.com/Melevir/cognitive_complexity Source0: https://mirrors.nju.edu.cn/pypi/web/packages/6a/ff/3cd46792fcbf742458083527407bc336efe382b168595583a06c70bf8e54/cognitive_complexity-1.3.0.tar.gz BuildArch: noarch %description # congnitive-complexity [![Build Status](https://travis-ci.org/Melevir/cognitive_complexity.svg?branch=master)](https://travis-ci.org/Melevir/cognitive_complexity) [![Maintainability](https://api.codeclimate.com/v1/badges/853d47d353e7becc9f09/maintainability)](https://codeclimate.com/github/Melevir/cognitive_complexity/maintainability) [![Test Coverage](https://api.codeclimate.com/v1/badges/853d47d353e7becc9f09/test_coverage)](https://codeclimate.com/github/Melevir/cognitive_complexity/test_coverage) [![PyPI version](https://badge.fury.io/py/cognitive-complexity.svg)](https://badge.fury.io/py/cognitive-complexity) ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/cognitive-complexity) Library to calculate Python functions cognitive complexity via code. ## Installation ```bash pip install cognitive_complexity ``` ## Usage ```python >>> import ast >>> funcdef = ast.parse(""" ... def f(a): ... return a * f(a - 1) # +1 for recursion ... """).body[0] >>> from cognitive_complexity.api import get_cognitive_complexity >>> get_cognitive_complexity(funcdef) 1 ``` ### Flake8-Cognitive-Complexity Extension Perhaps the most common way to use this library (especially if you are already using the [Flake8 linter](https://flake8.pycqa.org/en/latest/)) is to use the [flake8-cognitive-complexity extension](https://github.com/Melevir/flake8-cognitive-complexity). If you run Flake8 with this extension installed, Flake8 will let you know if your code is too complex. For more details and documentation, visit the [flake8-cognitive-complexity extension repository](https://github.com/Melevir/flake8-cognitive-complexity). ## What is cognitive complexity Here are some readings about cognitive complexity: - [Cognitive Complexity, Because Testability != Understandability](https://blog.sonarsource.com/cognitive-complexity-because-testability-understandability); - [Cognitive Complexity: A new way of measuring understandability](https://www.sonarsource.com/docs/CognitiveComplexity.pdf), white paper by G. Ann Campbell; - [Cognitive Complexity: the New Guide to Refactoring for Maintainable Code](https://www.youtube.com/watch?v=5C6AGTlKSjY); - [Cognitive Complexity](https://docs.codeclimate.com/docs/cognitive-complexity) from CodeClimate docs; - [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/). ## Realization details This is not precise realization of original algorithm proposed by [G. Ann Campbell](https://github.com/ganncamp), but it gives rather similar results. The algorithm gives complexity points for breaking control flow, nesting, recursion, stacks logic operation etc. ## Contributing We would love you to contribute to our project. It's simple: - Create an issue with bug you found or proposal you have. Wait for approve from maintainer. - Create a pull request. Make sure all checks are green. - Fix review comments if any. - Be awesome. Here are useful tips: - You can run all checks and tests with `make check`. Please do it before TravisCI does. - We use [BestDoctor python styleguide](https://github.com/best-doctor/guides/blob/master/guides/python_styleguide.md). Sorry, styleguide is available only in Russian for now. - We respect [Django CoC](https://www.djangoproject.com/conduct/). Make soft, not bullshit. %package -n python3-cognitive-complexity Summary: Library to calculate Python functions cognitive complexity via code Provides: python-cognitive-complexity BuildRequires: python3-devel BuildRequires: python3-setuptools BuildRequires: python3-pip %description -n python3-cognitive-complexity # congnitive-complexity [![Build Status](https://travis-ci.org/Melevir/cognitive_complexity.svg?branch=master)](https://travis-ci.org/Melevir/cognitive_complexity) [![Maintainability](https://api.codeclimate.com/v1/badges/853d47d353e7becc9f09/maintainability)](https://codeclimate.com/github/Melevir/cognitive_complexity/maintainability) [![Test Coverage](https://api.codeclimate.com/v1/badges/853d47d353e7becc9f09/test_coverage)](https://codeclimate.com/github/Melevir/cognitive_complexity/test_coverage) [![PyPI version](https://badge.fury.io/py/cognitive-complexity.svg)](https://badge.fury.io/py/cognitive-complexity) ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/cognitive-complexity) Library to calculate Python functions cognitive complexity via code. ## Installation ```bash pip install cognitive_complexity ``` ## Usage ```python >>> import ast >>> funcdef = ast.parse(""" ... def f(a): ... return a * f(a - 1) # +1 for recursion ... """).body[0] >>> from cognitive_complexity.api import get_cognitive_complexity >>> get_cognitive_complexity(funcdef) 1 ``` ### Flake8-Cognitive-Complexity Extension Perhaps the most common way to use this library (especially if you are already using the [Flake8 linter](https://flake8.pycqa.org/en/latest/)) is to use the [flake8-cognitive-complexity extension](https://github.com/Melevir/flake8-cognitive-complexity). If you run Flake8 with this extension installed, Flake8 will let you know if your code is too complex. For more details and documentation, visit the [flake8-cognitive-complexity extension repository](https://github.com/Melevir/flake8-cognitive-complexity). ## What is cognitive complexity Here are some readings about cognitive complexity: - [Cognitive Complexity, Because Testability != Understandability](https://blog.sonarsource.com/cognitive-complexity-because-testability-understandability); - [Cognitive Complexity: A new way of measuring understandability](https://www.sonarsource.com/docs/CognitiveComplexity.pdf), white paper by G. Ann Campbell; - [Cognitive Complexity: the New Guide to Refactoring for Maintainable Code](https://www.youtube.com/watch?v=5C6AGTlKSjY); - [Cognitive Complexity](https://docs.codeclimate.com/docs/cognitive-complexity) from CodeClimate docs; - [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/). ## Realization details This is not precise realization of original algorithm proposed by [G. Ann Campbell](https://github.com/ganncamp), but it gives rather similar results. The algorithm gives complexity points for breaking control flow, nesting, recursion, stacks logic operation etc. ## Contributing We would love you to contribute to our project. It's simple: - Create an issue with bug you found or proposal you have. Wait for approve from maintainer. - Create a pull request. Make sure all checks are green. - Fix review comments if any. - Be awesome. Here are useful tips: - You can run all checks and tests with `make check`. Please do it before TravisCI does. - We use [BestDoctor python styleguide](https://github.com/best-doctor/guides/blob/master/guides/python_styleguide.md). Sorry, styleguide is available only in Russian for now. - We respect [Django CoC](https://www.djangoproject.com/conduct/). Make soft, not bullshit. %package help Summary: Development documents and examples for cognitive-complexity Provides: python3-cognitive-complexity-doc %description help # congnitive-complexity [![Build Status](https://travis-ci.org/Melevir/cognitive_complexity.svg?branch=master)](https://travis-ci.org/Melevir/cognitive_complexity) [![Maintainability](https://api.codeclimate.com/v1/badges/853d47d353e7becc9f09/maintainability)](https://codeclimate.com/github/Melevir/cognitive_complexity/maintainability) [![Test Coverage](https://api.codeclimate.com/v1/badges/853d47d353e7becc9f09/test_coverage)](https://codeclimate.com/github/Melevir/cognitive_complexity/test_coverage) [![PyPI version](https://badge.fury.io/py/cognitive-complexity.svg)](https://badge.fury.io/py/cognitive-complexity) ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/cognitive-complexity) Library to calculate Python functions cognitive complexity via code. ## Installation ```bash pip install cognitive_complexity ``` ## Usage ```python >>> import ast >>> funcdef = ast.parse(""" ... def f(a): ... return a * f(a - 1) # +1 for recursion ... """).body[0] >>> from cognitive_complexity.api import get_cognitive_complexity >>> get_cognitive_complexity(funcdef) 1 ``` ### Flake8-Cognitive-Complexity Extension Perhaps the most common way to use this library (especially if you are already using the [Flake8 linter](https://flake8.pycqa.org/en/latest/)) is to use the [flake8-cognitive-complexity extension](https://github.com/Melevir/flake8-cognitive-complexity). If you run Flake8 with this extension installed, Flake8 will let you know if your code is too complex. For more details and documentation, visit the [flake8-cognitive-complexity extension repository](https://github.com/Melevir/flake8-cognitive-complexity). ## What is cognitive complexity Here are some readings about cognitive complexity: - [Cognitive Complexity, Because Testability != Understandability](https://blog.sonarsource.com/cognitive-complexity-because-testability-understandability); - [Cognitive Complexity: A new way of measuring understandability](https://www.sonarsource.com/docs/CognitiveComplexity.pdf), white paper by G. Ann Campbell; - [Cognitive Complexity: the New Guide to Refactoring for Maintainable Code](https://www.youtube.com/watch?v=5C6AGTlKSjY); - [Cognitive Complexity](https://docs.codeclimate.com/docs/cognitive-complexity) from CodeClimate docs; - [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/). ## Realization details This is not precise realization of original algorithm proposed by [G. Ann Campbell](https://github.com/ganncamp), but it gives rather similar results. The algorithm gives complexity points for breaking control flow, nesting, recursion, stacks logic operation etc. ## Contributing We would love you to contribute to our project. It's simple: - Create an issue with bug you found or proposal you have. Wait for approve from maintainer. - Create a pull request. Make sure all checks are green. - Fix review comments if any. - Be awesome. Here are useful tips: - You can run all checks and tests with `make check`. Please do it before TravisCI does. - We use [BestDoctor python styleguide](https://github.com/best-doctor/guides/blob/master/guides/python_styleguide.md). Sorry, styleguide is available only in Russian for now. - We respect [Django CoC](https://www.djangoproject.com/conduct/). Make soft, not bullshit. %prep %autosetup -n cognitive-complexity-1.3.0 %build %py3_build %install %py3_install install -d -m755 %{buildroot}/%{_pkgdocdir} if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi pushd %{buildroot} if [ -d usr/lib ]; then find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst fi if [ -d usr/lib64 ]; then find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst fi if [ -d usr/bin ]; then find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst fi if [ -d usr/sbin ]; then find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst fi touch doclist.lst if [ -d usr/share/man ]; then find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst fi popd mv %{buildroot}/filelist.lst . mv %{buildroot}/doclist.lst . %files -n python3-cognitive-complexity -f filelist.lst %dir %{python3_sitelib}/* %files help -f doclist.lst %{_docdir}/* %changelog * Tue Apr 11 2023 Python_Bot - 1.3.0-1 - Package Spec generated