diff options
Diffstat (limited to 'python-flake8-cognitive-complexity.spec')
| -rw-r--r-- | python-flake8-cognitive-complexity.spec | 213 |
1 files changed, 213 insertions, 0 deletions
diff --git a/python-flake8-cognitive-complexity.spec b/python-flake8-cognitive-complexity.spec new file mode 100644 index 0000000..7769b09 --- /dev/null +++ b/python-flake8-cognitive-complexity.spec @@ -0,0 +1,213 @@ +%global _empty_manifest_terminate_build 0 +Name: python-flake8-cognitive-complexity +Version: 0.1.0 +Release: 1 +Summary: An extension for flake8 that validates cognitive functions complexity +License: MIT +URL: https://github.com/Melevir/flake8-cognitive-complexity +Source0: https://mirrors.nju.edu.cn/pypi/web/packages/e7/d6/2bb09fab21521424d5afc836aa0057d15a92f5e738e506a3e3cb035be517/flake8_cognitive_complexity-0.1.0.tar.gz +BuildArch: noarch + + +%description +# flake8-cognitive-complexity + +[](https://travis-ci.org/Melevir/flake8-cognitive-complexity) +[](https://codeclimate.com/github/Melevir/flake8-cognitive-complexity/maintainability) +[](https://codeclimate.com/github/Melevir/flake8-cognitive-complexity/test_coverage) +[](https://badge.fury.io/py/flake8-cognitive-complexity) + + +An extension for flake8 that validates cognitive functions complexity. + +Cognitive complexity is analog of cyclomatic complexity, that measure +how difficult to understand piece of code. Introduced by [G. Ann Campbell](https://github.com/ganncamp) +and currently used by SonarSource, CodeClimate and others. +You can find more readings about cognitive complexity in +[cognitive-complexity readme file](https://github.com/Melevir/cognitive_complexity/blob/master/README.md#what-is-cognitive-complexity). + +Default complexity is 7, can be configured via `--max-cognitive-complexity` option. + +## Installation + +```terminal +pip install flake8-cognitive-complexity +``` + +## Example + +```python +def f(a, b): + if a: + for i in range(b): + if b: + return 1 +``` + +Usage: + +```terminal +$ flake8 --max-cognitive-complexity=3 test.py +text.py:1:5: CCR001 Cognitive complexity is too high (6 > 3) +``` + +Tested on Python 3.7.x and flake8 3.7.8. + +## Error codes + +| Error code | Description | +|:----------:|:----------------------------------------:| +| CCR001 | Cognitive complexity is too high (X > Y) | + +%package -n python3-flake8-cognitive-complexity +Summary: An extension for flake8 that validates cognitive functions complexity +Provides: python-flake8-cognitive-complexity +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: python3-pip +%description -n python3-flake8-cognitive-complexity +# flake8-cognitive-complexity + +[](https://travis-ci.org/Melevir/flake8-cognitive-complexity) +[](https://codeclimate.com/github/Melevir/flake8-cognitive-complexity/maintainability) +[](https://codeclimate.com/github/Melevir/flake8-cognitive-complexity/test_coverage) +[](https://badge.fury.io/py/flake8-cognitive-complexity) + + +An extension for flake8 that validates cognitive functions complexity. + +Cognitive complexity is analog of cyclomatic complexity, that measure +how difficult to understand piece of code. Introduced by [G. Ann Campbell](https://github.com/ganncamp) +and currently used by SonarSource, CodeClimate and others. +You can find more readings about cognitive complexity in +[cognitive-complexity readme file](https://github.com/Melevir/cognitive_complexity/blob/master/README.md#what-is-cognitive-complexity). + +Default complexity is 7, can be configured via `--max-cognitive-complexity` option. + +## Installation + +```terminal +pip install flake8-cognitive-complexity +``` + +## Example + +```python +def f(a, b): + if a: + for i in range(b): + if b: + return 1 +``` + +Usage: + +```terminal +$ flake8 --max-cognitive-complexity=3 test.py +text.py:1:5: CCR001 Cognitive complexity is too high (6 > 3) +``` + +Tested on Python 3.7.x and flake8 3.7.8. + +## Error codes + +| Error code | Description | +|:----------:|:----------------------------------------:| +| CCR001 | Cognitive complexity is too high (X > Y) | + +%package help +Summary: Development documents and examples for flake8-cognitive-complexity +Provides: python3-flake8-cognitive-complexity-doc +%description help +# flake8-cognitive-complexity + +[](https://travis-ci.org/Melevir/flake8-cognitive-complexity) +[](https://codeclimate.com/github/Melevir/flake8-cognitive-complexity/maintainability) +[](https://codeclimate.com/github/Melevir/flake8-cognitive-complexity/test_coverage) +[](https://badge.fury.io/py/flake8-cognitive-complexity) + + +An extension for flake8 that validates cognitive functions complexity. + +Cognitive complexity is analog of cyclomatic complexity, that measure +how difficult to understand piece of code. Introduced by [G. Ann Campbell](https://github.com/ganncamp) +and currently used by SonarSource, CodeClimate and others. +You can find more readings about cognitive complexity in +[cognitive-complexity readme file](https://github.com/Melevir/cognitive_complexity/blob/master/README.md#what-is-cognitive-complexity). + +Default complexity is 7, can be configured via `--max-cognitive-complexity` option. + +## Installation + +```terminal +pip install flake8-cognitive-complexity +``` + +## Example + +```python +def f(a, b): + if a: + for i in range(b): + if b: + return 1 +``` + +Usage: + +```terminal +$ flake8 --max-cognitive-complexity=3 test.py +text.py:1:5: CCR001 Cognitive complexity is too high (6 > 3) +``` + +Tested on Python 3.7.x and flake8 3.7.8. + +## Error codes + +| Error code | Description | +|:----------:|:----------------------------------------:| +| CCR001 | Cognitive complexity is too high (X > Y) | + +%prep +%autosetup -n flake8-cognitive-complexity-0.1.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-flake8-cognitive-complexity -f filelist.lst +%dir %{python3_sitelib}/* + +%files help -f doclist.lst +%{_docdir}/* + +%changelog +* Tue Apr 11 2023 Python_Bot <Python_Bot@openeuler.org> - 0.1.0-1 +- Package Spec generated |
