| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
This Java package is a collection of "lints" (aka "checkers") for XMIR (an intermediate representation of a EO object). This is not about static analysis or code formatting. This is about best practices and readiness of code for successful compilation and execution.
We use this package as a dependency in the EO-to-Java compiler:
<dependency>
<groupId>org.eolang</groupId>
<artifactId>lints</artifactId>
<version>0.0.45</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()
);
}
}Then, you can run a whole-program analysis of XMIR files in your project, using the Program class (there is a different set of lints to be executed here!):
import java.nio.file.Paths;
import org.eolang.lints.Program;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
final class Foo {
@Test
void testProgram() {
Assertions.assertTrue(
new Program(
Paths.get("xmir-files") // directory with XMIR files
).defects().isEmpty()
);
}
}It is possible to disable any particular linter in a program, with the help of the +unlint meta.
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. The Program class is responsible for running all lints and collecting defects for whole EO program, as set of XMIR files. All in all, there are only four classes and interfaces that are supposed to be exposed to a user of the library:
There are also a few classes that implement Iterable<Lint>: PkMono, PkWpa, and PkByXsl. They are supposed to be used only by the Source and Program, 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.
Here is the result of linting XMIRs:
Input: com/sun/jna/PointerType.class (S source)
Lint time: 4s (3527 ms)
Input: com/sun/jna/Memory.class (M source)
Lint time: 4s (4028 ms)
Input: com/sun/jna/Pointer.class (L source)
Lint time: 5s (5005 ms)
Input: com/sun/jna/Structure.class (XL source)
Lint time: 6s (6416 ms)
Input: org/apache/hadoop/hdfs/server/namenode/FSNamesystem.class (XXL source)
Lint time: 19s (19008 ms)
unlint-non-existing-defect (XXL) (9394 ms)
unlint-non-existing-defect (XL) (3164 ms)
unlint-non-existing-defect (L) (2467 ms)
unlint-non-existing-defect (M) (1972 ms)
unlint-non-existing-defect (S) (1724 ms)
application-duality (XXL) (1517 ms)
object-has-data (XXL) (1302 ms)
named-object-abstract-nested (XXL) (966 ms)
name-outside-of-abstract-object (XXL) (844 ms)
incorrect-bytes-format (XXL) (403 ms)
line-is-absent (XXL) (358 ms)
application-duality (XL) (292 ms)
duplicate-names (XXL) (269 ms)
bytes-without-data (XXL) (261 ms)
object-has-data (XL) (260 ms)
named-object-abstract-nested (XL) (193 ms)
The results were calculated in this GHA job on 2025-04-28 at 16:44, on Linux with 4 CPUs.
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 -PquliceAlso, run this and make sure your changes don't slow us down:
mvn jmh:benchmarkYou 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 17+
| Back | FazBrowse Home | New Git URL |