aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEvgeny Mandrikov <mandrikov@gmail.com>2011-11-30 16:50:13 +0400
committerEvgeny Mandrikov <mandrikov@gmail.com>2011-11-30 22:14:08 +0400
commita07ede17801531d8deeaa609339b925653fefc8b (patch)
tree4b2fa0ecd745ad6ad00a6bd0402f6958722279a6
parent735ed8bdf749b1034e2713abe37d8a7f27583244 (diff)
downloadsonarqube-a07ede17801531d8deeaa609339b925653fefc8b.tar.gz
sonarqube-a07ede17801531d8deeaa609339b925653fefc8b.zip
SONAR-2819 Upgrade to PMD 4.3
New rules in PMD 4.3: * DontCallThreadRun * GuardDebugLogging New rules in PMD 4.2.6: * GenericsNaming * AvoidCatchingGenericException * AvoidLosingExceptionInformation * AvoidLiteralsInIfCondition * UseConcurrentHashMap * DoNotHardCodeSDCard
-rw-r--r--plugins/sonar-cpd-plugin/pom.xml2
-rw-r--r--plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/pmd.properties8
-rw-r--r--plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/pmd/AvoidCatchingGenericException.html1
-rw-r--r--plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/pmd/AvoidLiteralsInIfCondition.html1
-rw-r--r--plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/pmd/AvoidLosingExceptionInformation.html1
-rw-r--r--plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/pmd/DoNotHardCodeSDCard.html1
-rw-r--r--plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/pmd/DontCallThreadRun.html1
-rw-r--r--plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/pmd/GenericsNaming.html1
-rw-r--r--plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/pmd/GuardDebugLogging.html1
-rw-r--r--plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/pmd/UseConcurrentHashMap.html1
-rw-r--r--plugins/sonar-pmd-plugin/pom.xml34
-rw-r--r--plugins/sonar-pmd-plugin/src/main/resources/org/sonar/plugins/pmd/rules.xml38
-rw-r--r--sonar-duplications/pom.xml2
13 files changed, 58 insertions, 34 deletions
diff --git a/plugins/sonar-cpd-plugin/pom.xml b/plugins/sonar-cpd-plugin/pom.xml
index d9d2a51487d..172f8ffca38 100644
--- a/plugins/sonar-cpd-plugin/pom.xml
+++ b/plugins/sonar-cpd-plugin/pom.xml
@@ -17,7 +17,7 @@
<dependency>
<groupId>pmd</groupId>
<artifactId>pmd</artifactId>
- <version>4.2.5</version>
+ <version>4.3</version>
<exclusions>
<exclusion>
<groupId>jaxen</groupId>
diff --git a/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/pmd.properties b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/pmd.properties
index 0bc9017ffc5..6c780de2d15 100644
--- a/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/pmd.properties
+++ b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/pmd.properties
@@ -267,3 +267,11 @@ rule.pmd.ExceptionAsFlowControl.name=Exception As Flow Control
rule.pmd.UnusedPrivateField.name=Unused Private Field
rule.pmd.AtLeastOneConstructor.name=At Least One Constructor
rule.pmd.AppendCharacterWithChar.name=Append Character With Char
+rule.pmd.GenericsNaming.name=Generics Naming
+rule.pmd.AvoidCatchingGenericException.name=Avoid Catching Generic Exception
+rule.pmd.AvoidLosingExceptionInformation.name=Avoid Losing Exception Information
+rule.pmd.AvoidLiteralsInIfCondition.name=Avoid Literals In If Condition
+rule.pmd.UseConcurrentHashMap.name=Use ConcurrentHashMap
+rule.pmd.DoNotHardCodeSDCard.name=Android - Do Not Hard Code SD Card
+rule.pmd.DontCallThreadRun.name=Dont Call Thread Run
+rule.pmd.GuardDebugLogging.name=Guard Debug Logging
diff --git a/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/pmd/AvoidCatchingGenericException.html b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/pmd/AvoidCatchingGenericException.html
new file mode 100644
index 00000000000..bcc94d8e2cf
--- /dev/null
+++ b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/pmd/AvoidCatchingGenericException.html
@@ -0,0 +1 @@
+Avoid catching generic exceptions such as NullPointerException, RuntimeException, Exception in try-catch block.
diff --git a/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/pmd/AvoidLiteralsInIfCondition.html b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/pmd/AvoidLiteralsInIfCondition.html
new file mode 100644
index 00000000000..a1c9e6264a9
--- /dev/null
+++ b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/pmd/AvoidLiteralsInIfCondition.html
@@ -0,0 +1 @@
+Avoid using hard coded literals in conditional statements, declare those as static variables or private members.
diff --git a/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/pmd/AvoidLosingExceptionInformation.html b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/pmd/AvoidLosingExceptionInformation.html
new file mode 100644
index 00000000000..51d1960f373
--- /dev/null
+++ b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/pmd/AvoidLosingExceptionInformation.html
@@ -0,0 +1 @@
+Statements in a catch block that invoke accessors on the exception without using the information only add to code size. Either remove the invocation, or use the return result.
diff --git a/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/pmd/DoNotHardCodeSDCard.html b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/pmd/DoNotHardCodeSDCard.html
new file mode 100644
index 00000000000..003eaefe63b
--- /dev/null
+++ b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/pmd/DoNotHardCodeSDCard.html
@@ -0,0 +1 @@
+Use Environment.getExternalStorageDirectory() instead of "/sdcard".
diff --git a/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/pmd/DontCallThreadRun.html b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/pmd/DontCallThreadRun.html
new file mode 100644
index 00000000000..89305204909
--- /dev/null
+++ b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/pmd/DontCallThreadRun.html
@@ -0,0 +1 @@
+Explicitly calling Thread.run() method will execute in the caller's thread of control. Instead, call Thread.start() for the intended behavior.
diff --git a/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/pmd/GenericsNaming.html b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/pmd/GenericsNaming.html
new file mode 100644
index 00000000000..879e0178180
--- /dev/null
+++ b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/pmd/GenericsNaming.html
@@ -0,0 +1 @@
+Generics names should be a one letter long and upper case.
diff --git a/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/pmd/GuardDebugLogging.html b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/pmd/GuardDebugLogging.html
new file mode 100644
index 00000000000..cc533ca8688
--- /dev/null
+++ b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/pmd/GuardDebugLogging.html
@@ -0,0 +1 @@
+When log messages are composed by concatenating strings, the whole section should be guarded by a isDebugEnabled() check to avoid performance and memory issues.
diff --git a/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/pmd/UseConcurrentHashMap.html b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/pmd/UseConcurrentHashMap.html
new file mode 100644
index 00000000000..a419810b189
--- /dev/null
+++ b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/pmd/UseConcurrentHashMap.html
@@ -0,0 +1 @@
+Since Java5 brought a new implementation of the Map interface, specially designed for concurrent application.
diff --git a/plugins/sonar-pmd-plugin/pom.xml b/plugins/sonar-pmd-plugin/pom.xml
index 3b36b882e91..402b25ed125 100644
--- a/plugins/sonar-pmd-plugin/pom.xml
+++ b/plugins/sonar-pmd-plugin/pom.xml
@@ -14,24 +14,9 @@
<description>PMD is a tool that looks for potential problems like possible bugs, dead code, suboptimal code, overcomplicated expressions or duplicate code.</description>
<properties>
- <pmd.version>4.2.5.2</pmd.version>
+ <pmd.version>4.3</pmd.version>
</properties>
- <repositories>
- <!-- for patched version of PMD (support of Java7) -->
- <repository>
- <id>sonar</id>
- <name>Sonar</name>
- <url>http://repository.sonarsource.org/content/repositories/sonar</url>
- <releases>
- <enabled>true</enabled>
- </releases>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
- </repository>
- </repositories>
-
<dependencies>
<dependency>
<groupId>org.codehaus.sonar</groupId>
@@ -44,8 +29,8 @@
<scope>provided</scope>
</dependency>
<dependency>
- <groupId>com.sonarsource.pmd</groupId>
- <artifactId>pmd-java7</artifactId>
+ <groupId>pmd</groupId>
+ <artifactId>pmd</artifactId>
<version>${pmd.version}</version>
<exclusions>
<exclusion>
@@ -106,19 +91,6 @@
<pluginClass>org.sonar.plugins.pmd.PmdPlugin</pluginClass>
</configuration>
</plugin>
- <plugin>
- <!-- TODO remove (see SONAR-2938) -->
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-enforcer-plugin</artifactId>
- <executions>
- <execution>
- <id>enforce-no-repositories</id>
- <configuration>
- <skip>true</skip>
- </configuration>
- </execution>
- </executions>
- </plugin>
</plugins>
</build>
</project>
diff --git a/plugins/sonar-pmd-plugin/src/main/resources/org/sonar/plugins/pmd/rules.xml b/plugins/sonar-pmd-plugin/src/main/resources/org/sonar/plugins/pmd/rules.xml
index 7807310d803..961239cadef 100644
--- a/plugins/sonar-pmd-plugin/src/main/resources/org/sonar/plugins/pmd/rules.xml
+++ b/plugins/sonar-pmd-plugin/src/main/resources/org/sonar/plugins/pmd/rules.xml
@@ -1,4 +1,40 @@
<rules>
+ <!-- PMD 4.3 -->
+ <rule key="DontCallThreadRun">
+ <priority>MAJOR</priority>
+ <configKey>rulesets/basic.xml/DontCallThreadRun</configKey>
+ </rule>
+ <rule key="GuardDebugLogging">
+ <priority>MAJOR</priority>
+ <configKey>rulesets/logging-jakarta-commons.xml/GuardDebugLogging</configKey>
+ </rule>
+
+ <!-- PMD 4.2.6 -->
+ <rule key="GenericsNaming">
+ <priority>MAJOR</priority>
+ <configKey>rulesets/naming.xml/GenericsNaming</configKey>
+ </rule>
+ <rule key="AvoidCatchingGenericException">
+ <priority>MAJOR</priority>
+ <configKey>rulesets/strictexception.xml/AvoidCatchingGenericException</configKey>
+ </rule>
+ <rule key="AvoidLosingExceptionInformation">
+ <priority>MAJOR</priority>
+ <configKey>rulesets/strictexception.xml/AvoidLosingExceptionInformation</configKey>
+ </rule>
+ <rule key="AvoidLiteralsInIfCondition">
+ <priority>MAJOR</priority>
+ <configKey>rulesets/controversial.xml/AvoidLiteralsInIfCondition</configKey>
+ </rule>
+ <rule key="UseConcurrentHashMap">
+ <priority>MAJOR</priority>
+ <configKey>rulesets/controversial.xml/UseConcurrentHashMap</configKey>
+ </rule>
+ <rule key="DoNotHardCodeSDCard">
+ <priority>MAJOR</priority>
+ <configKey>rulesets/android.xml/DoNotHardCodeSDCard</configKey>
+ </rule>
+
<!-- PMD 4.2.5 -->
<rule key="AvoidThrowingNewInstanceOfSameException">
<priority>MAJOR</priority>
@@ -1785,4 +1821,4 @@
</param>
</rule>
-</rules> \ No newline at end of file
+</rules>
diff --git a/sonar-duplications/pom.xml b/sonar-duplications/pom.xml
index 3903a86943e..c1bdecf2f9c 100644
--- a/sonar-duplications/pom.xml
+++ b/sonar-duplications/pom.xml
@@ -24,7 +24,7 @@
<dependency>
<groupId>pmd</groupId>
<artifactId>pmd</artifactId>
- <version>4.2.5</version>
+ <version>4.3</version>
<scope>test</scope>
</dependency>
<dependency>