Xavier Le Vourch has released PMD 4.1! PMD is a Java static code analysis utility - it finds unused code, design issues, duplicated code, and much more. I posted earlier about the release candidate, and the 4.1 final is pretty much the same code - 14 new rules, a bunch of bug fixes, fewer false positives, and the IntelliJ IDEA integration works again. You can download this release or view the changelog.
On the CPD (copy/pasted code detector) side of the house there's better Ruby support and a new Microsoft Visual Studio output format. I used the Ruby CPD checker to scan a Rails app just yesterday and it worked great - it found a couple of duplicated methods across some helpers and controllers. You can even check .rhtml files using the "Any language" support and find duplicated code there.
PMD continues to develop nicely; I hope to post on the type resolution inner workings soon. Go PMD! And of course, go PMD book! Now a mere $20.
Hello!
I'm using PMD with IntelliJ IDEA.
I tried it as a plugin, but it was always throwing exceptions inside IDEA.
So, I tried to use it as an External tool, now I need some help: in your instructions, what does the argument 'ideaj' stands for? Is it a renderer for IDEA? As far I can see, there are only 4 renderers: text, xml, html and nicehtml.
Thanks in advance,
Rui Baeta
PS: congrats for your good work!
Posted by: Rui Baeta | July 18, 2008 at 04:17 AM
@rui, thanks for the note, I need to check the pending comments more often. Yup, "ideaj" maps to a Renderer implementation - "net.sourceforge.pmd.renderers.IDEAJRenderer".
Posted by: tomcopeland | July 22, 2008 at 07:14 PM
I haven't found a way to get the total number of code and the number of duplicate lines of code within a project.
Am I missing something?
Thanks,
Posted by: Dale | September 18, 2008 at 12:25 PM
@dale, you may want to ask about this on the PMD forums. But I think the current ruleset only provides rules to trigger problem reports when there are more than a certain number of lines of code in a class or a method. You could certainly write your own rule to extract that information, though.
Posted by: tomcopeland | September 24, 2008 at 04:44 PM
Hi
i am using JDeveloper 10.1.3.3.0.4157 and PMD 4.2.4.2.0.
I dont no how to use this pmd tool in jdeveloper. I am new to this pmd tool.
while runing the pmd i am always getting the below error.
please help me ////
net.sourceforge.pmd.PMDException: Error while processing D:\Projects\MOJ-UAE\ePortalCodeMaintenance\ViewController\src\com\crimsonlogic\legal\mojuae\eportal\committee\managedbean\CommitteeBean.java
at net.sourceforge.pmd.PMD.processFile(PMD.java:132)
at net.sourceforge.pmd.PMD.processFile(PMD.java:75)
at net.sourceforge.pmd.PMD.processFile(PMD.java:172)
at net.sourceforge.pmd.PMD.processFile(PMD.java:189)
at net.sourceforge.pmd.PMD.processFile(PMD.java:230)
at net.sourceforge.pmd.jdeveloper.Plugin.runPmd(Plugin.java:218)
at net.sourceforge.pmd.jdeveloper.Plugin.handleEvent(Plugin.java:142)
at oracle.ide.controller.IdeAction.performAction(IdeAction.java:525)
at oracle.ide.controller.IdeAction$1.run(IdeAction.java:772)
at oracle.ide.controller.IdeAction.actionPerformedImpl(IdeAction.java:789)
at oracle.ide.controller.IdeAction.actionPerformed(IdeAction.java:498)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1849)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2169)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
at javax.swing.AbstractButton.doClick(AbstractButton.java:302)
at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:1000)
at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:1041)
at java.awt.Component.processMouseEvent(Component.java:5488)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3126)
at java.awt.Component.processEvent(Component.java:5253)
at java.awt.Container.processEvent(Container.java:1966)
at java.awt.Component.dispatchEventImpl(Component.java:3955)
at java.awt.Container.dispatchEventImpl(Container.java:2024)
at java.awt.Component.dispatchEvent(Component.java:3803)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4212)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3892)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3822)
at java.awt.Container.dispatchEventImpl(Container.java:2010)
at java.awt.Window.dispatchEventImpl(Window.java:1774)
at java.awt.Component.dispatchEvent(Component.java:3803)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
Caused by: java.lang.RuntimeException: org.jaxen.XPathSyntaxException: Expected: )
at net.sourceforge.pmd.rules.XPathRule.getRuleChainVisits(XPathRule.java:90)
at net.sourceforge.pmd.CommonAbstractRule.usesRuleChain(CommonAbstractRule.java:346)
at net.sourceforge.pmd.AbstractRuleChainVisitor.initialize(AbstractRuleChainVisitor.java:123)
at net.sourceforge.pmd.AbstractRuleChainVisitor.visitAll(AbstractRuleChainVisitor.java:46)
at net.sourceforge.pmd.RuleChain.apply(RuleChain.java:67)
at net.sourceforge.pmd.RuleSets.apply(RuleSets.java:133)
at net.sourceforge.pmd.PMD.processFile(PMD.java:126)
... 36 more
Caused by: org.jaxen.XPathSyntaxException: Expected: )
at org.jaxen.BaseXPath.(BaseXPath.java:136)
at org.jaxen.BaseXPath.(BaseXPath.java:159)
at net.sourceforge.pmd.rules.XPathRule.createXPath(XPathRule.java:209)
at net.sourceforge.pmd.rules.XPathRule.initializeXPathExpression(XPathRule.java:160)
at net.sourceforge.pmd.rules.XPathRule.getRuleChainVisits(XPathRule.java:87)
... 42 more
Posted by: Bharathi | June 08, 2009 at 12:38 AM
@bharathi - hm, someone else is maintaining this plugin now, can you post a note on the PMD forums here?
http://sourceforge.net/forum/forum.php?forum_id=188192
Posted by: tomcopeland | June 08, 2009 at 09:04 AM