astral-sh / astral-sh/ruff

Make the mccabe checker ignore the case of a single top-level elif chain or match statement

Open
#3,597 5 comments 0 reactions 0 assignees View on GitHub
needs-decision rule
Dominant language
Rust
Stars
49.6k
Forks
2.4k
Avg merge
2d 1h
Merged PRs (30d)
458

Description

This is a somewhat common edge case where there shouldn't be a need to use noqa comments. Non-looping functions with a nesting depth of 1 should be excluded from the mccabe checker, or there should be a separate error code for this particular kind of pattern if you want to lint or ignore it separately, such as "elif chain exceeds mccabe complexity".

Incidentally, while discussing code complexity KPIs, being able to set a maximum allowed nesting depth would be nice.

Contributor guide

Open the contributing guide

Research direction

Start by locating Ruff's mccabe checker and its handling of top-level elif chains and match statements. Determine how non-looping functions with nesting depth 1 are currently reported, then verify the chosen behavior for ignoring them or assigning a separate error code; the requested maximum nesting-depth setting is additional scope.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, rust
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.