Menu

#209 PMD tests for CDK interfaces use

Needs_Review
closed
nobody
cdk-1.2.x (46)
5
2012-10-28
2010-05-23
No

Adds PMD testing for inappropriate use of implementations, where interfaces should be used. Example 'bad' code:

  1. Molecule mol = builder.newInstance(IMolecule.class);
  2. if (atom instanceof PseudoAtom) { }

It will highlight many sources of bugs.

Patch available from:

http://github.com/egonw/cdk/tree/152-cdkPMDtests

No code library change; one review is enough.

Discussion

  • Rajarshi Guha

    Rajarshi Guha - 2010-05-23

    Looks good. Applied and pushed.

    But running

    ant -f pmd.xml

    does not seem to report any violations for the custom CDK rules. Does the PMD report have to be generated some other way?

     
  • Egon Willighagen

    That should work...

    <antcall target="test-module"><param name="pmd.test" value="custom"><param name="module" value="qsarprotein"></antcall>

    That's the call in pmd.xml, and the pmd.test param value is later used in:

    <pmd shortfilenames="true" rulesetfiles="pmd/${pmd.test}.xml"></pmd>

    And pmd/custom.xml is now referencing the pmd/cdkinterfaces.xml:

    http://github.com/cdk/cdk/commit/406930b29289b520077c310debffb1f18e49132b#diff-1

    I checked, and in some situations it was not run yet. Please see the attached patch.

     
  • Rajarshi Guha

    Rajarshi Guha - 2010-05-23

    Aah, works fine now. Applied and pushed.

     

Log in to post a comment.