Skip to content

feat(#155): add too-deep-object lint - #1247

Merged
yegor256 merged 1 commit into
objectionary:masterfrom
VasilevNStas:fix/issue-155-too-deep-object
Sep 1, 2026
Merged

yegor256 merged 1 commit into
objectionary:masterfrom
VasilevNStas:fix/issue-155-too-deep-object

Conversation

@VasilevNStas

Copy link
Copy Markdown
Contributor

fix #155

What

A new design/too-deep-object lint that warns when an object is nested
deeper than twelve levels.

How it works

The lint counts the ancestors of every object in XMIR:

depth = count(ancestor::o)

If the depth exceeds 12, the object is reported as a warning.

Synthetic nodes introduced by the parser are excluded from the count:
Φ.tuple (tuples written as *), Φ.bytes, Φ.number and Φ.string
(literals). Without this, even the canonical example
(src/test/resources/org/eolang/lints/canonical.eo, which is only about
12 source levels deep) would be flagged, because the parser wraps every
literal and tuple in extra levels of nesting.

Only the deepest offending objects are reported (not every descendant),
so a single deep chain yields a single defect.

Why

Deeply nested objects are hard to read and debug. The issue proposes a
threshold of 12, which this lint follows.

Tests

  • catches-too-deep-object — a 14-level chain is flagged
  • allows-normal-nesting — a 7-level chain (from the issue) is clean

Both mvn test (592 tests) and mvn clean install -Pqulice pass.

@VasilevNStas

Copy link
Copy Markdown
Contributor Author

@volodya-lombrozo plz review this pull request

@yegor256
yegor256 merged commit c2f2d1e into objectionary:master Sep 1, 2026
22 checks passed

yegor256 commented Sep 1, 2026

Copy link
Copy Markdown
Member

Thanks for the contribution!


Generated by Claude Code

@VasilevNStas
VasilevNStas deleted the fix/issue-155-too-deep-object branch September 5, 2026 10:09
@0crat

0crat commented Sep 5, 2026

Copy link
Copy Markdown

@VasilevNStas Thanks for the contribution! You've earned +12 points for this: +16 as a basis; -4 for too many hits-of-code (106 >= 100). Please, keep them coming. Your running score is +554; don't forget to check your Zerocracy account too).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

new lint too-deep-object to catch very nested objects

3 participants