feat(#256): add roll-bases lint - #1248
Open
VasilevNStas wants to merge 1 commit into
Open
Conversation
Contributor
Author
|
@volodya-lombrozo @maxonfjvipon please review this PR |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix #256
What
A new
misc/roll-baseslint that reports composite@baseattributeswhich could be written in a shorter, rolled form.
Consider this XMIR:
It can (and must) be written shorter:
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 comefrom
phino,jeo-maven-plugin, or be written by hand. In those inputsunrolled composite bases are a real mistake, and nothing currently flags
them.
How it works
The lint follows the collapse rules of
roll-bases.xslfromeo-parser:a node with
@basestarting with.and a single child whose@basedoes not start with
., has no inner objects, no data and no name, mustbe merged into
concat(child/@base, @base).Why unit tests instead of yaml packs
The yaml packs always parse EO code, and
eo-parserrolls bases on thatpath — so an unrolled
catchescase cannot be expressed in a pack. Thelint is therefore covered by unit tests in
LtByXslTestthat feed ahand-built XMIR (via
Xembler) straight toLtByXsl:catchesUnrolledBases—.foo/xis reportedallowsRolledBase—x.foois cleanallowsNestedBaseWithData— a child with data must not be rolledallowsDoubleDotBases—.foo/.barmust not be rolledBoth
mvn test(594 tests) andmvn clean install -Pqulicepass.