From 4d36abe44d6634fe496aa40267e20d81125b147c Mon Sep 17 00:00:00 2001 From: Jens Gerdes Date: Sat, 10 Nov 2018 23:40:18 +0100 Subject: [PATCH 1/3] Fixed Rule "AvoidUsingHardCodedIP". --- .../sonar/it/java/PmdTest/pmd-all-rules.xml | 114 +++++++++++++++++- .../resources/org/sonar/l10n/pmd.properties | 2 +- .../pmd/rules/pmd/AvoidUsingHardCodedIP.html | 2 +- .../resources/org/sonar/plugins/pmd/rules.xml | 4 +- 4 files changed, 115 insertions(+), 7 deletions(-) diff --git a/integration-test/src/test/resources/com/sonar/it/java/PmdTest/pmd-all-rules.xml b/integration-test/src/test/resources/com/sonar/it/java/PmdTest/pmd-all-rules.xml index c03a2d55..e7f5f343 100644 --- a/integration-test/src/test/resources/com/sonar/it/java/PmdTest/pmd-all-rules.xml +++ b/integration-test/src/test/resources/com/sonar/it/java/PmdTest/pmd-all-rules.xml @@ -300,8 +300,8 @@ MAJOR - pattern - ^[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}$ + checkAddressTypes + IPv4|IPv6|IPv4 mapped IPv6 @@ -554,7 +554,7 @@ - + pmd DataflowAnomalyAnalysis @@ -1851,5 +1852,112 @@ MAJOR + + pmd-unit-tests + JUnit4SuitesShouldUseSuiteAnnotation + MAJOR + + + + pmd-unit-tests + JUnit4TestShouldUseAfterAnnotation + MAJOR + + + + pmd-unit-tests + JUnit4TestShouldUseBeforeAnnotation + MAJOR + + + + pmd-unit-tests + JUnit4TestShouldUseTestAnnotation + MAJOR + + + + pmd-unit-tests + JUnitAssertionsShouldIncludeMessage + MINOR + + + + pmd-unit-tests + JUnitSpelling + MAJOR + + + + pmd-unit-tests + JUnitStaticSuite + MAJOR + + + + pmd-unit-tests + JUnitTestContainsTooManyAsserts + MAJOR + + + maximumAsserts + 1 + + + + + pmd-unit-tests + JUnitTestsShouldIncludeAssert + MAJOR + + + + pmd-unit-tests + JUnitUseExpected + MAJOR + + + + pmd-unit-tests + SimplifyBooleanAssertion + MINOR + + + + pmd-unit-tests + TestClassWithoutTestCases + MAJOR + + + + pmd-unit-tests + UnnecessaryBooleanAssertion + MINOR + + + + pmd-unit-tests + UseAssertEqualsInsteadOfAssertTrue + MINOR + + + + pmd-unit-tests + UseAssertNullInsteadOfAssertTrue + MINOR + + + + pmd-unit-tests + UseAssertSameInsteadOfAssertTrue + MINOR + + + + pmd-unit-tests + UseAssertTrueInsteadOfAssertEquals + MINOR + + diff --git a/sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd.properties b/sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd.properties index 4c2584a9..b0998201 100644 --- a/sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd.properties +++ b/sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd.properties @@ -155,7 +155,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 diff --git a/sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/AvoidUsingHardCodedIP.html b/sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/AvoidUsingHardCodedIP.html index 7b0919f9..84485476 100644 --- a/sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/AvoidUsingHardCodedIP.html +++ b/sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd/rules/pmd/AvoidUsingHardCodedIP.html @@ -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.

This rule is deprecated, use {rule:squid:S1313} instead. diff --git a/sonar-pmd-plugin/src/main/resources/org/sonar/plugins/pmd/rules.xml b/sonar-pmd-plugin/src/main/resources/org/sonar/plugins/pmd/rules.xml index f68872e7..7d663f80 100644 --- a/sonar-pmd-plugin/src/main/resources/org/sonar/plugins/pmd/rules.xml +++ b/sonar-pmd-plugin/src/main/resources/org/sonar/plugins/pmd/rules.xml @@ -1371,8 +1371,8 @@ MAJOR - - + + IPv4|IPv6|IPv4 mapped IPv6 DEPRECATED From 48e8fbfe1bb4a4963c32434a1522ee180d0b91b2 Mon Sep 17 00:00:00 2001 From: Jens Gerdes Date: Sun, 11 Nov 2018 22:30:46 +0100 Subject: [PATCH 2/3] Fixed Rule "CyclomaticComplexity". --- .../com/sonar/it/java/PmdTest/pmd-all-rules.xml | 13 ++++--------- .../main/resources/org/sonar/l10n/pmd.properties | 5 ++--- .../main/resources/org/sonar/plugins/pmd/rules.xml | 13 +++++-------- 3 files changed, 11 insertions(+), 20 deletions(-) diff --git a/integration-test/src/test/resources/com/sonar/it/java/PmdTest/pmd-all-rules.xml b/integration-test/src/test/resources/com/sonar/it/java/PmdTest/pmd-all-rules.xml index e7f5f343..99dbbdf0 100644 --- a/integration-test/src/test/resources/com/sonar/it/java/PmdTest/pmd-all-rules.xml +++ b/integration-test/src/test/resources/com/sonar/it/java/PmdTest/pmd-all-rules.xml @@ -554,26 +554,21 @@ - pmd DataflowAnomalyAnalysis diff --git a/sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd.properties b/sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd.properties index b0998201..07530a56 100644 --- a/sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd.properties +++ b/sonar-pmd-plugin/src/main/resources/org/sonar/l10n/pmd.properties @@ -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 diff --git a/sonar-pmd-plugin/src/main/resources/org/sonar/plugins/pmd/rules.xml b/sonar-pmd-plugin/src/main/resources/org/sonar/plugins/pmd/rules.xml index 7d663f80..0948a563 100644 --- a/sonar-pmd-plugin/src/main/resources/org/sonar/plugins/pmd/rules.xml +++ b/sonar-pmd-plugin/src/main/resources/org/sonar/plugins/pmd/rules.xml @@ -76,14 +76,11 @@ MAJOR size rulesets/java/codesize.xml/CyclomaticComplexity - - 10 - - - true + + 80 - - true + + 10 DEPRECATED @@ -1370,7 +1367,7 @@ MAJOR - + rulesets/java/basic.xml/AvoidUsingHardCodedIP IPv4|IPv6|IPv4 mapped IPv6 From ada2ae08ab2f567f707cfe723e79a773247b9e99 Mon Sep 17 00:00:00 2001 From: Jens Gerdes Date: Sun, 11 Nov 2018 23:34:24 +0100 Subject: [PATCH 3/3] Added changelog entries for our changes. --- CHANGELOG.md | 15 +++++++++++++++ README.md | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0dcacb37..8061ed64 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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)) diff --git a/README.md b/README.md index 51eaad2b..3fde0871 100644 --- a/README.md +++ b/README.md @@ -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.