Skip to content

feat(#256): add roll-bases lint - #1248

Open
VasilevNStas wants to merge 4 commits into
objectionary:masterfrom
VasilevNStas:fix/issue-256-roll-bases
Open

feat(#256): add roll-bases lint#1248
VasilevNStas wants to merge 4 commits into
objectionary:masterfrom
VasilevNStas:fix/issue-256-roll-bases

Conversation

@VasilevNStas

Copy link
Copy Markdown
Contributor

fix #256

What

A new misc/roll-bases lint that reports composite @base attributes
which could be written in a shorter, rolled form.

Consider this XMIR:

<o base=".foo">
  <o base="x"/>
</o>

It can (and must) be written shorter:

<o base="x.foo"/>

The lint reports the unrolled form with a warning.

Why

As @maxonfjvipon correctly pointed out, XMIR is not only produced by
eo-parser (which already rolls bases during parsing) — it may also come
from phino, jeo-maven-plugin, or be written by hand. In those inputs
unrolled composite bases are a real mistake, and nothing currently flags
them.

How it works

The lint follows the collapse rules of roll-bases.xsl from eo-parser:
a node with @base starting with . and a single child whose @base
does not start with ., has no inner objects, no data and no name, must
be merged into concat(child/@base, @base).

Why unit tests instead of yaml packs

The yaml packs always parse EO code, and eo-parser rolls bases on that
path — so an unrolled catches case cannot be expressed in a pack. The
lint is therefore covered by unit tests in LtByXslTest that feed a
hand-built XMIR (via Xembler) straight to LtByXsl:

  • catchesUnrolledBases.foo/x is reported
  • allowsRolledBasex.foo is clean
  • allowsNestedBaseWithData — a child with data must not be rolled
  • allowsDoubleDotBases.foo/.bar must not be rolled

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

@VasilevNStas

Copy link
Copy Markdown
Contributor Author

@volodya-lombrozo @maxonfjvipon please review this PR

@VasilevNStas
VasilevNStas force-pushed the fix/issue-256-roll-bases branch from e54bd1e to 6fc883c Compare August 25, 2026 13:34
@VasilevNStas

Copy link
Copy Markdown
Contributor Author

@volodya-lombrozo
I`m fixed conflict, plz re-review

Comment thread src/test/java/org/eolang/lints/LtByXslTest.java Outdated
@VasilevNStas
VasilevNStas force-pushed the fix/issue-256-roll-bases branch from 6fc883c to 5de0641 Compare August 30, 2026 20:00
@VasilevNStas

Copy link
Copy Markdown
Contributor Author

@volodya-lombrozo
plz re-review this

@VasilevNStas
VasilevNStas force-pushed the fix/issue-256-roll-bases branch from 5de0641 to 2310885 Compare September 5, 2026 10:45
@VasilevNStas
VasilevNStas force-pushed the fix/issue-256-roll-bases branch from 84c2294 to 4299698 Compare September 5, 2026 12:31
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.

composite @base attributes must be mandatory, if possible

2 participants