Closed c71n93 closed 6 months ago
@c71n93 thanks for the report, here is a feedback:
I would recommend including clear, step-by-step instructions to reproduce the error in the bug report.
Please fix the bug report in order it to get resolved faster.
Analyzed with gpt-4
@yegor256 As expected this problem occured in this project too: in this PR (#1268), in windows workflow (https://github.com/yegor256/qulice/actions/runs/9003058334/job/24732811660?pr=1268).
@pnatashap may you can take a look?
What is strange, the error is the same "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)" and φ is not a '\u2020' symbol (and is not considered as a good symbol in PMD, that's why we have a error). Looks like something is wrong with encoding, will check on windows env
@c71n93 the reason is in PMD, they use system property file.encoding to get default encoding, on Windows env it have Cp1251 (Check https://github.com/pmd/pmd/blob/master/pmd-core/src/main/java/net/sourceforge/pmd/AbstractConfiguration.java#L38 it is still the same in current version). So you need to set it up at least for now. Example - https://github.com/pnatashap/qulice/pull/9
@yegor256 There two variants to fix: 1. Keep code as is, because it can be fixed using system variables 2. add a parameter to set up encoding explicitly (also MVN parameter project.build.sourceEncoding can be used)
@pnatashap I believe, sourceEncoding
is set correctly in the pom.xml
where the problem was reported. @c71n93 am I right?
@yegor256 as far as I understand, no, sourceEncoding
is not set in the pom.xml
anywhere in eo.
@c71n93 eo project uses jcabi-parent (as a parent POM), where this is set: https://github.com/jcabi/jcabi-parent/blob/master/pom.xml#L96-L97
@yegor256 @c71n93 sourceEncoding doesn't help for now, only env variables will help. It is possible to set up encoding explicitly for PMD via context using this method (and get this data from sourceEncoding) https://github.com/pmd/pmd/blob/ef3455348603aa25f86894b9930f05f141f44d20/pmd-core/src/main/java/net/sourceforge/pmd/AbstractConfiguration.java#L41-L43
For now workaround is to set up
JAVA_OPTS: "%JAVA_OPTS% -Dfile.encoding=UTF-8"
@c71n93 please check PR #1273 on your project
PMD fails to analyze Java source with variables or methods named with unicode characters. The exception only appears in windows workflow. PMD failed in this (https://github.com/objectionary/eo/pull/3171) PR, for this (https://github.com/objectionary/eo/actions/runs/8973844023/job/24644892711?pr=3171) workflow.
Example of error message:
Part of the Java source file (
eo\eo-runtime\src\main\java\org\eolang\AtComposite.java
) related to this particular error:There was similar issues in PMD (https://github.com/pmd/pmd/issues/3423) but as I understand, they were resolved in the PMD version that qulice currently uses.
@yegor256 I was hoping to see why windows CI doesn't crash with the same error in this project, but I found that there is no tests in
qulice-pmd
that contains unicode characters. I think it's worth adding these tests to understand the cause of the error that I described above.