Skip to content Aller au contenu

Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

syntax.parenthetical-depth

Experimental in v0.2.x. Off by default; opt in via --experimental syntax.parenthetical-depth or [experimental] enabled = ["syntax.parenthetical-depth"] in lucid-lint.toml. Flips to Stable at the v0.3 cut as part of the F-experimental-rule-status cohort flip. See Conditions for the adhd and general condition tags.

What it flags

A sentence whose maximum balanced-bracket nesting depth across () and [] reaches the profile threshold. Stacked parentheticals force the reader to track multiple suspended frames at once — a recognised “hard sentence” signal in the plainlanguage.gov and Hemingway editing traditions, and a particular cost for ADHD readers, who carry the working-memory load first.

The rule complements structure.excessive-commas, which already discounts flat (A, B, C) enumerations at depth 1. This rule fires only at depth 2 or more, so the two rules are mechanically orthogonal: one flat parenthesised list never trips this rule.

At a glance

Categorysyntax
Default severitywarning
Default weight1
Statusexperimental (v0.2.x) → stable at v0.3 cut
Condition tagsadhd, general (gated; runs only under matching --conditions)
LanguagesEN · FR (language-agnostic — bracket families are the same in both)
Sourcesrc/rules/syntax/parenthetical_depth.rs

Detection

For each sentence, the rule walks the post-flattening paragraph text (so fenced code blocks are already excluded by the parser) and tracks a single running depth counter.

Algorithm

  1. Walk the sentence one character at a time.
  2. Increment depth on ( or [; decrement on ) or ].
  3. A close that would push depth below zero resets depth to zero — the rule fails open on unbalanced markup, mirroring the posture of the parenthesised_list_comma_count helper used by structure.excessive-commas.
  4. Track the maximum depth reached and the position of the opener that achieved it.
  5. Emit one diagnostic per sentence when max_depth ≥ the profile threshold, anchored at the deepest opener.

Skips (false-positive guards)

  • Code spans / fenced code blocks: already excluded upstream by the Markdown parser.
  • Unbalanced brackets: the depth-floor reset prevents stray closes from inflating later depths.

Deferred (not in MVP)

Em-dash pairs (— … —), curly braces ({}), and comma-flanked appositives are intentionally out of scope at v0.2.x. Em-dash pair detection is fragile (en/em-dash confusion, hyphen ambiguity) and would smuggle scope back in.

Parameters

KeyTypedev-docpublicfalc
max_depthint432

max_depth is the inclusive nesting depth at which the rule fires. A sentence whose deepest bracket frame is one level shallower stays silent.

Tune via lucid-lint.toml:

[rules."syntax.parenthetical-depth"]
max_depth = 3

Examples

English

Before (flagged):

The migration tool (which now supports rollbacks (see --reverse, added in 0.4.2 [tracked in #312])) is opt-in.

What lucid-lint check --profile public --experimental syntax.parenthetical-depth --conditions adhd reports:

warning input.md:1:21 Nested parentheticals reach depth 3; readers must hold 3 suspended thoughts to reach the close. Split the sentence or unnest the inner bracket (plainlanguage.gov, Hemingway). [syntax.parenthetical-depth]

After (your rewrite):

The migration tool is opt-in. It now supports rollbacks via --reverse, added in 0.4.2 (tracked in #312).

The two top-level parentheticals are gone; the remaining one sits flat at depth 1. A reader no longer has to push three suspended thoughts on the stack to reach the close.

French

Before (flagged):

Le module (qui dépend du noyau (chargé au démarrage [voir le manuel])) est facultatif.

What lucid-lint check --profile public --experimental syntax.parenthetical-depth --conditions adhd reports:

warning input.md:1:23 Nested parentheticals reach depth 3; readers must hold 3 suspended thoughts to reach the close. Split the sentence or unnest the inner bracket (plainlanguage.gov, Hemingway). [syntax.parenthetical-depth]

After (your rewrite):

Le module est facultatif. Il dépend du noyau, chargé au démarrage. Voir le manuel pour les détails.

Three sentences, no nested brackets. The dependency chain is now linear and the reader recovers each fact in the order it appears.

Suppression

See Suppressing diagnostics for the inline and block forms. Inline disable also works on this rule:

<!-- lucid-lint disable-next-line syntax.parenthetical-depth -->
The migration tool (which now supports rollbacks (see `--reverse`, added in 0.4.2 [tracked in #312])) is opt-in.

See also

References

  • plainlanguage.gov — Write short sentences. Plain-language guidance treats stacked qualifiers and nested parentheticals as the canonical “long sentence” symptom.
  • Hemingway editing tradition — surfaces “hard to read” sentences when they layer multiple suspended ideas; nested parentheticals are the cleanest mechanical reading of that signal.

See References for the full bibliography.