Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#3160 Enable PMD for eo-runime #3171

Merged
merged 26 commits into from
Jun 25, 2024

Conversation

c71n93
Copy link
Member

@c71n93 c71n93 commented May 6, 2024

Closes #3160


PR-Codex overview

This PR focuses on code cleanup and improvements.

Detailed summary

  • Removed unused classes PhWrite and PhOnce
  • Added @SuppressWarnings annotations for PMD violations
  • Updated constructors and exception handling in various classes
  • Refactored method names and added annotations
  • Improved exception handling in SafeFunc class

The following files were skipped due to too many changes: eo-runtime/src/test/java/org/eolang/UniverseDefaultTest.java, eo-runtime/src/main/java/org/eolang/PhDefault.java, eo-runtime/src/main/java/org/eolang/BytesOf.java, eo-runtime/src/main/java/org/eolang/Data.java, eo-runtime/src/test/java/EOorg/EOeolang/EOcageTest.java, eo-runtime/src/main/java/org/eolang/PhTraced.java, eo-runtime/src/test/java/org/eolang/DataizedTest.java, eo-runtime/src/test/java/org/eolang/SnippetTestCase.java, eo-runtime/src/test/java/org/eolang/PhDefaultTest.java

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

@c71n93
Copy link
Member Author

c71n93 commented May 6, 2024

@maxonfjvipon could you check this one, please?

@c71n93
Copy link
Member Author

c71n93 commented May 6, 2024

@maxonfjvipon oops, it looks like something went wrong with PMD check on windows. Looks like internal PMD error. Have you ever come across something like this?

2024-05-06T18:35:20.8319792Z [INFO] PMD: D:\a\eo\eo\eo-runtime\src\main\java\org\eolang\AtComposite.java[unknown]: PMDException: Error while processing D:\a\eo\eo\eo-runtime\src\main\java\org\eolang\AtComposite.java: net.sourceforge.pmd.PMDException: Error while processing D:\a\eo\eo\eo-runtime\src\main\java\org\eolang\AtComposite.java
2024-05-06T18:35:20.8325885Z 	at net.sourceforge.pmd.SourceCodeProcessor.processSourceCodeWithoutCache(SourceCodeProcessor.java:128)
2024-05-06T18:35:20.8327642Z 	at net.sourceforge.pmd.SourceCodeProcessor.processSourceCode(SourceCodeProcessor.java:100)
2024-05-06T18:35:20.8329641Z 	at net.sourceforge.pmd.SourceCodeProcessor.processSourceCode(SourceCodeProcessor.java:62)
2024-05-06T18:35:20.8333094Z 	at net.sourceforge.pmd.processor.PmdRunnable.call(PmdRunnable.java:89)
2024-05-06T18:35:20.8336483Z 	at net.sourceforge.pmd.processor.MonoThreadProcessor.runAnalysis(MonoThreadProcessor.java:32)
2024-05-06T18:35:20.8341693Z 	at net.sourceforge.pmd.processor.AbstractPMDProcessor.processFiles(AbstractPMDProcessor.java:143)
2024-05-06T18:35:20.8344982Z 	at net.sourceforge.pmd.processor.AbstractPMDProcessor.processFiles(AbstractPMDProcessor.java:123)
2024-05-06T18:35:20.8347679Z 	at net.sourceforge.pmd.PMD.processFiles(PMD.java:322)
2024-05-06T18:35:20.8349328Z 	at com.qulice.pmd.SourceValidator.validateOne(SourceValidator.java:130)
2024-05-06T18:35:20.8351728Z 	at com.qulice.pmd.SourceValidator.validate(SourceValidator.java:105)
2024-05-06T18:35:20.8353447Z 	at com.qulice.pmd.PmdValidator.validate(PmdValidator.java:67)
2024-05-06T18:35:20.8355075Z 	at com.qulice.maven.CheckMojo$ValidatorCallable.call(CheckMojo.java:237)
2024-05-06T18:35:20.8357390Z 	at com.qulice.maven.CheckMojo$ValidatorCallable.call(CheckMojo.java:205)
2024-05-06T18:35:20.8359571Z 	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
2024-05-06T18:35:20.8361442Z 	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
2024-05-06T18:35:20.8364028Z 	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
2024-05-06T18:35:20.8365987Z 	at java.base/java.lang.Thread.run(Thread.java:829)
2024-05-06T18:35:20.8369028Z Caused by: net.sourceforge.pmd.lang.ast.TokenMgrError: Lexical error at line 61, column 22.  Encountered: "\u2020" (8224), after : "" (in lexical state 0)
2024-05-06T18:35:20.8373051Z 	at net.sourceforge.pmd.lang.java.ast.JavaParserTokenManager.getNextToken(JavaParserTokenManager.java:2534)
2024-05-06T18:35:20.8375895Z 	at net.sourceforge.pmd.lang.java.ast.JavaParser.jj_consume_token(JavaParser.java:14281)
2024-05-06T18:35:20.8379388Z 	at net.sourceforge.pmd.lang.java.ast.JavaParser.PrimarySuffix(JavaParser.java:5270)
2024-05-06T18:35:20.8382917Z 	at net.sourceforge.pmd.lang.java.ast.JavaParser.PrimaryExpression(JavaParser.java:4680)
2024-05-06T18:35:20.8385610Z 	at net.sourceforge.pmd.lang.java.ast.JavaParser.PostfixExpression(JavaParser.java:4494)
2024-05-06T18:35:20.8388757Z 	at net.sourceforge.pmd.lang.java.ast.JavaParser.UnaryExpressionNotPlusMinus(JavaParser.java:4392)
2024-05-06T18:35:20.8391888Z 	at net.sourceforge.pmd.lang.java.ast.JavaParser.UnaryExpression(JavaParser.java:4269)
2024-05-06T18:35:20.8394940Z 	at net.sourceforge.pmd.lang.java.ast.JavaParser.MultiplicativeExpression(JavaParser.java:4184)
2024-05-06T18:35:20.8397995Z 	at net.sourceforge.pmd.lang.java.ast.JavaParser.AdditiveExpression(JavaParser.java:4131)
2024-05-06T18:35:20.8400882Z 	at net.sourceforge.pmd.lang.java.ast.JavaParser.ShiftExpression(JavaParser.java:4074)
2024-05-06T18:35:20.8403983Z 	at net.sourceforge.pmd.lang.java.ast.JavaParser.RelationalExpression(JavaParser.java:4013)
2024-05-06T18:35:20.8406696Z 	at net.sourceforge.pmd.lang.java.ast.JavaParser.InstanceOfExpression(JavaParser.java:3941)
2024-05-06T18:35:20.8409813Z 	at net.sourceforge.pmd.lang.java.ast.JavaParser.EqualityExpression(JavaParser.java:3686)
2024-05-06T18:35:20.8412868Z 	at net.sourceforge.pmd.lang.java.ast.JavaParser.AndExpression(JavaParser.java:3646)
2024-05-06T18:35:20.8415768Z 	at net.sourceforge.pmd.lang.java.ast.JavaParser.ExclusiveOrExpression(JavaParser.java:3606)
2024-05-06T18:35:20.8418568Z 	at net.sourceforge.pmd.lang.java.ast.JavaParser.InclusiveOrExpression(JavaParser.java:3566)
2024-05-06T18:35:20.8421940Z 	at net.sourceforge.pmd.lang.java.ast.JavaParser.ConditionalAndExpression(JavaParser.java:3526)
2024-05-06T18:35:20.8424760Z 	at net.sourceforge.pmd.lang.java.ast.JavaParser.ConditionalOrExpression(JavaParser.java:3486)
2024-05-06T18:35:20.8427832Z 	at net.sourceforge.pmd.lang.java.ast.JavaParser.ConditionalExpression(JavaParser.java:3448)
2024-05-06T18:35:20.8430697Z 	at net.sourceforge.pmd.lang.java.ast.JavaParser.Expression(JavaParser.java:3307)
2024-05-06T18:35:20.8435868Z 	at net.sourceforge.pmd.lang.java.ast.JavaParser.ReturnStatement(JavaParser.java:6990)
2024-05-06T18:35:20.8446583Z 	at net.sourceforge.pmd.lang.java.ast.JavaParser.Statement(JavaParser.java:5799)
2024-05-06T18:35:20.8450644Z 	at net.sourceforge.pmd.lang.java.ast.JavaParser.BlockStatement(JavaParser.java:5971)
2024-05-06T18:35:20.8453924Z 	at net.sourceforge.pmd.lang.java.ast.JavaParser.Block(JavaParser.java:5888)
2024-05-06T18:35:20.8458729Z 	at net.sourceforge.pmd.lang.java.ast.JavaParser.MethodDeclaration(JavaParser.java:2201)
2024-05-06T18:35:20.8462293Z 	at net.sourceforge.pmd.lang.java.ast.JavaParser.ClassOrInterfaceBodyDeclaration(JavaParser.java:1855)
2024-05-06T18:35:20.8465229Z 	at net.sourceforge.pmd.lang.java.ast.JavaParser.ClassOrInterfaceBody(JavaParser.java:1808)
2024-05-06T18:35:20.8468312Z 	at net.sourceforge.pmd.lang.java.ast.JavaParser.ClassOrInterfaceDeclaration(JavaParser.java:936)
2024-05-06T18:35:20.8471294Z 	at net.sourceforge.pmd.lang.java.ast.JavaParser.TypeDeclaration(JavaParser.java:838)
2024-05-06T18:35:20.8474144Z 	at net.sourceforge.pmd.lang.java.ast.JavaParser.CompilationUnit(JavaParser.java:558)
2024-05-06T18:35:20.8477198Z 	at net.sourceforge.pmd.lang.java.AbstractJavaParser.parse(AbstractJavaParser.java:62)
2024-05-06T18:35:20.8479692Z 	at net.sourceforge.pmd.lang.AbstractParser.doParse(AbstractParser.java:45)
2024-05-06T18:35:20.8484630Z 	at net.sourceforge.pmd.SourceCodeProcessor.parse(SourceCodeProcessor.java:136)
2024-05-06T18:35:20.8487198Z 	at net.sourceforge.pmd.SourceCodeProcessor.processSource(SourceCodeProcessor.java:200)
2024-05-06T18:35:20.8489778Z 	at net.sourceforge.pmd.SourceCodeProcessor.processSourceCodeWithoutCache(SourceCodeProcessor.java:118)
2024-05-06T18:35:20.8491860Z 	... 16 more
2024-05-06T18:35:20.8492229Z  (ProcessingError)

@maxonfjvipon
Copy link
Member

@c71n93 no, I use macos)

@c71n93
Copy link
Member Author

c71n93 commented May 6, 2024

@maxonfjvipon me too. But unfortunately we have windows CI :(

@maxonfjvipon
Copy link
Member

@c71n93 did you try to find the solution on stackoverflow?

@c71n93
Copy link
Member Author

c71n93 commented May 6, 2024

@maxonfjvipon not yet. But according to #3160 (comment) there was some problems with PMD and eo-runtime earlier. I assume that this (#3171 (comment)) is the problem.

@c71n93
Copy link
Member Author

c71n93 commented May 7, 2024

@c71n93 c71n93 force-pushed the 3160-enable-pmd-in-eo-runtime branch from 7644b64 to ff1c2ed Compare May 13, 2024 08:21
@c71n93
Copy link
Member Author

c71n93 commented May 13, 2024

@maxonfjvipon could you check this one, please?

Copy link
Member

@maxonfjvipon maxonfjvipon left a comment

Choose a reason for hiding this comment

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

@c71n93 that's awesome! Thanks

@c71n93
Copy link
Member Author

c71n93 commented May 13, 2024

@yegor256 could you check this one, please?

@c71n93
Copy link
Member Author

c71n93 commented May 14, 2024

@yegor256 could you merge this one, please?

@@ -35,6 +35,7 @@
* @since 0.22
*/
@Versionized
@SuppressWarnings({"PMD.TooManyMethods", "PMD.ConstructorShouldDoInitialization"})
Copy link
Member

Choose a reason for hiding this comment

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

@c71n93 I believe, you can easily fix this error (that PMD complains about), instead of suppressing it

public final class PhTraced implements Phi {

/**
* Name of property that responsible for keeping max depth.
*/
@SuppressWarnings("PMD.LongVariable")
Copy link
Member

Choose a reason for hiding this comment

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

@c71n93 why can't you just make the name shorter?

Copy link
Member Author

Choose a reason for hiding this comment

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

@yegor256 Because this variable means "maximum cage recursion depth". As for me the shortest name for this variable is MAX_CAGE_RECURSION. However max length of variable is two words. Any two-word options don't seem informative enough to me (MAX_RECURSION, MAX_CAGE, CAGE_RECURSION).

Copy link
Member

Choose a reason for hiding this comment

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

@c71n93 how about RECURSION_THRESHOLD? The name of the class already provides a lot of semantic: PhTraced.RECURSION_THRESHOLD -- sounds good.

Copy link
Member Author

Choose a reason for hiding this comment

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

@maxonfjvipon do we need this class? It never used now.

Copy link
Member

Choose a reason for hiding this comment

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

@c71n93 we don't need it

Copy link
Member Author

@c71n93 c71n93 May 16, 2024

Choose a reason for hiding this comment

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

@yegor256 @maxonfjvipon maybe we can move this class to eo-runtime/src/test/java/EOorg/EOeolang/? (it uses only there)

Copy link
Member

Choose a reason for hiding this comment

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

@c71n93 I believe it should stay in org.eolang since it's kind of part of common runtime object which are used for building the concrete ones

@c71n93
Copy link
Member Author

c71n93 commented May 16, 2024

@maxonfjvipon @yegor256 I resolved all I could.

@c71n93
Copy link
Member Author

c71n93 commented May 21, 2024

@yegor256 @maxonfjvipon could you check this one again, please?

@c71n93
Copy link
Member Author

c71n93 commented May 22, 2024

@yegor256 @maxonfjvipon could you check this one, please? I think it would be nice to enable pmd for eo-runtime as early as possible.

@@ -58,7 +60,7 @@ public final class PhTraced implements Phi {
/**
* Locator of encaged object.
*/
private final Integer locator;
private final Integer locatr;
Copy link
Member

Choose a reason for hiding this comment

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

@c71n93 what was wrong with locator name?

Copy link
Member Author

Choose a reason for hiding this comment

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

@maxonfjvipon it repeats the method name (prohibited by PMD)

Copy link
Member

@maxonfjvipon maxonfjvipon left a comment

Choose a reason for hiding this comment

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

see above

@c71n93
Copy link
Member Author

c71n93 commented May 23, 2024

@yegor256 could you check this one, please?

@yegor256
Copy link
Member

@c71n93 one small comment above and we are good to go

@c71n93
Copy link
Member Author

c71n93 commented May 27, 2024

@yegor256 done. could you check it please?

@c71n93
Copy link
Member Author

c71n93 commented May 28, 2024

@yegor256 could you check this one, please?

2 similar comments
@c71n93
Copy link
Member Author

c71n93 commented May 29, 2024

@yegor256 could you check this one, please?

@c71n93
Copy link
Member Author

c71n93 commented May 30, 2024

@yegor256 could you check this one, please?

@c71n93
Copy link
Member Author

c71n93 commented Jun 24, 2024

@yegor256 I updated this branch. Could we finally merge it?

@yegor256
Copy link
Member

@rultor merge

@rultor
Copy link
Contributor

rultor commented Jun 25, 2024

@rultor merge

@yegor256 OK, I'll try to merge now. You can check the progress of the merge here

@rultor rultor merged commit ba2a9e3 into objectionary:master Jun 25, 2024
22 checks passed
@rultor
Copy link
Contributor

rultor commented Jun 25, 2024

@rultor merge

@yegor256 Done! FYI, the full log is here (took me 24min)

@yegor256
Copy link
Member

@c71n93 thanks!

@c71n93 c71n93 deleted the 3160-enable-pmd-in-eo-runtime branch June 26, 2024 08:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PMD check disabled for entire eo-runtime
5 participants