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

Support multiple rulesets #65

Closed
adangel opened this issue Oct 5, 2018 · 4 comments
Closed

Support multiple rulesets #65

adangel opened this issue Oct 5, 2018 · 4 comments

Comments

@adangel
Copy link
Member

adangel commented Oct 5, 2018

PR #51 added basic support for multiple rulesets, but full support would be more useful. As explained in the last comment, this is what we need to do:

Currently the plugin deals with a single RuleSet (projectProperties.setProjectRuleSet(...)) and we would
need to change this to take a RuleSets (currently, we get a RuleSets instance, take the first ruleset out
of it, pass it along to the project properties and when we are about to execute PMD, we wrap this single
ruleset again into a RuleSets instance...).

adangel added a commit that referenced this issue Nov 11, 2018
@adangel
Copy link
Member Author

adangel commented Nov 11, 2018

@pkrall520 I've finally merged your multiple rulesets PR!
@regrog Would you mind testing, whether the pmd-eclipse-plugin now handles the multiple rulesets correctly? Thanks!

Snapshot update site: https://dl.bintray.com/pmd/pmd-eclipse-plugin/snapshots/updates/

@regrog
Copy link

regrog commented Nov 12, 2018

I tested this on my little example project and it works #51 (comment)
But in my large project I get this error executing PMD on 1 of submodules: #34

In another submodule I get the error below. But copying MyClass, InternalMyClass and their dependencies in a little plugin it works. Maybe the error is connected ti the issue 34.

Unfortunately, I can't share with you my project. I'll try to reproduce it but I'm not lucky until now.

Edit: executing pmd via gradle command line works.

java.lang.IncompatibleClassChangeError:  MyClass and MyClass$InternalMyClass disagree on InnerClasses attribute
at java.lang.Class.getDeclaringClass0(Native Method)
at java.lang.Class.getDeclaringClass(Class.java:1235)
at java.lang.Class.getEnclosingClass(Class.java:1277)
at java.lang.Class.getSimpleBinaryName(Class.java:1443)
at java.lang.Class.getSimpleName(Class.java:1309)
at java.lang.Class.isAnonymousClass(Class.java:1411)
at net.sourceforge.pmd.lang.java.typeresolution.typedefinition.JavaTypeDefinitionSimple.<init>(JavaTypeDefinitionSimple.java:46)
at net.sourceforge.pmd.lang.java.typeresolution.typedefinition.JavaTypeDefinition.forClass(JavaTypeDefinition.java:74)
at net.sourceforge.pmd.lang.java.typeresolution.ClassTypeResolver.populateType(ClassTypeResolver.java:1360)
at net.sourceforge.pmd.lang.java.typeresolution.ClassTypeResolver.populateType(ClassTypeResolver.java:1293)
at net.sourceforge.pmd.lang.java.typeresolution.ClassTypeResolver.visit(ClassTypeResolver.java:229)
at net.sourceforge.pmd.lang.java.ast.ASTImportDeclaration.jjtAccept(ASTImportDeclaration.java:135)
at net.sourceforge.pmd.lang.java.ast.AbstractJavaNode.childrenAccept(AbstractJavaNode.java:60)
at net.sourceforge.pmd.lang.java.ast.JavaParserVisitorAdapter.visit(JavaParserVisitorAdapter.java:11)
at net.sourceforge.pmd.lang.java.ast.JavaParserVisitorAdapter.visit(JavaParserVisitorAdapter.java:181)
at net.sourceforge.pmd.lang.java.typeresolution.ClassTypeResolver.visit(ClassTypeResolver.java:213)
at net.sourceforge.pmd.lang.java.ast.ASTCompilationUnit.jjtAccept(ASTCompilationUnit.java:41)
at net.sourceforge.pmd.lang.java.typeresolution.TypeResolutionFacade.initializeWith(TypeResolutionFacade.java:18)
at net.sourceforge.pmd.lang.java.AbstractJavaHandler$5.start(AbstractJavaHandler.java:109)
at net.sourceforge.pmd.SourceCodeProcessor.usesTypeResolution(SourceCodeProcessor.java:153)
at net.sourceforge.pmd.SourceCodeProcessor.processSource(SourceCodeProcessor.java:180)
at net.sourceforge.pmd.SourceCodeProcessor.processSourceCode(SourceCodeProcessor.java:96)
at net.sourceforge.pmd.SourceCodeProcessor.processSourceCode(SourceCodeProcessor.java:51)
at net.sourceforge.pmd.processor.PmdRunnable.call(PmdRunnable.java:78)
at net.sourceforge.pmd.processor.MonoThreadProcessor.runAnalysis(MonoThreadProcessor.java:29)
at net.sourceforge.pmd.processor.AbstractPMDProcessor.processFiles(AbstractPMDProcessor.java:108)
at net.sourceforge.pmd.eclipse.runtime.cmd.BaseVisitor.reviewResource(BaseVisitor.java:386)
at net.sourceforge.pmd.eclipse.runtime.cmd.ResourceVisitor.visit(ResourceVisitor.java:30)
at org.eclipse.core.internal.resources.Resource$2.visit(Resource.java:120)
at org.eclipse.core.internal.resources.Resource$1.visitElement(Resource.java:84)
at org.eclipse.core.internal.watson.ElementTreeIterator.doIteration(ElementTreeIterator.java:82)
at org.eclipse.core.internal.watson.ElementTreeIterator.doIteration(ElementTreeIterator.java:87)
at org.eclipse.core.internal.watson.ElementTreeIterator.doIteration(ElementTreeIterator.java:87)
at org.eclipse.core.internal.watson.ElementTreeIterator.doIteration(ElementTreeIterator.java:87)
at org.eclipse.core.internal.watson.ElementTreeIterator.doIteration(ElementTreeIterator.java:87)
at org.eclipse.core.internal.watson.ElementTreeIterator.doIteration(ElementTreeIterator.java:87)
at org.eclipse.core.internal.watson.ElementTreeIterator.doIteration(ElementTreeIterator.java:87)
at org.eclipse.core.internal.watson.ElementTreeIterator.iterate(ElementTreeIterator.java:129)
at org.eclipse.core.internal.resources.Resource.accept(Resource.java:94)
at org.eclipse.core.internal.resources.Resource.accept(Resource.java:52)
at org.eclipse.core.internal.resources.Resource.accept(Resource.java:117)
at org.eclipse.core.internal.resources.Resource.accept(Resource.java:105)
at net.sourceforge.pmd.eclipse.runtime.cmd.ReviewCodeCmd.processResource(ReviewCodeCmd.java:486)
at net.sourceforge.pmd.eclipse.runtime.cmd.ReviewCodeCmd.processJavaProject(ReviewCodeCmd.java:554)
at net.sourceforge.pmd.eclipse.runtime.cmd.ReviewCodeCmd.processProject(ReviewCodeCmd.java:520)
at net.sourceforge.pmd.eclipse.runtime.cmd.ReviewCodeCmd.processResources(ReviewCodeCmd.java:435)
at net.sourceforge.pmd.eclipse.runtime.cmd.ReviewCodeCmd.execute(ReviewCodeCmd.java:221)
at net.sourceforge.pmd.eclipse.runtime.cmd.JobCommandProcessor$1.run(JobCommandProcessor.java:93)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:56)

@adangel
Copy link
Member Author

adangel commented Nov 12, 2018

Ok, so the multiple rulesets are working 👍

Your other problem is something different. Could you please create a new issue and describing your project a bit: which java version are you using for compiling, which java version are you using in eclipse, with which java version are you running eclipse?

This "java.lang.IncompatibleClassChangeError: MyClass and MyClass$InternalMyClass disagree on InnerClasses attribute" seems like corrupt bytecode / changes. It normally happens, if you change a (inner) class from static to non-static (or vice versa) or a field. And then not the complete project is recompiled or uses old bytecodes (e.g. MyClass.class is new and MyClass$InternalMyClass.class is not yet updated).

@regrog
Copy link

regrog commented Nov 13, 2018

I deleted all my bin folders and rebuilded all (clean and build didn't work) and now it's working.

Another question: do I have to create the .ruleset file obligatory for each project?
I have some improvements to optimize the configuration, but I'll open new issues

Edit: about the plugin snapshot you gave me, what version of PMD is using?

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

No branches or pull requests

2 participants