melevir / flake8-cognitive-complexity Goto Github PK
View Code? Open in Web Editor NEWAn extension for flake8 that validates cognitive functions complexity
License: MIT License
An extension for flake8 that validates cognitive functions complexity
License: MIT License
Computed Cognitive complexity is 12 (I believe correct) for this:
class GildedRose:
def update_quality(self):
for item in self.items: # + 1
if (
item.name != "Aged Brie"
and item.name != "Backstage passes to a TAFKAL80ETC concert"
): # + 2
if item.quality > 0: # + 3
if item.name != "Sulfuras, Hand of Ragnaros": # + 4
item.quality = item.quality - 1
else:
pass
However, 10 is incorrect (less than before???) for following code:
Note complexity should be higher than before since code is the same with an added 'if' condition after the 'else'):
class GildedRose:
def update_quality(self):
for item in self.items: # + 1
if (
item.name != "Aged Brie"
and item.name != "Backstage passes to a TAFKAL80ETC concert"
): # + 2
if item.quality > 0: # + 3
if item.name != "Sulfuras, Hand of Ragnaros": # + 4
item.quality = item.quality - 1
else:
#pass
if item.quality < 50: # + 3
item.quality = item.quality
Hi,
are you ok if I make PR to migrate this project to setup.cfg or pyproject?
Hi!
We're looking to use your plugin, but I noticed this repo is not fully licensed (only MIT marker in setup.py) as opposed to https://github.com/best-doctor/flake8-expression-complexity.
Could you add the MIT license to this repo and make a new release?
Thanks in advance,
David
In addition to the existing cli option, would it be possible to add or document a configuration option?
Hi,
just a simple question: Is this project still alive? I asking, since there are 6 open issues w/ no comments by the maintainer. Also there was no commit since 2 years and no release since 3 years.
Python starts from 3.7? Seems, plugin fails on Python 3.6.8 on line:
from __future__ import annotations
Is it possible to add information about requirements in readme?
/home/andy/PROJECTS/events-registration/.env/bin/flake8 --max-complexity 10 --max-cognitive-complexity=3 /home/andy/PROJECTS/events-registration/backend/backend
Traceback (most recent call last):
File "/home/andy/PROJECTS/events-registration/.env/lib/python3.6/site-packages/flake8/plugins/manager.py", line 158, in load_plugin
self._load()
File "/home/andy/PROJECTS/events-registration/.env/lib/python3.6/site-packages/flake8/plugins/manager.py", line 135, in _load
self._plugin = self.entry_point.load()
File "/home/andy/PROJECTS/events-registration/.env/lib/python3.6/site-packages/entrypoints.py", line 82, in load
mod = import_module(self.module_name)
File "/home/andy/PROJECTS/events-registration/.env/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 674, in exec_module
File "<frozen importlib._bootstrap_external>", line 781, in get_code
File "<frozen importlib._bootstrap_external>", line 741, in source_to_code
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/andy/PROJECTS/events-registration/.env/lib/python3.6/site-packages/flake8_cognitive_complexity/checker.py", line 1
from __future__ import annotations
^
SyntaxError: future feature annotations is not defined
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/andy/PROJECTS/events-registration/.env/bin/flake8", line 8, in <module>
sys.exit(main())
File "/home/andy/PROJECTS/events-registration/.env/lib/python3.6/site-packages/flake8/main/cli.py", line 18, in main
app.run(argv)
File "/home/andy/PROJECTS/events-registration/.env/lib/python3.6/site-packages/flake8/main/application.py", line 393, in run
self._run(argv)
File "/home/andy/PROJECTS/events-registration/.env/lib/python3.6/site-packages/flake8/main/application.py", line 380, in _run
self.initialize(argv)
File "/home/andy/PROJECTS/events-registration/.env/lib/python3.6/site-packages/flake8/main/application.py", line 363, in initialize
self.find_plugins()
File "/home/andy/PROJECTS/events-registration/.env/lib/python3.6/site-packages/flake8/main/application.py", line 199, in find_plugins
self.check_plugins.load_plugins()
File "/home/andy/PROJECTS/events-registration/.env/lib/python3.6/site-packages/flake8/plugins/manager.py", line 410, in load_plugins
plugins = list(self.manager.map(load_plugin))
File "/home/andy/PROJECTS/events-registration/.env/lib/python3.6/site-packages/flake8/plugins/manager.py", line 297, in map
yield func(self.plugins[name], *args, **kwargs)
File "/home/andy/PROJECTS/events-registration/.env/lib/python3.6/site-packages/flake8/plugins/manager.py", line 408, in load_plugin
return plugin.load_plugin()
File "/home/andy/PROJECTS/events-registration/.env/lib/python3.6/site-packages/flake8/plugins/manager.py", line 165, in load_plugin
raise failed_to_load
flake8.exceptions.FailedToLoadPlugin: Flake8 failed to load plugin "CCR" due to future feature annotations is not defined (checker.py, line 1).
Process finished with exit code 1
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.