Skip to content

Forbid len(...) > 0 expressions #633

@sobolevn

Description

@sobolevn

Rule request

Thesis

We all know that if len(x) > 0 is an anti-pattern.
It should be replaced with if x or if not x: for if len(x) == 0 or if len(x) <= 0

So, the rule is when we find len(...) and its compare with zero or >= 1, then we raise a violation.

Reasoning

That's simply not pythonic, it is also shorter to write correctly.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions