Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions eo-maven-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,7 @@
<plugin>
<groupId>com.qulice</groupId>
<artifactId>qulice-maven-plugin</artifactId>
<version>0.25.1</version>
<configuration>
<excludes>
<exclude>checkstyle:/src/it.*</exclude>
Expand Down
6 changes: 3 additions & 3 deletions eo-maven-plugin/src/main/java/org/eolang/maven/Cache.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package org.eolang.maven;

import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.security.MessageDigest;
Expand Down Expand Up @@ -101,16 +102,15 @@ private Path hash(final Path tail) {
*/
private static String sha(final Path file) throws NoSuchAlgorithmException, IOException {
final MessageDigest digest = MessageDigest.getInstance("SHA-256");
try (var stream = Files.newInputStream(file)) {
try (InputStream stream = Files.newInputStream(file)) {
final byte[] buffer = new byte[8192];
int read = stream.read(buffer);
while (read != -1) {
digest.update(buffer, 0, read);
read = stream.read(buffer);
}
}
final byte[] hash = digest.digest();
return Base64.getEncoder().encodeToString(hash);
return Base64.getEncoder().encodeToString(digest.digest());
}
}

7 changes: 6 additions & 1 deletion eo-maven-plugin/src/main/java/org/eolang/maven/Catalogs.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import com.yegor256.tojos.Tojos;
import java.nio.file.Path;
import java.util.Locale;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.cactoos.scalar.Sticky;
import org.cactoos.scalar.Unchecked;
Expand All @@ -23,7 +24,11 @@
* All catalogs in one place, to avoid making multiple objects.
*
* @since 0.29
* @todo #4884:30min Use ReentranLock instead of synchronized block in the code.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Typo: ReentranLockReentrantLock

The TODO references the wrong class name; it's missing the second t.

📝 Proposed fix
- * `@todo` `#4884`:30min Use ReentranLock instead of synchronized block in the code.
+ * `@todo` `#4884`:30min Use ReentrantLock instead of synchronized block in the code.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
* @todo #4884:30min Use ReentranLock instead of synchronized block in the code.
* `@todo` `#4884`:30min Use ReentrantLock instead of synchronized block in the code.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@eo-maven-plugin/src/main/java/org/eolang/maven/Catalogs.java` at line 27, Fix
the typo in the TODO comment inside Catalogs (change "ReentranLock" to
"ReentrantLock") so the referenced class name is correct; update the TODO text
in the Catalogs.java comment to "ReentrantLock" and, if present elsewhere in
comments, ensure consistent spelling to avoid confusion when implementing the
actual replacement of the synchronized block.

* It will be more efficient and will not cause deadlocks.
* Don't forget to remove the PMD suppression after that.
*/
@SuppressWarnings("PMD.AvoidSynchronizedStatement")
final class Catalogs {

/**
Expand Down Expand Up @@ -54,7 +59,7 @@ final class Catalogs {
/**
* All of them.
*/
private final ConcurrentHashMap<Path, Tojos> all;
private final Map<Path, Tojos> all;

/**
* Ctor.
Expand Down
8 changes: 6 additions & 2 deletions eo-maven-plugin/src/main/java/org/eolang/maven/ChSource.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,15 @@ public String value() {
* @return SHA-1 hash
* @throws NoSuchAlgorithmException If SHA-1 is not supported
*/
@SuppressWarnings("PMD.UseStringIsEmptyRule")
private String hash() throws NoSuchAlgorithmException {
final MessageDigest digest = MessageDigest.getInstance("SHA-1");
final var content = new Unchecked<>(this.text).value();
final StringBuilder res = new StringBuilder(40);
for (final byte raw : digest.digest(content.getBytes(StandardCharsets.UTF_8))) {
for (
final byte raw : digest.digest(
new Unchecked<>(this.text).value().getBytes(StandardCharsets.UTF_8)
)
) {
final String hex = Integer.toHexString(0xff & raw);
if (hex.length() == 1) {
res.append('0');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,7 @@ interface CommitHash extends Scalar<String> {
*/
CommitHash FAKE = new CommitHash.ChConstant("abcdef");

/**
* SHA Hash.
*
* @return SHA of commit
*/
@Override
String value();

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@
* Concurrent cache wrapper for Cache.
* Wrap {@link Cache} to make it thread-safe.
* @since 0.60
* @todo #4884:30min Use ReentrantLock instead of synchronized block.
* This is the suggestion from qulice.
* Dont' forget to remove the PMD suppression for AvoidSynchronizedStatement
* after that.
Comment on lines +15 to +18

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Fix typo in TODO Javadoc text.

Line 17 has a typo (Dont'). Please correct it to keep maintenance notes clear and professional.

✍️ Suggested edit
- *  Dont' forget to remove the PMD suppression for AvoidSynchronizedStatement
+ *  Don't forget to remove the PMD suppression for `AvoidSynchronizedStatement`
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
* @todo #4884:30min Use ReentrantLock instead of synchronized block.
* This is the suggestion from qulice.
* Dont' forget to remove the PMD suppression for AvoidSynchronizedStatement
* after that.
* `@todo` `#4884`:30min Use ReentrantLock instead of synchronized block.
* This is the suggestion from qulice.
* Don't forget to remove the PMD suppression for `AvoidSynchronizedStatement`
* after that.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@eo-maven-plugin/src/main/java/org/eolang/maven/ConcurrentCache.java` around
lines 15 - 18, In the Javadoc TODO comment inside the ConcurrentCache class
update the typo "Dont'" to "Don't" so the maintenance note reads correctly;
locate the TODO block that starts with "@todo `#4884`:30min Use ReentrantLock
instead of synchronized block." and replace the malformed apostrophe in the word
Dont' with the proper contraction Don't (no other logic changes required).

*/
@SuppressWarnings("PMD.AvoidSynchronizedStatement")
final class ConcurrentCache {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ final class DepDirs extends ListEnvelope<String> {
* @return List
* @throws IOException If fails
*/
@SuppressWarnings("PMD.UnnecessaryLocalRule")
private static List<String> list(final Path dir) throws IOException {
final List<String> names = new LinkedList<>();
if (Files.exists(dir)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* List of dependencies.
* @since 0.54
*/
@FunctionalInterface
interface Dependencies extends Iterable<Dep> {
Comment on lines +20 to 21

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

# First, let me find the exact file and read it to understand the context
cat -n eo-maven-plugin/src/main/java/org/eolang/maven/Dependencies.java

Repository: objectionary/eo

Length of output: 4656


🏁 Script executed:

# Check if Dependencies is ever instantiated via lambda or method reference
rg -n --type java 'Dependencies\s+[a-zA-Z_$][a-zA-Z0-9_$]*\s*=' eo-maven-plugin/src/main/java/org/eolang/maven/ -A 2 -B 2

Repository: objectionary/eo

Length of output: 578


🏁 Script executed:

# Also check for direct lambda instantiation patterns
rg -n --type java '\(\)\s*->\s*' eo-maven-plugin/src/main/java/org/eolang/maven/Dependencies.java -A 2 -B 2

Repository: objectionary/eo

Length of output: 41


🏁 Script executed:

# Find all classes implementing Dependencies
rg -n --type java 'implements\s+Dependencies' eo-maven-plugin/src/main/java/org/eolang/maven/

Repository: objectionary/eo

Length of output: 1189


🏁 Script executed:

# Check if there are any lambda assignments to Dependencies anywhere
rg -n --type java 'Dependencies\s+\w+\s*=\s*\(' eo-maven-plugin/src/main/java/org/eolang/maven/ -A 1

Repository: objectionary/eo

Length of output: 41


Remove @FunctionalInterface—it is misleading and unused.

@FunctionalInterface suggests clients may construct Dependencies via lambda expressions (e.g., Dependencies d = () -> list.iterator();). However, the entire codebase instantiates Dependencies exclusively through concrete class implementations (DpsDefault, DpsWithRuntime, DpsDepgraph, Fake, etc.) and never via lambda. The annotation is technically valid (one abstract method: iterator()) but actively misleading; it should be removed to avoid suggesting an unsupported pattern.

Additionally, extract the magic number at line 114:

new String[]{"test", "compiled", "runtime"}[rand.nextInt(3)]

The hardcoded 3 is decoupled from the array length. Use rand.nextInt(scopes.length) or a named constant to prevent them from falling out of sync if the scopes array is later extended.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@eo-maven-plugin/src/main/java/org/eolang/maven/Dependencies.java` around
lines 20 - 21, Remove the misleading `@FunctionalInterface` annotation from the
Dependencies interface declaration (interface Dependencies extends
Iterable<Dep>) since the project only uses concrete implementations (e.g.,
DpsDefault, DpsWithRuntime, DpsDepgraph, Fake) and does not rely on lambda
construction; then replace the magic number usage in the random scope selection
(currently new String[]{"test","compiled","runtime"}[rand.nextInt(3)]) by
referencing the scopes array length (e.g., use a local scopes String[] and call
rand.nextInt(scopes.length)) or a named constant for the size so the index bound
stays in sync with the array.

/**
* Fake dependencies.
Expand Down Expand Up @@ -106,14 +107,11 @@ static Dep runtimeDep() {
*/
private static Dep randDep() {
final Random rand = new SecureRandom();
final String scope = new String[] {
"test", "compiled", "runtime",
}[rand.nextInt(3)];
return Dependencies.Fake.dep(
UUID.randomUUID().toString(),
UUID.randomUUID().toString(),
String.valueOf(rand.nextInt(Integer.MAX_VALUE)),
scope
new String[]{"test", "compiled", "runtime"}[rand.nextInt(3)]
);
}

Expand All @@ -126,7 +124,6 @@ private static Dep randDep() {
* @return Dependency.
* @checkstyle ParameterNumberCheck (5 lines)
*/
@SuppressWarnings("PMD.UseObjectForClearerAPI")
private static Dep dep(
final String group,
final String artifact,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,10 @@ private static Collection<String> jvms(final Path file) {
Filter.withName("meta"),
meta -> {
final Xnav xnav = new Xnav(meta);
final Optional<String> head = xnav.element("head").text();
final boolean runtime = head.map("rt"::equals).orElse(false);
final Optional<Xnav> part = xnav.elements(
Filter.withName("part")
).findFirst();
return runtime
return xnav.element("head").text().map("rt"::equals).orElse(false)
&& part.isPresent()
&& part.get().text().map("jvm"::equals).orElse(false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,20 @@ final class DpsEachWithoutTransitive implements Dependencies {
public Iterator<Dep> iterator() {
return new Mapped<>(
dependency -> {
final Iterable<Dep> transitives = new Filtered<>(
dep -> {
final Dependency dpndncy = dep.get();
return !DpsEachWithoutTransitive.eqTo(dpndncy, dependency.get())
&& DpsEachWithoutTransitive.isRuntimeRequired(dpndncy)
&& !MjResolve.isRuntime(dpndncy);
},
this.transitive.apply(dependency)
);
final String list = String.join(
", ",
new Mapped<>(Dep::toString, transitives)
new Mapped<>(
Dep::toString,
new Filtered<>(
dep -> {
final Dependency dpndncy = dep.get();
return !DpsEachWithoutTransitive.eqTo(dpndncy, dependency.get())
&& DpsEachWithoutTransitive.isRuntimeRequired(dpndncy)
&& !MjResolve.isRuntime(dpndncy);
},
this.transitive.apply(dependency)
)
)
);
if (!list.isEmpty()) {
throw new IllegalStateException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import java.io.IOException;
import java.net.URL;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.function.Supplier;
import org.apache.maven.model.Dependency;
Expand Down Expand Up @@ -78,7 +79,7 @@ final class DpsWithRuntime implements Dependencies {

@Override
public Iterator<Dep> iterator() {
final ListOf<Dep> all = new ListOf<>(this.delegate);
final List<Dep> all = new ListOf<>(this.delegate);
if (all.stream().noneMatch(dep -> DpsWithRuntime.isRuntime(dep.get()))) {
all.add(this.supplied.value());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* target files, updates target file and returns it.
* @since 0.41.0
*/
@FunctionalInterface
interface Footprint extends BiFunc<Path, Path, Path> {
@Override
Path apply(Path source, Path target) throws IOException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public final class MjAssemble extends MjSafe {
};

@Override
@SuppressWarnings("PMD.UnnecessaryLocalRule")
public void exec() {
final long begin = System.currentTimeMillis();
String before = this.scopedTojos().status();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public final class MjCompile extends MjSafe {
};

@Override
@SuppressWarnings("PMD.UnnecessaryLocalRule")
public void exec() {
final long begin = System.currentTimeMillis();
for (final Moja<?> moja : MjCompile.MOJAS) {
Expand Down
11 changes: 6 additions & 5 deletions eo-maven-plugin/src/main/java/org/eolang/maven/MjLint.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,11 @@ void exec() throws IOException {
* Lint.
* @throws IOException If fails
*/
@SuppressWarnings("PMD.UnnecessaryLocalRule")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

# First, let's look at the MjLint.java file around line 80 for full context
sed -n '70,120p' eo-maven-plugin/src/main/java/org/eolang/maven/MjLint.java

Repository: objectionary/eo

Length of output: 2065


🏁 Script executed:

# Search for "UnnecessaryLocalRule" in the entire codebase to check if it's a custom rule
rg "UnnecessaryLocalRule" --type java --type xml

Repository: objectionary/eo

Length of output: 6419


🏁 Script executed:

# Look for PMD configuration files
fd -e xml -e pom | xargs grep -l "PMD\|pmd\|ruleset" 2>/dev/null | head -10

Repository: objectionary/eo

Length of output: 82


🏁 Script executed:

# Check the main pom.xml for PMD configuration
head -200 eo-maven-plugin/pom.xml | grep -A 20 -B 5 "pmd\|qulice"

Repository: objectionary/eo

Length of output: 41


🏁 Script executed:

# Look for ruleset or PMD configuration files
find . -name "*.xml" | xargs grep -l "UnnecessaryLocalRule\|qulice" | head -5

Repository: objectionary/eo

Length of output: 166


🏁 Script executed:

# Check pom.xml more broadly for PMD plugin configuration
cat eo-maven-plugin/pom.xml | grep -A 30 "qulice\|pmd" | head -80

Repository: objectionary/eo

Length of output: 936


🏁 Script executed:

# Look for PMD ruleset XML files in the project
find . -name "*.xml" -type f | xargs grep -l "ruleset\|rule" 2>/dev/null | grep -E "(pmd|qulice|config)" | head -10

Repository: objectionary/eo

Length of output: 41


🏁 Script executed:

# Check if there's a custom PMD ruleset or configuration file
find . -name "*ruleset*" -o -name "*pmd*config*" 2>/dev/null

Repository: objectionary/eo

Length of output: 41


🏁 Script executed:

# Let's check the root pom.xml for any PMD or qulice rule configuration
cat pom.xml | grep -A 50 "qulice\|pmd" | head -100

Repository: objectionary/eo

Length of output: 2048


🏁 Script executed:

# Check qulice documentation or look for rule definitions in dependencies
# Let's search for any mention of how UnnecessaryLocalRule is used in context
grep -r "UnnecessaryLocalRule" --include="*.md" --include="*.txt" --include="*.html" 2>/dev/null

Repository: objectionary/eo

Length of output: 41


🏁 Script executed:

# Let's examine one of the other files that use this annotation to see if it makes sense
sed -n '1,30p' eo-parser/src/main/java/org/eolang/parser/OnDefault.java

Repository: objectionary/eo

Length of output: 806


🌐 Web query:

qulice maven plugin UnnecessaryLocalRule PMD custom rule

💡 Result:

Qulice’s Maven plugin doesn’t expose “use my PMD ruleset / add my PMD rules” configuration. With Qulice you basically have only these PMD-related options:

  1. Suppress a PMD rule in code (Qulice explicitly supports this approach):
`@SuppressWarnings`("PMD.UnnecessaryLocalBeforeReturn") // or the rule you need

(qulice.com)

  1. Exclude files/packages from PMD within Qulice (note the pmd: prefix):
<plugin>
  <groupId>com.qulice</groupId>
  <artifactId>qulice-maven-plugin</artifactId>
  <version>0.24.3</version>
  <configuration>
    <excludes>
      <exclude>pmd:.*/generated/.*</exclude>
    </excludes>
  </configuration>
</plugin>

(qulice.com)


About UnnecessaryLocalRule

In modern PMD, the rule you likely mean is UnnecessaryLocalBeforeReturn (and it’s deprecated in favor of VariableCanBeInlined), referenced like:

<rule ref="category/java/codestyle.xml/UnnecessaryLocalBeforeReturn" />

(pmd.github.io)


If you truly need a custom PMD rule/ruleset

Use maven-pmd-plugin alongside (or instead of) Qulice, and point it at your own ruleset XML:

<configuration>
  <rulesets>
    <ruleset>${project.basedir}/config/pmd/ruleset.xml</ruleset>
  </rulesets>
</configuration>

(pmd.github.io)

Citations:


@SuppressWarnings("PMD.UnnecessaryLocalRule") is not a valid PMD rule — the annotation has no effect.

The correct PMD rule for unnecessary local variables is UnnecessaryLocalBeforeReturn. Additionally, since lint() is a void method with no return statement, that rule cannot apply here regardless. This annotation appears in 40+ files across the codebase, suggesting it was added systematically but based on an incorrect rule name.

The annotation should be removed entirely, as it provides no actual suppression and contributes no value.

🐛 Proposed fix
-    `@SuppressWarnings`("PMD.UnnecessaryLocalRule")
     private void lint() throws IOException {
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
@SuppressWarnings("PMD.UnnecessaryLocalRule")
private void lint() throws IOException {
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@eo-maven-plugin/src/main/java/org/eolang/maven/MjLint.java` at line 80,
Remove the ineffective suppression annotation
`@SuppressWarnings`("PMD.UnnecessaryLocalRule") from the MjLint class (and
similarly from other files where it was added); locate the annotation near the
lint() method and delete it entirely since the rule name is invalid and the
applicable PMD rule UnnecessaryLocalBeforeReturn cannot apply to a void method
like lint(), so no suppression is needed.

private void lint() throws IOException {
final long start = System.currentTimeMillis();
final Collection<TjForeign> tojos = this.scopedTojos().withXmir();
final ConcurrentHashMap<Severity, Integer> counts = new ConcurrentHashMap<>();
final Map<Severity, Integer> counts = new ConcurrentHashMap<>();
counts.putIfAbsent(Severity.CRITICAL, 0);
counts.putIfAbsent(Severity.ERROR, 0);
counts.putIfAbsent(Severity.WARNING, 0);
Expand Down Expand Up @@ -143,7 +144,7 @@ private void lint() throws IOException {
*/
private int lintOne(
final TjForeign tojo,
final ConcurrentHashMap<Severity, Integer> counts,
final Map<Severity, Integer> counts,
final String... unlints
) throws Exception {
final Path source = tojo.xmir();
Expand Down Expand Up @@ -185,7 +186,7 @@ private int lintOne(
* @return Amount of seen XMIR files
* @throws IOException If failed to lint
*/
private int lintAll(final ConcurrentHashMap<Severity, Integer> counts) throws IOException {
private int lintAll(final Map<Severity, Integer> counts) throws IOException {
final Map<String, Path> paths = new HashMap<>();
for (final TjForeign tojo : this.scopedTojos().withXmir()) {
paths.put(tojo.identifier(), tojo.xmir());
Expand Down Expand Up @@ -235,7 +236,7 @@ private int lintAll(final ConcurrentHashMap<Severity, Integer> counts) throws IO
private XML linted(
final String program,
final XML xmir,
final ConcurrentHashMap<Severity, Integer> counts,
final Map<Severity, Integer> counts,
final String... unlints
) {
final Node node = xmir.inner();
Expand Down Expand Up @@ -317,7 +318,7 @@ private static String plural(final int count, final String name) {
* @param counts Counts of errors, warnings, and critical
* @return Summary text
*/
private static String summary(final ConcurrentHashMap<Severity, Integer> counts) {
private static String summary(final Map<Severity, Integer> counts) {
final List<String> parts = new ArrayList<>(0);
final int critical = counts.get(Severity.CRITICAL);
if (critical > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public final class MjParse extends MjSafe {
static final String CACHE = "parsed";

@Override
@SuppressWarnings("PMD.UnnecessaryLocalRule")
public void exec() {
final long start = System.currentTimeMillis();
final Collection<TjForeign> tojos = this.scopedTojos().withSources();
Expand Down
10 changes: 6 additions & 4 deletions eo-maven-plugin/src/main/java/org/eolang/maven/MjPrint.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,12 @@ void exec() throws IOException {
this.printSourcesDir.toPath().relativize(source).toString()
.replace(".xmir", ".eo")
);
final String program = new Xmir(
new XMLDocument(new TextOf(source).asString())
).toEO();
new Saved(program, home.resolve(relative)).value();
new Saved(
new Xmir(
new XMLDocument(new TextOf(source).asString())
).toEO(),
home.resolve(relative)
).value();
Logger.info(
this,
"Printed: %[file]s (%[size]s) => %[file]s (%[size]s)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public void exec() throws IOException {
/**
* Probe objects.
*/
@SuppressWarnings("PMD.UnnecessaryLocalRule")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Test 1: Search for any definition or declaration of UnnecessaryLocalRule in the repo
echo "=== Test 1: Searching for UnnecessaryLocalRule definition ==="
rg -rn "UnnecessaryLocalRule" --type java --type xml -A 2 2>/dev/null || echo "(no results)"

# Test 2: Check for other `@SuppressWarnings` usages with PMD rules
echo -e "\n=== Test 2: Other `@SuppressWarnings` with PMD rules ==="
rg -rn 'SuppressWarnings.*PMD\.Unnecessary' --type java -C 1 2>/dev/null || echo "(no results)"

# Test 3: List all `@SuppressWarnings` in the file to see usage patterns
echo -e "\n=== Test 3: All `@SuppressWarnings` in MjProbe.java ==="
rg -n '@SuppressWarnings' eo-maven-plugin/src/main/java/org/eolang/maven/MjProbe.java 2>/dev/null || echo "(not found)"

Repository: objectionary/eo

Length of output: 33366


🏁 Script executed:

#!/bin/bash
# Test 4: Get the full context of the probe() method to verify locals usage
echo "=== Test 4: probe() method context (lines 55-82) ==="
sed -n '55,82p' eo-maven-plugin/src/main/java/org/eolang/maven/MjProbe.java

Repository: objectionary/eo

Length of output: 1260


🏁 Script executed:

#!/bin/bash
# Test 5: Check Qulice/Maven configuration files for custom rule definitions
echo "=== Test 5: Qulice configuration and custom rule definitions ==="
find . -name "pom.xml" -o -name "qulice.xml" -o -name "*rule*.xml" 2>/dev/null | head -20
echo -e "\n=== Checking pom.xml for Qulice dependency version ==="
rg -n "qulice-maven-plugin|qulice" pom.xml -A 2 2>/dev/null | head -30

Repository: objectionary/eo

Length of output: 585


🏁 Script executed:

#!/bin/bash
# Additional verification: Check if there's any Qulice/PMD configuration that might define this rule
echo "=== Searching for qulice or PMD rule configuration files ==="
find . -type f \( -name "*.xml" -o -name "*.properties" -o -name "qulice*" \) | xargs grep -l "UnnecessaryLocal" 2>/dev/null || echo "(no match found)"

# Check if there's a checkstyle or PMD config that mentions this rule
echo -e "\n=== Checking for Qulice/PMD config files ==="
find . -type f \( -name "checkstyle*.xml" -o -name "pmd*.xml" -o -name "*qulice*.xml" \) 2>/dev/null | head -10

Repository: objectionary/eo

Length of output: 182


🏁 Script executed:

#!/bin/bash
# Verify the exact annotation by examining the actual file
echo "=== Exact context of line 55 in MjProbe.java ==="
sed -n '54,60p' eo-maven-plugin/src/main/java/org/eolang/maven/MjProbe.java

Repository: objectionary/eo

Length of output: 432


Replace or remove the unrecognized PMD rule name PMD.UnnecessaryLocalRule.

The rule UnnecessaryLocalRule is not a recognized PMD rule. The standard PMD rule for unnecessary local variables is UnnecessaryLocalBeforeReturn (under category/java/codestyle.xml). No custom rule by the name UnnecessaryLocalRule exists in the project's Qulice configuration.

Furthermore, the probe() method does not match the pattern that would trigger UnnecessaryLocalBeforeReturn in any case: it is a void method (no return statement), and all three local variables—tojos, start, and probed—are each referenced multiple times within the method body.

Either correct the rule name to PMD.UnnecessaryLocalBeforeReturn if a specific rule check is intended, or remove the annotation entirely if no suppression is needed.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@eo-maven-plugin/src/main/java/org/eolang/maven/MjProbe.java` at line 55, The
`@SuppressWarnings`("PMD.UnnecessaryLocalRule") annotation in MjProbe.java is
using a non-existent PMD rule; open the MjProbe class and locate the annotation
on the probe() method and either remove the `@SuppressWarnings` entry entirely
(preferred since probe() is void and locals are used) or change the rule name to
the correct PMD identifier
"@SuppressWarnings(\"PMD.UnnecessaryLocalBeforeReturn\")" if you truly intend to
suppress that specific check; update the annotation text accordingly so it
references a valid PMD rule or delete the annotation.

private void probe() {
final Collection<TjForeign> tojos = this.scopedTojos().unprobed();
if (tojos.isEmpty()) {
Expand Down
14 changes: 7 additions & 7 deletions eo-maven-plugin/src/main/java/org/eolang/maven/MjPull.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,17 @@ public final class MjPull extends MjSafe {

@Override
public void exec() throws IOException {
final var objectionary = new OyIndexed(
new OyCached(new OyRemote(this.hash, this.proxies()))
);
if (this.offline) {
Logger.info(
this,
"No programs were pulled because eo.offline flag is TRUE"
);
} else {
this.pull(objectionary);
this.pull(
new OyIndexed(
new OyCached(new OyRemote(this.hash, this.proxies()))
)
);
}
}

Expand All @@ -59,7 +60,7 @@ public void exec() throws IOException {
* @param objectionary Objectionary to pull from
* @throws IOException If fails
*/
@SuppressWarnings("PMD.PrematureDeclaration")
@SuppressWarnings("PMD.UnnecessaryLocalRule")
private void pull(final OyIndexed objectionary) throws IOException {
final long start = System.currentTimeMillis();
final Collection<TjForeign> tojos = this.scopedTojos().withoutSources();
Expand Down Expand Up @@ -116,11 +117,10 @@ private Path pulled(
final String object,
final Path base,
final String hsh) throws IOException {
final String semver = this.plugin.getVersion();
final Path target = new Place(object).make(base, MjAssemble.EO);
final Supplier<Path> che = new CachePath(
this.cache.toPath().resolve(MjPull.CACHE),
semver,
this.plugin.getVersion(),
hsh,
base.relativize(target)
);
Expand Down
Loading
Loading