Skip to content

Commit

Permalink
Merge pull request #3898 from maxonfjvipon/bug/#3869/fix-linting
Browse files Browse the repository at this point in the history
bug(#3869): added boolean flag for linting as package
  • Loading branch information
yegor256 authored Feb 9, 2025
2 parents a828139 + b3013b8 commit b4151e7
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 48 deletions.
32 changes: 22 additions & 10 deletions eo-maven-plugin/src/main/java/org/eolang/maven/LintMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,18 @@ public final class LintMojo extends SafeMojo {
* @checkstyle MemberNameCheck (11 lines)
*/
@SuppressWarnings("PMD.ImmutableField")
@Parameter(
property = "eo.failOnWarning",
required = true,
defaultValue = "true"
)
@Parameter(property = "eo.failOnWarning", required = true, defaultValue = "true")
private boolean failOnWarning;

/**
* Whether we should lint all the sources together as package.
*
* @checkstyle MemberNameCheck (11 lines)
*/
@SuppressWarnings("PMD.ImmutableField")
@Parameter(property = "eo.lintAsPackage", required = true, defaultValue = "true")
private boolean lintAsPackage;

@Override
void exec() throws IOException {
final long start = System.currentTimeMillis();
Expand All @@ -100,11 +105,18 @@ void exec() throws IOException {
if (tojos.isEmpty()) {
Logger.info(this, "There are no XMIR programs, nothing to lint individually");
}
Logger.info(
this,
"Also, %d XMIR programs linted as a package",
this.lintAll(counts)
);
if (this.lintAsPackage) {
Logger.info(
this,
"XMIR programs linted as a package: %d",
this.lintAll(counts)
);
} else {
Logger.info(
this,
"Skipping linting as package (use -Deo.lintAsPackage=true to enable)"
);
}
final String sum = LintMojo.summary(counts);
Logger.info(
this,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ private int translate(final Path xmir, final int position, final int total)
final XML xml = new XMLDocument(new TextOf(xmir).asString());
try {
new Saved(this.translated(xml), target).value();
Logger.info(
Logger.debug(
this,
"Translated to phi (#%d/%d): %[file]s (%[size]s) -> %[file]s (%[size]s) in %[ms]s",
position, total, xmir,
Expand Down
25 changes: 0 additions & 25 deletions eo-maven-plugin/src/main/java/org/eolang/maven/RegisterMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
package org.eolang.maven;

import com.jcabi.log.Logger;
import java.io.File;
import java.nio.file.Path;
import java.util.Collection;
import java.util.Set;
Expand All @@ -47,30 +46,6 @@
)
@SuppressWarnings("PMD.ImmutableField")
public final class RegisterMojo extends SafeMojo {

/**
* Directory in which {@code .eo} files are located.
*
* <p>If you need to register {@code .eo} files located in many directories,
* you can use the {@code &lt;includeSources&gt;} feature, for example:</p>
*
* <pre> &lt;configuration&gt;
* &lt;sourcesDir&gt;/&lt;/sourcesDir&gt;
* &lt;includeSources&gt;
* &lt;glob&gt;tmp/&#42;&#42;/&#42;.eo&lt;/glob&gt;
* &lt;glob&gt;src/main/&#42;&#42;/&#42;.eo&lt;/glob&gt;
* &lt;/includeSources&gt;
* &lt;/configuration&gt;</pre>
*
* @checkstyle MemberNameCheck (7 lines)
*/
@Parameter(
property = "eo.sourcesDir",
required = true,
defaultValue = "${project.basedir}/src/main/eo"
)
private File sourcesDir;

/**
* List of inclusion GLOB filters for finding EO files
* in the {@code <includeSources>} directory, which can be
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ public Object resolveParameter(final ParameterContext context,
final ExtensionContext ext) {
return String.join(
"\n",
"+unlint object-has-data\n",
"# This is a random program in EO, which supposedly",
"# complies with all syntactic rules of the language,",
"# include the requirements for comments.",
Expand Down
6 changes: 0 additions & 6 deletions eo-maven-plugin/src/test/resources/org/eolang/maven/mess.eo
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,6 @@
+tests
+package org.eolang.examples
+version 0.0.0
+unlint atom-is-not-unique
+unlint broken-ref
+unlint incorrect-alias
+unlint object-is-not-unique
+unlint broken-alias-second
+unlint object-has-data

3.14 > pi

Expand Down
4 changes: 3 additions & 1 deletion eo-runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -245,14 +245,16 @@ SOFTWARE.
<configuration>
<withRuntimeDependency>false</withRuntimeDependency>
<placeBinariesThatHaveSources>true</placeBinariesThatHaveSources>
<lintAsPackage>false</lintAsPackage>
</configuration>
</execution>
<execution>
<id>test-compile</id>
<phase>generate-test-sources</phase>
<goals>
<goal>register</goal>
<goal>compile</goal>
<goal>assemble</goal>
<goal>lint</goal>
<goal>xmir-to-phi</goal>
<goal>phi-to-xmir</goal>
<goal>transpile</goal>
Expand Down
1 change: 1 addition & 0 deletions eo-runtime/src/main/eo/org/eolang/math/e.eo
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
+home https://github.com/objectionary/eo
+package org.eolang.math
+version 0.0.0
+unlint unit-test-missing

# The Euler's number.
# A fundamental mathematical constant approximately equal to 2.7182818284590452354.
Expand Down
4 changes: 0 additions & 4 deletions eo-runtime/src/main/eo/org/eolang/txt/text.eo
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@

# Text.
# A sequence of characters representing words, sentences, or data.
# @todo #3481:30min Remove all +unlit metas from EO source code.
# These suppressions were added in order to be compile EO when @ref attribute
# from XMIR is removed, by it's checked by LintMojo. We need to remove these
# suppressions when `lints` repository is fixed and new version is used in EO.
[origin] > text
origin > @
# Check that all signs in string are numbers or letters.
Expand Down

1 comment on commit b4151e7

@0pdd
Copy link

@0pdd 0pdd commented on b4151e7 Feb 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Puzzle 3481-afe7d026 disappeared from eo-runtime/src/main/eo/org/eolang/txt/text.eo), that's why I closed #3869. Please, remember that the puzzle was not necessarily removed in this particular commit. Maybe it happened earlier, but we discovered this fact only now.

Please sign in to comment.