Permalink
Browse files

Merge branch 'cdk-1.2.x'

  • Loading branch information...
2 parents 235b04f + 406930b commit b8110ae58dcc699e3d6ab34298f80b732c0ccd6e @egonw egonw committed May 23, 2010
Showing with 379 additions and 0 deletions.
  1. +360 −0 pmd/cdkinterfaces.xml
  2. +1 −0 pmd/custom.xml
  3. +18 −0 src/main/org/openscience/cdk/qsar/descriptors/molecular/ChiIndexUtils.java
View
@@ -0,0 +1,360 @@
+<?xml version="1.0"?>
+<ruleset name="cdkinterfaces">
+
+ <description>
+ This ruleset checks for programming against implementations instead
+ of interfaces.
+ </description>
+
+ <rule name="MoleculeFieldType"
+ language="java"
+ message="Use the IMolecule interfaces instead of the Molecule implementation"
+ class="net.sourceforge.pmd.rules.XPathRule">
+ <description>
+ Programming against the CDK interfaces allows users to pick their favorite
+ implementation (nonotify, datadebug).
+ </description>
+ <priority>2</priority>
+ <properties>
+ <property name="xpath">
+ <value>
+ <![CDATA[
+ //Type/ReferenceType/ClassOrInterfaceType[@Image='Molecule']
+ ]]>
+ </value>
+ </property>
+ </properties>
+ <example>
+ <![CDATA[
+ Molecule mol = builder.newInstance(IMolecule.class);
+ // better:
+ // IMolecule mol = builder.newInstance(IMolecule.class);
+ ]]>
+ </example>
+ </rule>
+
+ <rule name="AtomFieldType"
+ language="java"
+ message="Use the IAtom interfaces instead of the Atom implementation"
+ class="net.sourceforge.pmd.rules.XPathRule">
+ <description>
+ Programming against the CDK interfaces allows users to pick their favorite
+ implementation (nonotify, datadebug).
+ </description>
+ <priority>2</priority>
+ <properties>
+ <property name="xpath">
+ <value>
+ <![CDATA[
+ //Type/ReferenceType/ClassOrInterfaceType[@Image='Atom']
+ ]]>
+ </value>
+ </property>
+ </properties>
+ <example>
+ <![CDATA[
+ Atom mol = builder.newInstance(IAtom.class);
+ // better:
+ // IAtom mol = builder.newInstance(IAtom.class);
+ ]]>
+ </example>
+ </rule>
+
+ <rule name="BondFieldType"
+ language="java"
+ message="Use the IBond interfaces instead of the Bond implementation"
+ class="net.sourceforge.pmd.rules.XPathRule">
+ <description>
+ Programming against the CDK interfaces allows users to pick their favorite
+ implementation (nonotify, datadebug).
+ </description>
+ <priority>2</priority>
+ <properties>
+ <property name="xpath">
+ <value>
+ <![CDATA[
+ //Type/ReferenceType/ClassOrInterfaceType[@Image='Bond']
+ ]]>
+ </value>
+ </property>
+ </properties>
+ <example>
+ <![CDATA[
+ Bond mol = builder.newInstance(IBond.class);
+ // better:
+ // IBond mol = builder.newInstance(IBond.class);
+ ]]>
+ </example>
+ </rule>
+
+ <rule name="InstanceOfMolecule"
+ language="java"
+ message="Use instanceof against interfaces not implementations"
+ class="net.sourceforge.pmd.rules.XPathRule">
+ <description>
+ Programming against the CDK interfaces allows users to pick their favorite
+ implementation (nonotify, datadebug).
+ </description>
+ <priority>1</priority>
+ <properties>
+ <property name="xpath">
+ <value>
+ <![CDATA[
+ //InstanceOfExpression/Type/ReferenceType/ClassOrInterfaceType[@Image='Molecule']
+ ]]>
+ </value>
+ </property>
+ </properties>
+ <example>
+ <![CDATA[
+ if (atomContainer instanceof Molecule) {}
+ // use instead:
+ // if (atomContainer instanceof IMolecule) {}
+ ]]>
+ </example>
+ </rule>
+
+ <rule name="InstanceOfAtom"
+ language="java"
+ message="Use instanceof against interfaces not implementations"
+ class="net.sourceforge.pmd.rules.XPathRule">
+ <description>
+ Programming against the CDK interfaces allows users to pick their favorite
+ implementation (nonotify, datadebug).
+ </description>
+ <priority>1</priority>
+ <properties>
+ <property name="xpath">
+ <value>
+ <![CDATA[
+ //InstanceOfExpression/Type/ReferenceType/ClassOrInterfaceType[@Image='Atom']
+ ]]>
+ </value>
+ </property>
+ </properties>
+ <example>
+ <![CDATA[
+ if (atomContainer instanceof Atom) {}
+ // use instead:
+ // if (atomContainer instanceof IAtom) {}
+ ]]>
+ </example>
+ </rule>
+
+ <rule name="InstanceOfPseudoAtom"
+ language="java"
+ message="Use instanceof against interfaces not implementations"
+ class="net.sourceforge.pmd.rules.XPathRule">
+ <description>
+ Programming against the CDK interfaces allows users to pick their favorite
+ implementation (nonotify, datadebug).
+ </description>
+ <priority>1</priority>
+ <properties>
+ <property name="xpath">
+ <value>
+ <![CDATA[
+ //InstanceOfExpression/Type/ReferenceType/ClassOrInterfaceType[@Image='PseudoAtom']
+ ]]>
+ </value>
+ </property>
+ </properties>
+ <example>
+ <![CDATA[
+ if (atomContainer instanceof PseudoAtom) {}
+ // use instead:
+ // if (atomContainer instanceof IPseudoAtom) {}
+ ]]>
+ </example>
+ </rule>
+
+ <rule name="InstanceOfBond"
+ language="java"
+ message="Use instanceof against interfaces not implementations"
+ class="net.sourceforge.pmd.rules.XPathRule">
+ <description>
+ Programming against the CDK interfaces allows users to pick their favorite
+ implementation (nonotify, datadebug).
+ </description>
+ <priority>1</priority>
+ <properties>
+ <property name="xpath">
+ <value>
+ <![CDATA[
+ //InstanceOfExpression/Type/ReferenceType/ClassOrInterfaceType[@Image='Bond']
+ ]]>
+ </value>
+ </property>
+ </properties>
+ <example>
+ <![CDATA[
+ if (atomContainer instanceof Bond) {}
+ // use instead:
+ // if (atomContainer instanceof IBond) {}
+ ]]>
+ </example>
+ </rule>
+
+ <rule name="InstanceOfLonePair"
+ language="java"
+ message="Use instanceof against interfaces not implementations"
+ class="net.sourceforge.pmd.rules.XPathRule">
+ <description>
+ Programming against the CDK interfaces allows users to pick their favorite
+ implementation (nonotify, datadebug).
+ </description>
+ <priority>1</priority>
+ <properties>
+ <property name="xpath">
+ <value>
+ <![CDATA[
+ //InstanceOfExpression/Type/ReferenceType/ClassOrInterfaceType[@Image='LonePair']
+ ]]>
+ </value>
+ </property>
+ </properties>
+ <example>
+ <![CDATA[
+ if (atomContainer instanceof LonePair) {}
+ // use instead:
+ // if (atomContainer instanceof ILonePair) {}
+ ]]>
+ </example>
+ </rule>
+
+ <rule name="InstanceOfSingleElectron"
+ language="java"
+ message="Use instanceof against interfaces not implementations"
+ class="net.sourceforge.pmd.rules.XPathRule">
+ <description>
+ Programming against the CDK interfaces allows users to pick their favorite
+ implementation (nonotify, datadebug).
+ </description>
+ <priority>1</priority>
+ <properties>
+ <property name="xpath">
+ <value>
+ <![CDATA[
+ //InstanceOfExpression/Type/ReferenceType/ClassOrInterfaceType[@Image='SingleElectron']
+ ]]>
+ </value>
+ </property>
+ </properties>
+ <example>
+ <![CDATA[
+ if (atomContainer instanceof SingleElectron) {}
+ // use instead:
+ // if (atomContainer instanceof ISingleElectron) {}
+ ]]>
+ </example>
+ </rule>
+
+ <rule name="InstanceOfIsotope"
+ language="java"
+ message="Use instanceof against interfaces not implementations"
+ class="net.sourceforge.pmd.rules.XPathRule">
+ <description>
+ Programming against the CDK interfaces allows users to pick their favorite
+ implementation (nonotify, datadebug).
+ </description>
+ <priority>1</priority>
+ <properties>
+ <property name="xpath">
+ <value>
+ <![CDATA[
+ //InstanceOfExpression/Type/ReferenceType/ClassOrInterfaceType[@Image='Isotope']
+ ]]>
+ </value>
+ </property>
+ </properties>
+ <example>
+ <![CDATA[
+ if (atomContainer instanceof Isotope) {}
+ // use instead:
+ // if (atomContainer instanceof IIsotope) {}
+ ]]>
+ </example>
+ </rule>
+
+ <rule name="InstanceOfAtomType"
+ language="java"
+ message="Use instanceof against interfaces not implementations"
+ class="net.sourceforge.pmd.rules.XPathRule">
+ <description>
+ Programming against the CDK interfaces allows users to pick their favorite
+ implementation (nonotify, datadebug).
+ </description>
+ <priority>1</priority>
+ <properties>
+ <property name="xpath">
+ <value>
+ <![CDATA[
+ //InstanceOfExpression/Type/ReferenceType/ClassOrInterfaceType[@Image='AtomType']
+ ]]>
+ </value>
+ </property>
+ </properties>
+ <example>
+ <![CDATA[
+ if (atomContainer instanceof AtomType) {}
+ // use instead:
+ // if (atomContainer instanceof IAtomType) {}
+ ]]>
+ </example>
+ </rule>
+
+ <rule name="InstanceOfElement"
+ language="java"
+ message="Use instanceof against interfaces not implementations"
+ class="net.sourceforge.pmd.rules.XPathRule">
+ <description>
+ Programming against the CDK interfaces allows users to pick their favorite
+ implementation (nonotify, datadebug).
+ </description>
+ <priority>1</priority>
+ <properties>
+ <property name="xpath">
+ <value>
+ <![CDATA[
+ //InstanceOfExpression/Type/ReferenceType/ClassOrInterfaceType[@Image='Element']
+ ]]>
+ </value>
+ </property>
+ </properties>
+ <example>
+ <![CDATA[
+ if (atomContainer instanceof Element) {}
+ // use instead:
+ // if (atomContainer instanceof IElement) {}
+ ]]>
+ </example>
+ </rule>
+
+ <rule name="InstanceOfAtomContainer"
+ language="java"
+ message="Use instanceof against interfaces not implementations"
+ class="net.sourceforge.pmd.rules.XPathRule">
+ <description>
+ Programming against the CDK interfaces allows users to pick their favorite
+ implementation (nonotify, datadebug).
+ </description>
+ <priority>1</priority>
+ <properties>
+ <property name="xpath">
+ <value>
+ <![CDATA[
+ //InstanceOfExpression/Type/ReferenceType/ClassOrInterfaceType[@Image='AtomContainer']
+ ]]>
+ </value>
+ </property>
+ </properties>
+ <example>
+ <![CDATA[
+ if (atomContainer instanceof AtomContainer) {}
+ // use instead:
+ // if (atomContainer instanceof IAtomContainer) {}
+ ]]>
+ </example>
+ </rule>
+
+</ruleset>
View
@@ -27,5 +27,6 @@
<rule ref="pmd/customCDK.xml"/>
<rule ref="pmd/customOptimization.xml"/>
+ <rule ref="pmd/cdkinterfaces.xml"/>
</ruleset>
@@ -1,3 +1,21 @@
+/* Copyright (C) 2004-2007 Rajarshi Guha <rajarshi@users.sourceforge.net>
+ *
+ * Contact: cdk-devel@lists.sourceforge.net
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
package org.openscience.cdk.qsar.descriptors.molecular;
import java.io.IOException;

0 comments on commit b8110ae

Please sign in to comment.