Skip to content

Commit

Permalink
Merge pull request #65 from jensgerdes/bugfix/nonworking-pmd-rules
Browse files Browse the repository at this point in the history
Fixes #64
  • Loading branch information
jensgerdes authored Nov 11, 2018
2 parents 1a5599b + ada2ae0 commit f01d209
Show file tree
Hide file tree
Showing 6 changed files with 139 additions and 25 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,27 @@
- Java 11 support
- Updated PMD (6.9.0)

**Breaking changes:**
- Config parameters of Rule [CyclomaticComplexity](https://pmd.github.io/pmd-6.9.0/pmd_rules_java_design.html#cyclomaticcomplexity) changed.
- Removed:
- `reportLevel`
- `showClassesComplexity`
- `showMethodsComplexity`
- Added
- `classReportLevel`
- `methodReportLevel`
- Config parameters of Rule [AvoidUsingHardCodedIP](https://pmd.github.io/pmd-6.9.0/pmd_rules_java_bestpractices.html#avoidusinghardcodedip) changed.
- Removed: `pattern`
- Added: `checkAddressTypes`


**Closed issues:**
- Upgrade pmd version to the latest one for parsing Java 8 code successfully [\#34](https://github.com/jensgerdes/sonar-pmd/issues/34)
- Please update PMD to at least 5.5.2 [\#38](https://github.com/jensgerdes/sonar-pmd/issues/38)
- Java 10 compatibility [\#44](https://github.com/jensgerdes/sonar-pmd/issues/44)
- Upgrade to a recent PMD version? [\#48](https://github.com/jensgerdes/sonar-pmd/issues/48)
- Convert project into Multi module Maven Project [\#59](https://github.com/jensgerdes/sonar-pmd/issues/59)
- Sonar-PMD can not be used with all rules [\#64](https://github.com/jensgerdes/sonar-pmd/issues/64)

**Merged pull requests:**
- Upgrade to latest PMD [\#51](https://github.com/jensgerdes/sonar-pmd/pull/51) ([spasam](https://github.com/spasam))
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Sonar-PMD is a plugin that provides coding rules from [PMD](https://pmd.github.i
PMD Plugin|2.0|2.1|2.2|2.3|2.4.1|2.5|2.6|3.0.0|3.1.0-SNAPSHOT
-------|---|---|---|---|---|---|---|---|---
PMD|4.3|4.3|5.1.1|5.2.1|5.3.1|5.4.0|5.4.2|5.4.2|6.9.0
Supported Java Version | | | | | | 1.7 | 1.8 | 1.8 | 11
Max. supported Java Version | | | | | | 1.7 | 1.8 | 1.8 | 11
Min. SonarQube Version | | | | | | 4.5.4 | 4.5.4 | 6.6 | 6.6

A majority of the PMD rules have been rewritten in the Java plugin. Rewritten rules are marked "Deprecated" in the PMD plugin, but a [concise summary of replaced rules](http://dist.sonarsource.com/reports/coverage/pmd.html) is available.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,8 +300,8 @@
<priority>MAJOR</priority>
<parameters>
<parameter>
<key>pattern</key>
<value>^[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}$</value>
<key>checkAddressTypes</key>
<value>IPv4|IPv6|IPv4 mapped IPv6</value>
</parameter>
</parameters>
</rule>
Expand Down Expand Up @@ -560,17 +560,13 @@
<priority>MAJOR</priority>
<parameters>
<parameter>
<key>showMethodsComplexity</key>
<value>false</value>
<key>classReportLevel</key>
<value>80</value>
</parameter>
<parameter>
<key>reportLevel</key>
<key>methodReportLevel</key>
<value>10</value>
</parameter>
<parameter>
<key>showClassesComplexity</key>
<value>true</value>
</parameter>
</parameters>
</rule>
<rule>
Expand Down Expand Up @@ -1851,5 +1847,112 @@
<priority>MAJOR</priority>
<parameters/>
</rule>
<rule>
<repositoryKey>pmd-unit-tests</repositoryKey>
<key>JUnit4SuitesShouldUseSuiteAnnotation</key>
<priority>MAJOR</priority>
<parameters/>
</rule>
<rule>
<repositoryKey>pmd-unit-tests</repositoryKey>
<key>JUnit4TestShouldUseAfterAnnotation</key>
<priority>MAJOR</priority>
<parameters/>
</rule>
<rule>
<repositoryKey>pmd-unit-tests</repositoryKey>
<key>JUnit4TestShouldUseBeforeAnnotation</key>
<priority>MAJOR</priority>
<parameters/>
</rule>
<rule>
<repositoryKey>pmd-unit-tests</repositoryKey>
<key>JUnit4TestShouldUseTestAnnotation</key>
<priority>MAJOR</priority>
<parameters/>
</rule>
<rule>
<repositoryKey>pmd-unit-tests</repositoryKey>
<key>JUnitAssertionsShouldIncludeMessage</key>
<priority>MINOR</priority>
<parameters/>
</rule>
<rule>
<repositoryKey>pmd-unit-tests</repositoryKey>
<key>JUnitSpelling</key>
<priority>MAJOR</priority>
<parameters/>
</rule>
<rule>
<repositoryKey>pmd-unit-tests</repositoryKey>
<key>JUnitStaticSuite</key>
<priority>MAJOR</priority>
<parameters/>
</rule>
<rule>
<repositoryKey>pmd-unit-tests</repositoryKey>
<key>JUnitTestContainsTooManyAsserts</key>
<priority>MAJOR</priority>
<parameters>
<parameter>
<key>maximumAsserts</key>
<value>1</value>
</parameter>
</parameters>
</rule>
<rule>
<repositoryKey>pmd-unit-tests</repositoryKey>
<key>JUnitTestsShouldIncludeAssert</key>
<priority>MAJOR</priority>
<parameters/>
</rule>
<rule>
<repositoryKey>pmd-unit-tests</repositoryKey>
<key>JUnitUseExpected</key>
<priority>MAJOR</priority>
<parameters/>
</rule>
<rule>
<repositoryKey>pmd-unit-tests</repositoryKey>
<key>SimplifyBooleanAssertion</key>
<priority>MINOR</priority>
<parameters/>
</rule>
<rule>
<repositoryKey>pmd-unit-tests</repositoryKey>
<key>TestClassWithoutTestCases</key>
<priority>MAJOR</priority>
<parameters/>
</rule>
<rule>
<repositoryKey>pmd-unit-tests</repositoryKey>
<key>UnnecessaryBooleanAssertion</key>
<priority>MINOR</priority>
<parameters/>
</rule>
<rule>
<repositoryKey>pmd-unit-tests</repositoryKey>
<key>UseAssertEqualsInsteadOfAssertTrue</key>
<priority>MINOR</priority>
<parameters/>
</rule>
<rule>
<repositoryKey>pmd-unit-tests</repositoryKey>
<key>UseAssertNullInsteadOfAssertTrue</key>
<priority>MINOR</priority>
<parameters/>
</rule>
<rule>
<repositoryKey>pmd-unit-tests</repositoryKey>
<key>UseAssertSameInsteadOfAssertTrue</key>
<priority>MINOR</priority>
<parameters/>
</rule>
<rule>
<repositoryKey>pmd-unit-tests</repositoryKey>
<key>UseAssertTrueInsteadOfAssertEquals</key>
<priority>MINOR</priority>
<parameters/>
</rule>
</rules>
</profile>
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ rule.pmd.AvoidDollarSigns.name=Naming - Avoid dollar signs
rule.pmd.AvoidUsingShortType.name=Avoid Using Short Type
rule.pmd.NonCaseLabelInSwitchStatement.name=Non Case Label In Switch Statement
rule.pmd.CyclomaticComplexity.name=Code size - cyclomatic complexity
rule.pmd.CyclomaticComplexity.param.showMethodsComplexity=Indicate if method average violation should be added to the report. Default is true.
rule.pmd.CyclomaticComplexity.param.showClassesComplexity=Indicate if class average violation should be added to the report. Default is true.
rule.pmd.CyclomaticComplexity.param.reportLevel=The Cyclomatic Complexity reporting threshold. Default is 10.
rule.pmd.CyclomaticComplexity.param.methodReportLevel=Cyclomatic complexity reporting threshold. Range: 1 - 50.
rule.pmd.CyclomaticComplexity.param.classReportLevel=Total class complexity reporting threshold. Range: 1 - 600.
rule.pmd.AvoidEnumAsIdentifier.name=Avoid Enum As Identifier
rule.pmd.AvoidFieldNameMatchingMethodName.name=Naming - Avoid field name matching method name
rule.pmd.InstantiationToGetClass.name=Instantiation To Get Class
Expand Down Expand Up @@ -155,7 +154,7 @@ rule.pmd.ExcessiveClassLength.param.minimum=The class size reporting threshold.
rule.pmd.FinalFieldCouldBeStatic.name=Final Field Could Be Static
rule.pmd.AvoidRethrowingException.name=Avoid Rethrowing Exception
rule.pmd.AvoidUsingHardCodedIP.name=Avoid Using Hard Coded IP
rule.pmd.AvoidUsingHardCodedIP.param.pattern=Regular Expression. Default is ^[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}$
rule.pmd.AvoidUsingHardCodedIP.param.checkAddressTypes=Defines which IP types should be considered (IPv4, IPv6, IPv4 mapped as IPv6).
rule.pmd.ProtectLogD.name=Android - Protect LOGD
rule.pmd.ProtectLogV.name=Android - Protect LOGV
rule.pmd.MethodNamingConventions.name=Naming - Method naming conventions
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
An application with hard coded IP may become impossible to deploy in some case. It never hurts to externalize IP adresses.
An application with hard-coded IP addresses can become impossible to deploy in some cases. Externalizing IP addresses is preferable.

<p>
This rule is deprecated, use {rule:squid:S1313} instead.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,11 @@
<priority>MAJOR</priority>
<tag>size</tag>
<configKey>rulesets/java/codesize.xml/CyclomaticComplexity</configKey>
<param key="reportLevel" type="INTEGER">
<defaultValue>10</defaultValue>
</param>
<param key="showClassesComplexity" type="BOOLEAN">
<defaultValue>true</defaultValue>
<param key="classReportLevel" type="INTEGER">
<defaultValue>80</defaultValue>
</param>
<param key="showMethodsComplexity" type="BOOLEAN">
<defaultValue>true</defaultValue>
<param key="methodReportLevel" type="INTEGER">
<defaultValue>10</defaultValue>
</param>
<status>DEPRECATED</status>
</rule>
Expand Down Expand Up @@ -1370,9 +1367,9 @@

<rule key="AvoidUsingHardCodedIP">
<priority>MAJOR</priority>
<configKey><![CDATA[rulesets/java/basic.xml/AvoidUsingHardCodedIP]]></configKey>
<param key="pattern" type="REGULAR_EXPRESSION">
<defaultValue><![CDATA[^[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}$]]></defaultValue>
<configKey>rulesets/java/basic.xml/AvoidUsingHardCodedIP</configKey>
<param key="checkAddressTypes" type="STRING">
<defaultValue>IPv4|IPv6|IPv4 mapped IPv6</defaultValue>
</param>
<status>DEPRECATED</status>
</rule>
Expand Down

0 comments on commit f01d209

Please sign in to comment.