
Security News
TC39 Advances 11 Proposals for Math Precision, Binary APIs, and More
TC39 advances 11 JavaScript proposals, with two moving to Stage 4, bringing better math, binary APIs, and more features one step closer to the ECMAScript spec.
flake8-expression-complexity
Advanced tools
An extension for flake8 that validates expression complexity.
Splits code into expression and scores each according to how much one is complicated. Fires an error on each expression more complex than theshold.
Default complexity is 7, can be configured via --max-expression-complexity
option.
Since Django ORM queries can produce long and readable expressions,
checker can skip them. To enable this behaviour,
use --ignore-django-orm-queries-complexity
option.
pip install flake8-expression-complexity
if (
(user and user.is_authorized)
and user.subscriptions.filter(start_date__lt=today, end_date__gt=today).exists()
and (
user.total_credits_added
- Check.objects.filter(user=user).aggregate(Sum('price'))['check__sum']
)
and UserAction.objects.filter(user=user).last().datetime > today - datetime.timedelta(days=10)
):
...
Usage:
$ flake8 --max-expression-complexity=3 test.py
text.py:2:5: ECE001 Expression is too complex (7.0 > 3)
Error code | Description |
---|---|
ECE001 | Expression is too complex (X > Y) |
We would love you to contribute to our project. It's simple:
Here are useful tips:
make check
.
Please do it before TravisCI does.FAQs
A flake8 extension that checks expressions complexity
We found that flake8-expression-complexity demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
TC39 advances 11 JavaScript proposals, with two moving to Stage 4, bringing better math, binary APIs, and more features one step closer to the ECMAScript spec.
Research
/Security News
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
Product
Customize license detection with Socket’s new license overlays: gain control, reduce noise, and handle edge cases with precision.