Collection of Checkers for EO Programs

This Java package is a collection of "lints" (aka "checkers") for
XMIR (an intermediate representation of a
EO object). This is primarily about best practices and readiness
of code for successful compilation and execution, not about code
formatting. A few lints also enforce naming conventions, since
consistent naming is considered a best practice here too.
We use this package as a dependency in the
EO-to-Java compiler:
<dependency>
<groupId>org.eolang</groupId>
<artifactId>lints</artifactId>
<version>0.5.0</version>
</dependency>
You can also use it in order to validate the validity
of XMIR documents your software may generate:
import com.jcabi.xml.StrictXML;
import org.eolang.lints.Source;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
final class Foo {
@Test
void testValidSource() {
Assertions.assertTrue(
new Source(
new StrictXML("<object> your XMIR goes here </object>")
).defects().isEmpty()
);
}
}
It is possible to disable any particular linter in a program,
with the help of the +unlint meta.
Whole-program analysis (running lints across a set of XMIR files
instead of one at a time) lives in a separate package,
org.eolang:wpa.
Running Locally on a .eo File
There is no standalone CLI in this repository, but you can lint
a single .eo file with a few lines of Java. Besides lints,
add eo-parser, which turns
EO source into XMIR:
<dependency>
<groupId>org.eolang</groupId>
<artifactId>eo-parser</artifactId>
<!-- keep this in sync with "home.version" in this project's pom.xml -->
<version>0.63.2</version>
</dependency>
import com.jcabi.xml.XML;
import java.nio.file.Paths;
import org.cactoos.io.InputOf;
import org.eolang.lints.Source;
import org.eolang.parser.EoSyntax;
final class RunLints {
public static void main(final String... args) throws Exception {
final XML xmir = new EoSyntax(
new InputOf(Paths.get("my-program.eo"))
).parsed();
new Source(xmir).defects().forEach(System.out::println);
}
}
Printed defects include a source line when one is available.
Defects about missing metas have no source line, e.g.
[mandatory-spdx/S WARNING] The +spdx meta is mandatory, but is absent.
Print xmir itself to inspect the parsed object tree, the <errors>
parser diagnostics, and the original <listing>, which helps when a
lint isn't behaving as expected.
Design of This Library
The library is designed as a set of lints, each of which
is a separate class implementing the Lint interface.
Each lint is responsible for checking one particular aspect
of the XMIR document. The Source class is responsible for
running all lints and collecting defects for a single XMIR file.
All in all, there are only three classes and interfaces that
are supposed to be exposed to a user of the library:
Source - checker of a single XMIR
Defect - a single defect discovered
Severity - a severity of a defect
There are also a few classes that implement Iterable<Lint>:
PkMono and PkByXsl.
They are supposed to be used only by the Source,
and are not supposed to be exposed to the user of the library.
They are responsible for providing a set of lints to be executed,
building them from the information in classpath.
Benchmark
Here is the result of linting XMIRs:
Input: com/sun/jna/PointerType.class (S source)
Lint time: 12s (11933 ms)
Input: com/sun/jna/Memory.class (M source)
Lint time: 7s (6926 ms)
Input: com/sun/jna/Pointer.class (L source)
Lint time: 10s (10285 ms)
Input: com/sun/jna/Structure.class (XL source)
Lint time: 17s (16627 ms)
Input: org/apache/hadoop/hdfs/server/namenode/FSNamesystem.class (XXL source)
Lint time: 1min (61967 ms)
application-without-as-attributes (XXL) (2909 ms)
too-deep-object (XXL) (1767 ms)
duplicate-as-attribute (XXL) (1646 ms)
object-has-data (XXL) (1320 ms)
reserved-name (XXL) (1152 ms)
redundant-object (XXL) (1140 ms)
unit-test-is-not-verb (XXL) (1139 ms)
empty-object (XXL) (1134 ms)
compound-name (XXL) (1032 ms)
line-is-absent (XXL) (977 ms)
incorrect-bytes-format (XXL) (850 ms)
invalid-name-notation (XXL) (811 ms)
non-kebab-name (XXL) (699 ms)
wrong-test-order (XXL) (644 ms)
anonymous-formation (XXL) (621 ms)
unit-test-missing (XXL) (586 ms)
The results were calculated in this GHA job
on 2026-11-19 at 18:59,
on Linux with 4 CPUs.
How to Contribute
Fork repository, make changes, then send us
a pull request.
We will review your changes and apply them to the master branch shortly,
provided they don't violate our quality standards. To avoid frustration,
before sending us your pull request please run full Maven build:
mvn clean install -Pqulice
Also, run this and make sure your changes don't slow us down:
mvn jmh:benchmark
You will need Maven 3.3+ and Java 11+ installed.
Also, if you have xcop installed, make sure
it is version 0.8.0+.
If you want the code to be checked using
error-prone, use Java 21+
If you want to check markdown files
using vale,
just install it and make sure it's in your PATH