Skip to content

New check: Ban while-loops #4367

@nickdrozd

Description

@nickdrozd

The while operator is needed to make Python Turing-complete. But
unless you are implementing something like a theorem prover or an
interpreter, there is very little call to use a true while loop. In
practically every case a while loop can be converted to a for loop
with improved clarity. Seriously, how many web apps have a need for
unbounded computation?

One exception to this is the use of while loops at the tippity-top
of applications as a main execution loop. But other than that, genuine
need for while is rare.

I would like to see a check that simply flags any use of while. This
is an opinionated check, so make it an extension.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Good first issueFriendly and approachable by new contributorsHelp wanted 🙏Outside help would be appreciated, good for new contributorsProposal 📨

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions