diff --git a/eo-runtime/pom.xml b/eo-runtime/pom.xml
index aa6744a1e3..19d5461f5f 100644
--- a/eo-runtime/pom.xml
+++ b/eo-runtime/pom.xml
@@ -336,7 +336,14 @@ SOFTWARE.
qulice-maven-plugin
- pmd:.*
+
+ pmd:/src/main/java/EOorg/.*
+ pmd:/src/test/java/EOorg/.*
dependencies:org.eolang:eo-maven-plugin
diff --git a/eo-runtime/src/main/java/org/eolang/Bytes.java b/eo-runtime/src/main/java/org/eolang/Bytes.java
index c3cdc12869..ea6cbaa511 100644
--- a/eo-runtime/src/main/java/org/eolang/Bytes.java
+++ b/eo-runtime/src/main/java/org/eolang/Bytes.java
@@ -51,8 +51,9 @@ public interface Bytes {
* OR operation.
* @param other Bytes.
* @return Bytes.
- * @checkstyle MethodNameCheck (2 lines)
+ * @checkstyle MethodNameCheck (3 lines)
*/
+ @SuppressWarnings("PMD.ShortMethodName")
Bytes or(Bytes other);
/**
diff --git a/eo-runtime/src/main/java/org/eolang/BytesOf.java b/eo-runtime/src/main/java/org/eolang/BytesOf.java
index cefb3a5822..af6260bd6d 100644
--- a/eo-runtime/src/main/java/org/eolang/BytesOf.java
+++ b/eo-runtime/src/main/java/org/eolang/BytesOf.java
@@ -31,8 +31,14 @@
* Bytes.
*
* @since 1.0
+ * @todo #3160:90min This class requires refactoring. As a result of refactoring you should remove
+ * {@code @SuppressWarnings("PMD.GodClass")} from this class and
+ * {@code @SuppressWarnings("PMD.CognitiveComplexity")} from {@link BytesOf#shift} method. You can
+ * check description of this rules here
+ * pmd.github.io
*/
@Versionized
+@SuppressWarnings({"PMD.TooManyMethods", "PMD.GodClass"})
public final class BytesOf implements Bytes {
/**
@@ -45,7 +51,7 @@ public final class BytesOf implements Bytes {
* @param data Data.
*/
public BytesOf(final byte[] data) {
- this.data = data;
+ this.data = Arrays.copyOf(data, data.length);
}
/**
@@ -108,6 +114,7 @@ public Bytes and(final Bytes other) {
}
@Override
+ @SuppressWarnings("PMD.ShortMethodName")
public Bytes or(final Bytes other) {
final byte[] first = this.take();
final byte[] second = other.take();
@@ -128,6 +135,7 @@ public Bytes xor(final Bytes other) {
}
@Override
+ @SuppressWarnings("PMD.CognitiveComplexity")
public Bytes shift(final int bits) {
// @checkstyle MethodBodyCommentsCheck (3 lines)
// @checkstyle NestedIfDepthCheck (40 lines)
diff --git a/eo-runtime/src/main/java/org/eolang/Data.java b/eo-runtime/src/main/java/org/eolang/Data.java
index e295e00896..877abcb13b 100644
--- a/eo-runtime/src/main/java/org/eolang/Data.java
+++ b/eo-runtime/src/main/java/org/eolang/Data.java
@@ -32,6 +32,7 @@
* @since 0.1
*/
@Versionized
+@SuppressWarnings("PMD.TooManyMethods")
public interface Data {
/**
* Attach data to the object.
@@ -192,11 +193,20 @@ private static Phi toPhi(final Object obj) {
*
* @param str A string optionally containing standard java escape sequences.
* @return The translated string
+ * @todo #3160:90min This method should be refactored because it has high cognitive
+ * complexity and other problems. All {@code @checkstyle} warnings suppression and
+ * {@code SuppressWarnings("PMD.WarningName")} annotations for this method should be
+ * removed as a result of refactoring.
* @checkstyle CyclomaticComplexityCheck (100 lines)
* @checkstyle JavaNCSSCheck (100 lines)
* @checkstyle NestedIfDepthCheck (100 lines)
* @checkstyle ModifiedControlVariableCheck (100 lines)
*/
+ @SuppressWarnings({
+ "PMD.AvoidReassigningLoopVariables",
+ "PMD.CognitiveComplexity",
+ "PMD.NPathComplexity"
+ })
private static String unescapeJavaString(final String str) {
final StringBuilder unescaped = new StringBuilder(str.length());
for (int idx = 0; idx < str.length(); ++idx) {
@@ -209,19 +219,19 @@ private static String unescapeJavaString(final String str) {
next = str.charAt(idx + 1);
}
if (next >= '0' && next <= '7') {
- String code = String.valueOf(next);
+ final StringBuilder code = new StringBuilder(String.valueOf(next));
++idx;
if (idx < str.length() - 1 && str.charAt(idx + 1) >= '0'
&& str.charAt(idx + 1) <= '7') {
- code += str.charAt(idx + 1);
+ code.append(str.charAt(idx + 1));
++idx;
if (idx < str.length() - 1 && str.charAt(idx + 1) >= '0'
&& str.charAt(idx + 1) <= '7') {
- code += str.charAt(idx + 1);
+ code.append(str.charAt(idx + 1));
++idx;
}
}
- unescaped.append((char) Integer.parseInt(code, 8));
+ unescaped.append((char) Integer.parseInt(code.toString(), 8));
continue;
}
switch (next) {
diff --git a/eo-runtime/src/main/java/org/eolang/Dataized.java b/eo-runtime/src/main/java/org/eolang/Dataized.java
index 75c1e6b479..d63d11dce0 100644
--- a/eo-runtime/src/main/java/org/eolang/Dataized.java
+++ b/eo-runtime/src/main/java/org/eolang/Dataized.java
@@ -150,14 +150,4 @@ public T take(final Class type) {
}
return type.cast(strong);
}
-
- /**
- * Clean up resources.
- * This includes call of {@link ThreadLocal#remove()} method to prevent
- * memory leaks.
- */
- public static void cleanUp() {
- Dataized.LEVEL.remove();
- Dataized.MAX_LEVEL.remove();
- }
}
diff --git a/eo-runtime/src/main/java/org/eolang/ExAbstract.java b/eo-runtime/src/main/java/org/eolang/ExAbstract.java
index 2229c390fa..f92e0d971c 100644
--- a/eo-runtime/src/main/java/org/eolang/ExAbstract.java
+++ b/eo-runtime/src/main/java/org/eolang/ExAbstract.java
@@ -42,25 +42,26 @@ public abstract class ExAbstract extends RuntimeException {
/**
* Ctor.
+ * @param cause Exception cause
*/
- public ExAbstract() {
- this(null);
+ public ExAbstract(final String cause) {
+ super(cause);
}
/**
* Ctor.
* @param cause Exception cause
+ * @param root Root cause exception
*/
- public ExAbstract(final String cause) {
- super(cause);
+ public ExAbstract(final String cause, final Throwable root) {
+ super(cause, root);
}
/**
* Ctor.
- * @param cause Exception cause
* @param root Root cause exception
*/
- ExAbstract(final String cause, final Throwable root) {
- super(cause, root);
+ public ExAbstract(final Throwable root) {
+ super(root);
}
}
diff --git a/eo-runtime/src/main/java/org/eolang/ExInterrupted.java b/eo-runtime/src/main/java/org/eolang/ExInterrupted.java
index cc5da73fbc..50e3ad9675 100644
--- a/eo-runtime/src/main/java/org/eolang/ExInterrupted.java
+++ b/eo-runtime/src/main/java/org/eolang/ExInterrupted.java
@@ -38,8 +38,9 @@ public class ExInterrupted extends ExAbstract {
/**
* Ctor.
+ * @param root Root cause exception
*/
- public ExInterrupted() {
- super(null);
+ public ExInterrupted(final InterruptedException root) {
+ super(root);
}
}
diff --git a/eo-runtime/src/main/java/org/eolang/Main.java b/eo-runtime/src/main/java/org/eolang/Main.java
index 27c36f223d..5cfad3dce5 100644
--- a/eo-runtime/src/main/java/org/eolang/Main.java
+++ b/eo-runtime/src/main/java/org/eolang/Main.java
@@ -49,6 +49,7 @@
* @since 0.1
*/
@Versionized
+@SuppressWarnings("PMD.MoreThanOneLogger")
public final class Main {
/**
@@ -182,7 +183,8 @@ private static void run(final List opts) throws Exception {
.newInstance();
} catch (final ClassNotFoundException ex) {
throw new ExUnset(
- String.format("Can not find '%s' object", opts.get(0))
+ String.format("Can not find '%s' object", opts.get(0)),
+ ex
);
}
if (opts.size() > 1) {
diff --git a/eo-runtime/src/main/java/org/eolang/PhDefault.java b/eo-runtime/src/main/java/org/eolang/PhDefault.java
index d356ff0020..3c1ed00624 100644
--- a/eo-runtime/src/main/java/org/eolang/PhDefault.java
+++ b/eo-runtime/src/main/java/org/eolang/PhDefault.java
@@ -42,7 +42,7 @@
* @checkstyle DesignForExtensionCheck (500 lines)
*/
@Versionized
-@SuppressWarnings({"PMD.TooManyMethods", "PMD.ConstructorShouldDoInitialization"})
+@SuppressWarnings({"PMD.TooManyMethods", "PMD.GodClass"})
public class PhDefault implements Phi, Cloneable {
/**
* Vertices.
@@ -74,7 +74,7 @@ public class PhDefault implements Phi, Cloneable {
* Data.
* @checkstyle VisibilityModifierCheck (2 lines)
*/
- private AtomicReference data = new AtomicReference<>(null);
+ private AtomicReference data;
/**
* Forma of it.
@@ -96,6 +96,7 @@ public class PhDefault implements Phi, Cloneable {
*/
@SuppressWarnings("PMD.ConstructorOnlyInitializesOrCallOtherConstructors")
public PhDefault() {
+ this.data = new AtomicReference<>(null);
this.vertex = PhDefault.VTX.next();
this.form = this.getClass().getName();
this.attrs = new HashMap<>(0);
@@ -300,15 +301,6 @@ public String forma() {
return this.form;
}
- /**
- * Clean up resources.
- * This includes call of {@link ThreadLocal#remove()} method to prevent
- * memory leaks.
- */
- public static void cleanUp() {
- PhDefault.NESTING.remove();
- }
-
/**
* Add new attribute.
*
diff --git a/eo-runtime/src/main/java/org/eolang/PhFake.java b/eo-runtime/src/main/java/org/eolang/PhFake.java
index d723824b5f..959b3dca40 100644
--- a/eo-runtime/src/main/java/org/eolang/PhFake.java
+++ b/eo-runtime/src/main/java/org/eolang/PhFake.java
@@ -47,6 +47,7 @@ public PhFake() {
* Ctor.
* @param sup The function to return the real object
*/
+ @SuppressWarnings("PMD.ConstructorOnlyInitializesOrCallOtherConstructors")
public PhFake(final Supplier sup) {
this.add("args", new AtVoid("args"));
this.add("φ", new AtComposite(this, rho -> sup.get()));
diff --git a/eo-runtime/src/main/java/org/eolang/PhLocated.java b/eo-runtime/src/main/java/org/eolang/PhLocated.java
index 33458ae922..ded8ce8da7 100644
--- a/eo-runtime/src/main/java/org/eolang/PhLocated.java
+++ b/eo-runtime/src/main/java/org/eolang/PhLocated.java
@@ -29,6 +29,7 @@
*
* @since 0.21
*/
+@SuppressWarnings("PMD.TooManyMethods")
@Versionized
public final class PhLocated implements Phi {
diff --git a/eo-runtime/src/main/java/org/eolang/PhLogged.java b/eo-runtime/src/main/java/org/eolang/PhLogged.java
index 27356f0f29..5692a1d1b4 100644
--- a/eo-runtime/src/main/java/org/eolang/PhLogged.java
+++ b/eo-runtime/src/main/java/org/eolang/PhLogged.java
@@ -34,6 +34,7 @@
* @since 0.24
*/
@Versionized
+@SuppressWarnings({"PMD.TooManyMethods", "PMD.SystemPrintln"})
public final class PhLogged implements Phi {
/**
diff --git a/eo-runtime/src/main/java/org/eolang/PhNamed.java b/eo-runtime/src/main/java/org/eolang/PhNamed.java
index d5b0157b76..5de26bb4f7 100644
--- a/eo-runtime/src/main/java/org/eolang/PhNamed.java
+++ b/eo-runtime/src/main/java/org/eolang/PhNamed.java
@@ -30,6 +30,7 @@
* @since 0.17
*/
@Versionized
+@SuppressWarnings("PMD.TooManyMethods")
final class PhNamed implements Phi {
/**
diff --git a/eo-runtime/src/main/java/org/eolang/PhOnce.java b/eo-runtime/src/main/java/org/eolang/PhOnce.java
index 466d103e02..a5ce5f6214 100644
--- a/eo-runtime/src/main/java/org/eolang/PhOnce.java
+++ b/eo-runtime/src/main/java/org/eolang/PhOnce.java
@@ -33,6 +33,7 @@
* @since 0.1
*/
@Versionized
+@SuppressWarnings("PMD.TooManyMethods")
class PhOnce implements Phi {
/**
diff --git a/eo-runtime/src/main/java/org/eolang/PhPackage.java b/eo-runtime/src/main/java/org/eolang/PhPackage.java
index 6177f82c07..7badbf4942 100644
--- a/eo-runtime/src/main/java/org/eolang/PhPackage.java
+++ b/eo-runtime/src/main/java/org/eolang/PhPackage.java
@@ -35,6 +35,7 @@
* @since 0.22
*/
@Versionized
+@SuppressWarnings("PMD.TooManyMethods")
final class PhPackage implements Phi {
/**
@@ -45,9 +46,7 @@ final class PhPackage implements Phi {
/**
* All of them.
*/
- private final ThreadLocal