Skip to content

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

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

feat(#256): add roll-bases lint#1248
VasilevNStas wants to merge 1 commit 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

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

1 participant