From 45030e0743a65d1aca373bf56262d3369310a5d2 Mon Sep 17 00:00:00 2001 From: Philippe Herlin Date: Wed, 15 Jun 2005 21:16:27 +0000 Subject: [PATCH] Create a plugin fragment for the Eclipse plugin unit tests git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@3587 51baf565-9d33-0410-a72c-fc3788e3496d --- pmd-eclipse-test-fragment/.classpath | 7 + pmd-eclipse-test-fragment/.project | 28 + pmd-eclipse-test-fragment/build.properties | 4 + pmd-eclipse-test-fragment/fragment.xml | 18 + .../src/rulesets/additional | 2 + .../src/rulesets/extra1.xml | 616 ++++++++++++++++++ .../src/rulesets/extra2.xml | 129 ++++ 7 files changed, 804 insertions(+) create mode 100644 pmd-eclipse-test-fragment/.classpath create mode 100644 pmd-eclipse-test-fragment/.project create mode 100644 pmd-eclipse-test-fragment/build.properties create mode 100644 pmd-eclipse-test-fragment/fragment.xml create mode 100644 pmd-eclipse-test-fragment/src/rulesets/additional create mode 100644 pmd-eclipse-test-fragment/src/rulesets/extra1.xml create mode 100644 pmd-eclipse-test-fragment/src/rulesets/extra2.xml diff --git a/pmd-eclipse-test-fragment/.classpath b/pmd-eclipse-test-fragment/.classpath new file mode 100644 index 0000000000..065ac06e19 --- /dev/null +++ b/pmd-eclipse-test-fragment/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/pmd-eclipse-test-fragment/.project b/pmd-eclipse-test-fragment/.project new file mode 100644 index 0000000000..c8e9ac9d78 --- /dev/null +++ b/pmd-eclipse-test-fragment/.project @@ -0,0 +1,28 @@ + + + pmd-eclipse-test-fragment + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/pmd-eclipse-test-fragment/build.properties b/pmd-eclipse-test-fragment/build.properties new file mode 100644 index 0000000000..9ba6a0771c --- /dev/null +++ b/pmd-eclipse-test-fragment/build.properties @@ -0,0 +1,4 @@ +source.pmd_eclipse_test_fragment.jar = src/ +output.pmd_eclipse_test_fragment.jar = bin/ +bin.includes = fragment.xml,\ + pmd_eclipse_test_fragment.jar diff --git a/pmd-eclipse-test-fragment/fragment.xml b/pmd-eclipse-test-fragment/fragment.xml new file mode 100644 index 0000000000..3f51d8b60c --- /dev/null +++ b/pmd-eclipse-test-fragment/fragment.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + diff --git a/pmd-eclipse-test-fragment/src/rulesets/additional b/pmd-eclipse-test-fragment/src/rulesets/additional new file mode 100644 index 0000000000..9757baa0ee --- /dev/null +++ b/pmd-eclipse-test-fragment/src/rulesets/additional @@ -0,0 +1,2 @@ +rulesets/extra1.xml +rulesets/extra2.xml diff --git a/pmd-eclipse-test-fragment/src/rulesets/extra1.xml b/pmd-eclipse-test-fragment/src/rulesets/extra1.xml new file mode 100644 index 0000000000..5449939323 --- /dev/null +++ b/pmd-eclipse-test-fragment/src/rulesets/extra1.xml @@ -0,0 +1,616 @@ + + + + +The Basic Ruleset contains a collection of good practices which everyone should follow. + + + + + + Empty Catch Block finds instances where an exception is caught, + but nothing is done. In most circumstances, this swallows an exception + which should either be acted on or reported. + + + + + 1] + [count(*) = 0] + [../@Finally='false' or following-sibling::Block] + ]]> + + + + 3 + + + + + + + + + Empty If Statement finds instances where a condition is checked but nothing is done about it. + + 3 + + + + + + + + + + + + + + + + Empty While Statement finds all instances where a while statement + does nothing. If it is a timing loop, then you should use Thread.sleep() for it; if + it's a while loop that does a lot in the exit expression, rewrite it to make it clearer. + + + + + + + + + 3 + + + + + + + + + + Avoid empty try blocks - what's the point? + + + + + + + + + 3 + + + + + + + + + Avoid empty finally blocks - these can be deleted. + + + + + + + + + 3 + + + + + + + + + + Avoid empty switch statements. + + + + + + + + + 3 + + + + + + + + + + Avoid jumbled loop incrementers - it's usually a mistake, and it's confusing even if it's what's intended. + + + + + + + + + 3 + + + + + + + + + + Some for loops can be simplified to while loops - this makes them more concise. + + + + + 1] + [not(ForInit)] + [not(ForUpdate)] + [not(Type and Expression and Statement)] + ]]> + + + + 3 + + + + + + + + + Avoid unnecessary temporaries when converting primitives to Strings + + 3 + + + + + + + + Override both public boolean Object.equals(Object other), and public int Object.hashCode(), or override neither. Even if you are inheriting a hashCode() from a parent class, consider implementing hashCode and explicitly delegating to your superclass. + + + + + + + + + 3 + + + + + + + + + Partially created objects can be returned by the Double Checked Locking pattern when used in Java. + An optimizing JRE may assign a reference to the baz variable before it creates the object the + reference is intended to point to. For more details see http://www.javaworld.com/javaworld/jw-02-2001/jw-0209-double.html. + + 1 + + + + + + + + Avoid returning from a finally block - this can discard exceptions. + + + + + + + + + 3 + + + + + + + + + Avoid empty synchronized blocks - they're useless. + + + + + + + + + 3 + + + + + + + + + Avoid unnecessary return statements + + + + + + + + + 3 + + + + + + + + + + An empty static initializer was found. + + + + + + + + + 3 + + + + + + + + Do not use "if" statements that are always true or always false. + + + + + + + + + 3 + + + + + + + + An empty statement (aka a semicolon by itself) that is not used + as the sole body of a for loop or while loop is probably a bug. It + could also be a double semicolon, which is useless and should be + removed. + + + + + + + + + 3 + + + + + + + + Avoid instantiating Boolean objects, instead use Boolean.TRUE or Boolean.FALSE. + + + + + + + + + 2 + + + + + + + + When a class has the final modifier, all the methods are marked finally. + + + + + + + + + 3 + + + + + + + + + Sometimes two 'if' statements can be consolidated by separating their conditions with a boolean short-circuit operator. + + + + + + + + + 3 + + + + + + diff --git a/pmd-eclipse-test-fragment/src/rulesets/extra2.xml b/pmd-eclipse-test-fragment/src/rulesets/extra2.xml new file mode 100644 index 0000000000..4d47329e1c --- /dev/null +++ b/pmd-eclipse-test-fragment/src/rulesets/extra2.xml @@ -0,0 +1,129 @@ + + + + +The Braces Ruleset contains a collection of braces rules. + + + + + Avoid using if statements without using curly braces + + + + + + + + + 3 + + + + + + + + + Avoid using 'while' statements without using curly braces + + + + + + + + + 3 + + + + + + + + + Avoid using if..else statements without using curly braces + + + + + + + + + 3 + + + + + + + + + Avoid using 'for' statements without using curly braces + + + + + + + + + 3 + + + + + + +