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

update PMD ruleset.xml #2317

Merged
merged 2 commits into from
Nov 6, 2024
Merged

update PMD ruleset.xml #2317

merged 2 commits into from
Nov 6, 2024

Conversation

yagee-de
Copy link
Member

@yagee-de yagee-de commented Nov 4, 2024

Copy link
Member

@golsch golsch left a comment

Choose a reason for hiding this comment

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

Looks good to me. All the rules that were defined in the PDM sessions are included.

<rule ref="category/java/bestpractices.xml/NonExhaustiveSwitch"/>
<!-- TODO: Create PR to fix this rule -->
<!--
<rule ref="category/java/bestpractices.xml/SystemPrintln" />
Copy link
Member

Choose a reason for hiding this comment

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

We had defined exceptions, perhaps they should be defined directly here or a general comment.

Copy link
Member Author

Choose a reason for hiding this comment

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

This is up to the PR to enable the rule and implement exceptions in the class

@toKrause
Copy link
Contributor

toKrause commented Nov 5, 2024

Just as an info: Codacy fails with

Java :

KubernetesDockerRunner: Container for codacy/codacy-pmd:3.13.17 exited with non-zero code 1
Error executing the tool
java.lang.IllegalArgumentException: Unable to find referenced rule DefaultLabelNotLastInSwitch; perhaps the rule name is misspelled?
	at net.sourceforge.pmd.RuleSetFactory.parseRuleReferenceNode(RuleSetFactory.java:693)
	at net.sourceforge.pmd.RuleSetFactory.parseRuleNode(RuleSetFactory.java:505)
	at net.sourceforge.pmd.RuleSetFactory.parseRuleSetNode(RuleSetFactory.java:409)
	at net.sourceforge.pmd.RuleSetFactory.createRuleSet(RuleSetFactory.java:234)
	at net.sourceforge.pmd.RuleSetFactory.createRuleSet(RuleSetFactory.java:229)
	at net.sourceforge.pmd.RuleSetFactory.createRuleSets(RuleSetFactory.java:184)
	at net.sourceforge.pmd.RuleSetFactory.createRuleSets(RuleSetFactory.java:165)
	at net.sourceforge.pmd.RulesetsFactoryUtils.getRuleSets(RulesetsFactoryUtils.java:46)
	at com.codacy.pmd.PMD$.apply(PMD.scala:90)
	at com.codacy.tools.scala.seed.DockerEngine.executeTool(DockerEngine.scala:53)
	at com.codacy.tools.scala.seed.DockerEngine.$anonfun$main$2(DockerEngine.scala:35)
	at scala.util.Success.map(Try.scala:262)
	at com.codacy.tools.scala.seed.DockerEngine.$anonfun$main$1(DockerEngine.scala:27)
	at scala.util.Success.flatMap(Try.scala:258)
	at com.codacy.tools.scala.seed.DockerEngine.main(DockerEngine.scala:26)
	at com.codacy.Engine.main(Engine.scala)

Container codacy/codacy-pmd:3.13.17 is the current release of https://github.com/codacy/codacy-pmd.

Looking in the latest revision of the build file reveals that by default version 6.55.0 of PMD is used. Rule DefaultLabelNotLastInSwitch ony exists since version 7.7.0 of PMD.

The last commit there has the following message: "Revert PMD to version 6. Version 7 will be launched as a different tool"

Indeed, there is https://github.com/codacy/codacy-pmd7.

We might need to switch. Not sure how to configure the PMD tool used by the Codacy service and the PMD version used by that tool, since even that version, by default, only uses version 7.6.0 of PMD.

@toKrause
Copy link
Contributor

toKrause commented Nov 5, 2024

There is also a problem with ESLint for JavaScript/TypeScript that also effects other PRs targeting 2024.06.x:

Javascript :

KubernetesDockerRunner: Container for codacy/codacy-eslint:9.17.28 exited with non-zero code 1
ConfigurationNotFoundError: No ESLint configuration found in /src/mycore-webtools/src/main/ts/upload.
    at CascadingConfigArrayFactory._finalizeConfigArray (/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:4000:19)
    at CascadingConfigArrayFactory.getConfigArrayForFile (/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3791:21)
    at FileEnumerator._iterateFilesWithFile (/node_modules/eslint/lib/cli-engine/file-enumerator.js:368:43)
    at FileEnumerator._iterateFiles (/node_modules/eslint/lib/cli-engine/file-enumerator.js:349:25)
    at FileEnumerator.iterateFiles (/node_modules/eslint/lib/cli-engine/file-enumerator.js:299:59)
    at iterateFiles.next (<anonymous>)
    at CLIEngine.executeOnFiles (/node_modules/eslint/lib/cli-engine/cli-engine.js:797:48)
    at ESLint.lintFiles (/node_modules/eslint/lib/eslint/eslint.js:551:23)
    at /dist/src/engineImpl.js:68:46
    at Generator.next (<anonymous>) {
  messageTemplate: 'no-config-found',
  messageData: { directoryPath: '/src/mycore-webtools/src/main/ts/upload' }
}

Not sure what that is about, ...

@yagee-de
Copy link
Member Author

yagee-de commented Nov 5, 2024

Just as an info: Codacy fails with

Java :

KubernetesDockerRunner: Container for codacy/codacy-pmd:3.13.17 exited with non-zero code 1
Error executing the tool
java.lang.IllegalArgumentException: Unable to find referenced rule DefaultLabelNotLastInSwitch; perhaps the rule name is misspelled?
	at net.sourceforge.pmd.RuleSetFactory.parseRuleReferenceNode(RuleSetFactory.java:693)
	at net.sourceforge.pmd.RuleSetFactory.parseRuleNode(RuleSetFactory.java:505)
	at net.sourceforge.pmd.RuleSetFactory.parseRuleSetNode(RuleSetFactory.java:409)
	at net.sourceforge.pmd.RuleSetFactory.createRuleSet(RuleSetFactory.java:234)
	at net.sourceforge.pmd.RuleSetFactory.createRuleSet(RuleSetFactory.java:229)
	at net.sourceforge.pmd.RuleSetFactory.createRuleSets(RuleSetFactory.java:184)
	at net.sourceforge.pmd.RuleSetFactory.createRuleSets(RuleSetFactory.java:165)

We could in theory kill Codacy as our rules are now active for the current ruleset and every new rule has to applied to the then present code before getting activated. So in theory every code that is submitted will fail the build because we check all the code everytime not only the changed code. So practically ther should be no need for Codacy if it's performing the same checks.

@yagee-de
Copy link
Member Author

yagee-de commented Nov 6, 2024

I switched Codacy to the PMD7 module, but it still fails as ESLint does. I would recommend to deactivate PMD7 until it is updated to at least 7.7.0. For ESLint: the error is that config files are missing. Seems to have no link to this PR.

@toKrause
Copy link
Contributor

toKrause commented Nov 6, 2024

Removing PMD from Codacy seem reasonable,

Yes, the ESLint problem seems to be independent from this PR, as it, as I said, effects all PRs targeting 2024.06.x. Still needs to be resolved, in order for this and other PRs to move forward. Don't know what the problem is or who might have a clue. Should probably be resolved separately, so that this PR and the other PRs can be rebased.

@yagee-de
Copy link
Member Author

yagee-de commented Nov 6, 2024

Deactivating PMD7 was enough to make Codacy successful again

@yagee-de yagee-de merged commit d62cd1b into 2024.06.x Nov 6, 2024
3 checks passed
@yagee-de yagee-de deleted the pmd_update_ruleset.xml branch November 6, 2024 15:07
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.

3 participants