feat(#20): add mystery-object lint - #1241
Open
VasilevNStas wants to merge 3 commits into
Open
Conversation
Contributor
Author
|
@volodya-lombrozo plz review this PR |
volodya-lombrozo
suggested changes
Aug 13, 2026
VasilevNStas
force-pushed
the
fix/issue-20-mystery-objects
branch
2 times, most recently
from
August 13, 2026 06:34
faab882 to
8ea053a
Compare
Contributor
Author
|
@volodya-lombrozo plz re-review |
VasilevNStas
force-pushed
the
fix/issue-20-mystery-objects
branch
from
August 15, 2026 09:53
8ea053a to
4745435
Compare
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 #20
What
A new Java-based lint
mystery-objectis added. It is registered inMonoLintstogether with the other hand-coded lints (ascii-only,reserved-name). The full set of artifacts:src/main/java/org/eolang/lints/LtMystery.java— the lint implementationsrc/main/resources/org/eolang/motives/names/mystery-object.md— the motivesrc/test/java/org/eolang/lints/LtMysteryTest.java— unit testssrc/test/resources/org/eolang/lints/*.eo— EO fixtures used by the testsWhy
Consider this program:
The object
baris neither defined in the program, nor imported via+alias, nor one of theorg.eolangobjects. Such a call is almost alwaysa typo in the object name. Still, the parser happily compiles it into a
bare
Φ.barreference and nobody complains. The program reaches thecompile/run pipeline and fails there with an obscure error, far away from
the actual mistake.
This lint detects exactly that situation and reports it as an
errorright at the source line.
How it works
The parser resolves any object application into a
baseattribute. Thereare three interesting shapes:
Φ.org.eolang.io.stdout— a qualified path (result of+aliasor afully-qualified name). Always legitimate, never reported.
Φ.number,Φ.bytes, etc. — references to primeorg.eolangobjects.Legitimate, but only when the name is really one of the reserved top-level
objects of the home repository.
Φ.bar— a bare single-name reference. This is the suspicious case.The lint walks every
//o[@base]element and applies the simple-namepattern
^Φ\.[a-z][a-z0-9_-]*$. Any element that matches must prove itsright to exist:
//o[@name='bar']node in the same XMIR — a legitimate local object, orReservedNames— the CSV of theorg.eolangtop-level objects, generated from the home repository on the
reservedbuild profile.
Everything else is a mystery object and gets an
errordefect.Aliased objects need no special handling: the parser resolves an alias into
a dotted path (
Φ.org.eolang.io.stdout), which never matches the simpleone-word pattern, so they are excluded by construction.
Why not an XSL lint
The decision on "is
NAMEa legitimateorg.eolangobject" depends on theruntime list from the home repository (
ReservedNames, backed byreserved.csvgenerated on thereservedMaven profile). XSL transformscannot read that runtime data, while a Java lint can — this is the same
reason the existing
reserved-namelint is implemented in Java.Robustness against a missing reserved list
reserved.csvexists only when thereservedprofile is active (CI doesthis in a dedicated
reserved.ymlworkflow). In the defaultmvn testrun the map is empty. The lint handles this gracefully: with an empty list
it returns no defects. The full behavior matrix is exercised in the
@Tag("reserved")integration test (scansMysteryFromHome), which runsagainst the real home data in CI.
Tests
catchesMysteryObject—barwith no definition is caughtreportsCorrectMessageForMysteryObject— message names the objectallowsDeclaredObject— localbardeclaration is fineallowsAliasedObject—+aliasimport is fineallowsCanonicalObject—org.eolangliteral (42) is fineallowsAllObjectsDeclaredInline— all inline declarations are finescansMysteryFromHome(@Tag("reserved")) — integration against thereal reserved list from home
Both
mvn test(592 tests) andmvn clean install -Pqulicepass.