Compare commits

...
Author SHA1 Message Date
Andreas Dangel 59b360a60a [maven-release-plugin] prepare release pmd_releases/6.2.0 2018-03-26 09:23:14 +02:00
Andreas Dangel a9dfd6e218 Prepare pmd release 6.2.0 2018-03-26 09:17:36 +02:00
Andreas Dangel 3bcecddbb0 Merge branch 'pr-986' 2018-03-26 09:03:24 +02:00
Juan Martín Sotuyo Dodero 7ef2168eae Merge branch 'pr-958' 2018-03-25 23:39:14 -03:00
Juan Martín Sotuyo Dodero a895d9d3d9 Update changelog, refs #958 2018-03-25 23:37:37 -03:00
BBG 9d9fa22c31 Issue #956: fixed comments 2018-03-25 14:06:43 +08:00
Clément Fournier ea700d84ec Fix designer 2018-03-24 23:48:46 +01:00
Travis CI (pmd-bot) 3f1c441a5c Update documentation 2018-03-24 21:31:12 +00:00
Clément Fournier dbcaf663f4 Fix CompareObjectsWithEquals 2018-03-24 22:17:59 +01:00
Andreas Dangel 14d474f333 Merge branch 'pr-991'
Closes #974
2018-03-24 22:13:37 +01:00
Andreas Dangel 8dfef6c165 Update changelog, refs #974 2018-03-24 22:13:27 +01:00
Clément Fournier ee85254bd0 Merge branch 'master' 2018-03-24 19:05:13 +01:00
Clément Fournier a193af1d4a Use auxclasspath ClassLoader to resolve type qualified names 2018-03-24 19:03:29 +01:00
BBG f0ed81751a Issue #956: add AbstractJavaAnnotatableNode class 2018-03-24 18:39:22 +08:00
BBG f86ca456a0 Issue #956: fixed comments 2018-03-24 18:39:22 +08:00
BBG 7616f8b7a8 Issue #956: Refactor ignoredAnnotationsDescripror in AbstractIgnoredAnnotRule class 2018-03-24 18:39:22 +08:00
BBG e654c265a9 Issue #956: fixed comment 2018-03-24 18:39:21 +08:00
BBG 6888806e12 Fixed issue956 2018-03-24 18:39:21 +08:00
Juan Martín Sotuyo Dodero cec32a8508 Merge branch 'pr-996' 2018-03-23 11:23:31 -03:00
Andreas Dangel 579914fb7e Delete old dogfood rulesets 2018-03-23 10:33:41 +01:00
Andreas Dangel f9ef2c8c4b Remove maven profile jdk8-modules and enable all modules by default
We are now enforcing java9 for building, so these modules are anyway
enabled always
2018-03-23 10:23:56 +01:00
Andreas Dangel f335e83043 Cleanup pom.xml files 2018-03-23 10:21:16 +01:00
Andreas Dangel 6cd084b7ce Use release build-tools 1.1.0: uses latest dogfood ruleset
Closes #361
2018-03-23 10:12:38 +01:00
Juan Martín Sotuyo Dodero f00a085087 Merge branch 'pr-987' 2018-03-22 11:51:14 -03:00
Clément Fournier 5ebde0a0e9 Update changelog, refs #993
Closes #992
2018-03-22 15:05:20 +01:00
Clément Fournier d4c5bd011c Merge branch 'pr-993' 2018-03-22 15:03:40 +01:00
Clément Fournier 89db6fe71d Structure improvement 2018-03-22 15:02:53 +01:00
Clément Fournier d699c277ea Update release notes, refs #989
Closes #978
2018-03-22 14:41:13 +01:00
Clément Fournier b969974653 Merge branch 'pr-989' 2018-03-22 14:40:40 +01:00
Clément Fournier dba594353f Fix link and grammar 2018-03-22 14:35:44 +01:00
Andreas Dangel f2c8b5e2e8 Make the project be importable by IntelliJ IDEA
See https://youtrack.jetbrains.com/issue/IDEA-188690
2018-03-21 21:54:31 +01:00
Bolarinwa Saheed 08f1fea25b Update writing_documentation.md to fix Issue #992 2018-03-21 19:22:15 +01:00
Travis CI (pmd-bot) d865fb4627 Update documentation 2018-03-21 16:11:04 +00:00
Clément Fournier e6e07d22b4 Merge branch 'pr-990' 2018-03-21 16:59:48 +01:00
Clément Fournier da8969ecb7 Update release notes, refs #990
Closes #832
2018-03-21 16:55:58 +01:00
Clément Fournier 6c9c229516 Remove one example
That example would have been flagged by the rule
2018-03-21 16:52:13 +01:00
Bolarinwa Saheed 3e24180da1 Moved all the description inside a single CDATA tag 2018-03-21 14:17:27 +01:00
Travis CI (pmd-bot) 482cb01d7c Update documentation 2018-03-20 22:56:50 +00:00
Clément Fournier b52bd878f6 Update the description of MissingOverride 2018-03-20 23:43:15 +01:00
Bolarinwa Saheed 8f54d451d9 Extended the documentation with some markdown inline 2018-03-20 21:58:38 +01:00
Bolarinwa Saheed 87aafcc8ef Added link to Writing Documentation (Dev Docs) 2018-03-20 20:25:43 +01:00
Bolarinwa Saheed e04f7c2d4f Update design.xml - AvoidThrowingNullPointerException to close Issue #832 2018-03-20 19:54:19 +01:00
Bolarinwa Saheed d3aa3df15e Revert "Doc on AvoidThrowingNullPointerException updated to close Issue #832"
This reverts commit e27dad1862.
2018-03-20 17:58:17 +01:00
Clément Fournier 603a306370 Deprecate former rules, update changelog 2018-03-20 17:47:09 +01:00
Clément Fournier 67acede81f Report multiple blocks under case label 2018-03-20 17:47:09 +01:00
Clément Fournier b4b52e037b Revert "Refine case statement treatment"
This reverts commit 580560c28c56cb57ca5350f9035856b1362400ec.
2018-03-20 17:47:09 +01:00
Clément Fournier 1ae8b1c8e6 Refine case statement treatment
Every dangling unbraced statement will be flagged individually
This complexifies the expression, and still ignores some cases, eg:
  case 3:
    {
      x++;
    }
    {
      y++;
      break;
    }

in which the label should be flagged anyway
2018-03-20 17:47:09 +01:00
Clément Fournier 2711d88e3c Add support for case stmts
A case label is flagged if one of its subordinate
    statements is not braced. The message could be more
    explicit, eg, if we flagged the unbraced statement
    instead of the label in case part of the label's
    statements are braced
2018-03-20 17:46:54 +01:00
Clément Fournier ac3e59a4b7 Add new rule ControlStatementBraces 2018-03-20 17:45:44 +01:00
Bolarinwa Saheed e27dad1862 Doc on AvoidThrowingNullPointerException updated to close Issue #832 2018-03-20 15:45:39 +01:00
Bolarinwa Saheed 55c34feb97 Update Contibute.md to close Issue #978 2018-03-20 14:09:17 +01:00
Clément Fournier 045308948a Fix pmd-java8 tests 2018-03-20 14:07:33 +01:00
Clément Fournier 73f6b2f6cf Fix compilation + checkstyle + pmd 2018-03-20 13:46:45 +01:00
Clément Fournier 9ff4636194 Add getPrintableName to MethodLikeKind 2018-03-19 15:41:56 +01:00
Clément Fournier 0ebd2ba35c Hide ImmutableList, exposing List instead 2018-03-19 15:23:44 +01:00
Clément Fournier 0f61f2576d Move qname classes into another package 2018-03-19 14:25:00 +01:00
Clément Fournier 26e97032ef Minor changes 2018-03-19 14:25:00 +01:00
Clément Fournier 4154a5931e Add qname resolution step to the designer 2018-03-19 14:25:00 +01:00
Clément Fournier ccc1443373 Use JavaQualifiedName to resolve anonymous classes types in ClassTypeResolver
Success! We still need to figure out a straightforward bridge between JavaTypeDefinition and qualified names
2018-03-19 14:25:00 +01:00
Clément Fournier eb8908796c Allow TypeQualifiedNames to resolve their own type lazily
This could allow us to share the JavaQualifiedName implementations
with type resolution
2018-03-19 14:25:00 +01:00
Clément Fournier 1f1637bafd Split JavaQualifiedName into type and operation specific subclasses 2018-03-19 14:24:56 +01:00
Clément Fournier 3c8fcfa6c2 Cleanup QualifiedNameFactory 2018-03-19 14:05:51 +01:00
Clément Fournier 0bba8a2249 Resolve all MethodLike qnames 2018-03-19 14:05:51 +01:00
Clément Fournier 134d529442 Consider anonymous classes
* ASTAllocationExpression and ASTEnumConstant implement JavaQualifiableNode
* It's not satisfying yet, too much code duplication. They should  be
considered by the metrics framework. A good solution would be to add a
new node (see #905)
2018-03-19 14:05:51 +01:00
Clément Fournier 06e38128c4 Wire the visitor into SourceCodeProcessor
We need a way to configure which visitors are run on nodes
obtained from ParserTstUtil
2018-03-19 14:05:51 +01:00
Clément Fournier ba3611f241 Add visitor to populate qualified names
* Currently populates ASTAnyTypeDeclarations with their qname
* Package tails are shared
2018-03-19 14:05:51 +01:00
Juan Martín Sotuyo Dodero 36ac7ddd4c Merge branch 'pr-975' 2018-03-19 01:39:06 -03:00
Juan Martín Sotuyo Dodero 4254fb3f15 Merge branch 'pr-895' 2018-03-19 01:33:07 -03:00
Juan Martín Sotuyo Dodero 1301a3821b Update changelog, refs #895 2018-03-19 01:32:52 -03:00
Travis CI (pmd-bot) 5d2ed89dc1 Update documentation 2018-03-18 15:43:17 +00:00
Juan Martín Sotuyo Dodero acd365ad98 Add new rule to release ruleset 2018-03-18 12:32:04 -03:00
Juan Martín Sotuyo Dodero 2a6a3c5832 Merge branch 'pr-984' 2018-03-18 12:28:38 -03:00
Juan Martín Sotuyo Dodero 0f63ac9131 Update changelog, refs #984 2018-03-18 12:28:19 -03:00
Kirk Clemens 1bd44a3b52 issue983 Update rule to use rule chain pattern 2018-03-17 22:55:04 -05:00
Kirk Clemens 844ab0e6d4 issue983 Add a new test case for an annotation with a single non value element 2018-03-17 19:38:40 -05:00
Kirk Clemens 313da24a71 issue983 Remove pom changes checked in by mistake 2018-03-17 19:37:07 -05:00
Kirk Clemens 28f292f736 issue983 Add new UnnecessaryAnnotationValueElement rule 2018-03-17 19:33:49 -05:00
Clément Fournier c967e63e6a Merge branch 'master', fix merge conflicts 2018-03-13 16:15:44 +01:00
Clément Fournier 58f76f054e Use javadoc @deprecated for ASTConstructorDeclaration.getParameters 2018-03-13 16:13:39 +01:00
Clément Fournier 92da9faee4 Fix pmd warnings 2018-03-13 00:33:37 +01:00
Andreas Dangel b6c84e2ba3 [java] Remove new method getFormalParameters to preserve API compatibility
Refs #912
Refs #881
2018-03-12 20:38:38 +01:00
Clément Fournier 9eb79af16b Update docs 2018-03-12 01:01:58 +01:00
Clément Fournier e643da230d Merge branch 'master' 2018-03-12 00:36:56 +01:00
Travis CI (pmd-bot) f25e35f42d Update documentation 2018-03-11 09:50:28 +00:00
Andreas Dangel d27273581f Fix PMD / Checkstyle issues 2018-03-11 10:32:37 +01:00
Andreas Dangel f4441ce938 Merge branch 'pr-912' 2018-03-11 10:15:28 +01:00
Andreas Dangel 96446f384b Update release notes, new rule MissingOverride, refs #912 2018-03-11 10:07:51 +01:00
Andreas Dangel 4514e6fb19 Update versions for new classes 2018-03-11 10:07:11 +01:00
Juan Martín Sotuyo Dodero 451815bf0a Merge branch 'pr-954' 2018-03-11 02:23:26 -03:00
Juan Martín Sotuyo Dodero 1577931fe3 Update changelog 2018-03-11 02:21:59 -03:00
Juan Martín Sotuyo Dodero 5ead2eda16 Use TemporaryFolder instead 2018-03-11 02:16:01 -03:00
Juan Martín Sotuyo Dodero 53e11481dc Merge branch 'pr-952' 2018-03-11 01:41:22 -03:00
Juan Martín Sotuyo Dodero 75b74afe8d Update changelog, refs #952 2018-03-11 01:40:28 -03:00
Juan Martín Sotuyo Dodero 136d147210 Use positive checks 2018-03-11 01:38:29 -03:00
Juan Martín Sotuyo Dodero 309a2a4924 Merge branch 'pr-951' 2018-03-11 01:28:54 -03:00
Juan Martín Sotuyo Dodero 8f5b2a04b8 Update changelog, refs #951 2018-03-11 01:26:19 -03:00
Clément Fournier 6943803ccb Merge branch 'pr-908' 2018-03-11 01:59:55 +01:00
Juan Martín Sotuyo Dodero df2677457c Use relative links in docs 2018-03-10 18:23:19 -03:00
Juan Martín Sotuyo Dodero 161d7be37e Update broken links in doc 2018-03-10 17:30:19 -03:00
Juan Martín Sotuyo Dodero 05ab784d0b Merge branch 'pr-969' 2018-03-10 17:16:51 -03:00
Juan Martín Sotuyo Dodero 20cddf5079 Update changelog, refs #969 2018-03-10 17:16:12 -03:00
Juan Martín Sotuyo Dodero 185fd15953 Refactor lombok check into separate method 2018-03-10 17:13:25 -03:00
Andreas Dangel d6ccc58f20 Corrections from PR review (#908), make the metrics visitors extendable again 2018-03-10 20:52:11 +01:00
Juan Martín Sotuyo Dodero 5ba5082ae2 Merge branch 'pr-965' 2018-03-10 16:49:13 -03:00
Juan Martín Sotuyo Dodero 7a0a31b149 Update changelog, refs #963 2018-03-10 16:47:56 -03:00
Clément Fournier 9766e632a9 Remove breaking API changes of JavaQualifiedName
Checked with japicmp
2018-03-10 19:20:02 +01:00
Clément Fournier 2fd5d7c41b Remove breaking binary changes with metrics framework
Spotted using japicmp
2018-03-10 18:49:48 +01:00
Clément Fournier 110c8db6e0 Update release notes, refs #970 2018-03-10 17:13:35 +01:00
Clément Fournier c88641fa5c Merge branch 'pr-970' 2018-03-10 17:11:27 +01:00
epidemia 87f2403ec3 Remove unused import 2018-03-10 16:43:59 +03:00
epidemia 6e2b75e245 Fixed inefficient use of keySet iterator instead of entrySet iterator for pdm-java 2018-03-10 16:35:43 +03:00
epidemia 219b80a13b Fixed inefficient use of keySet iterator instead of entrySet iterator for pdm-java 2018-03-10 16:03:19 +03:00
Clément Fournier e592d4baf2 Update release notes, refs #967 2018-03-10 13:50:51 +01:00
Clément Fournier 75ecf7b66f Merge branch 'pr-967' 2018-03-10 13:47:43 +01:00
Clément Fournier 4053e548bf Fix link 2018-03-10 13:47:31 +01:00
Andreas Dangel 8bd1e3b486 Fix PMD dogfood: UncommentedEmptyMethodBody, SimplifyBooleanReturns,
UnnecessaryLocalBeforeReturn, OptimizableToArrayCall,
ClassWithOnlyPrivateConstructorsShouldBeFinal,
UseLocaleWithCaseConversions, NonStaticInitializer, UseCollectionIsEmpty
2018-03-10 12:04:50 +01:00
Kirk Clemens d0ba8998e7 Minor code cleanup 2018-03-09 23:22:49 -06:00
Kirk Clemens d94ff95db8 Fix checkstyle issues 2018-03-09 23:02:29 -06:00
Kirk Clemens 9938a4491c Issue 968 Add logic to handle lombok private constructors with utility classes 2018-03-09 22:53:14 -06:00
epidemia 4c76a7f695 Issue 959: fixed broken link to XPath Rule Tutorial 2018-03-09 18:55:52 +03:00
Andreas Dangel 5b93b14373 Fix PMD dogfood: AssignmentInOperand, LooseCoupling 2018-03-09 16:28:14 +01:00
Stephen 264403b354 Make Varargs trigger ArrayIsStoredDirectly
fixes #963
2018-03-09 07:05:13 -08:00
Andreas Dangel c85abd258a Fix PMD dogfood: AvoidPrefixingMethodParameters, UnnecessaryConstructor,
AvoidUsingShortType
2018-03-09 16:04:15 +01:00
Andreas Dangel 9fb3206d9e PMD dogfood: Upgrade PMD to 6.1.0 2018-03-09 13:00:52 +01:00
Andreas Dangel cf88117820 Fix PMD dogfood: UnusedFormalParameter, UselessParentheses and UselessOverridingMethod 2018-03-09 12:52:20 +01:00
Andreas Dangel b8a34eda97 TypeHelper: Remove misleading warning of incomplete auxclasspath
*   Failing to resolve a class in that situation might happen, since
    we use it to probe types
*   Simplify AbstractJUnitRule
2018-03-09 11:22:15 +01:00
Andreas Dangel f452adbf6a Fix PMD dogfood: SimplifiedTernary 2018-03-09 10:26:23 +01:00
Andreas Dangel 5972c32ecf Fix checkstyle 2018-03-09 10:01:00 +01:00
Andreas Dangel fb4d564e8b Fix PMD dogfood: AvoidBranchingStatementAsLastInLoop 2018-03-09 09:58:04 +01:00
Andreas Dangel f3a358c419 Fix PMD dogfood: EmptyCatchBlock 2018-03-09 09:58:04 +01:00
Andreas Dangel 7aaa9966c2 Fix PMD dogfood: AvoidCatchingThrowable
Refs #361
2018-03-09 09:57:15 +01:00
Andreas Dangel 4ace14899c Fix PMD dogfood: UnusedPrivateField
Refs #361
2018-03-09 09:57:15 +01:00
Andreas Dangel e9abdf7a92 Update pmd configuration to use dogfood and fail build on violations
Refs #361
2018-03-09 09:53:15 +01:00
Clément Fournier ca4500b40b Delete multi property, add tests 2018-03-06 23:42:41 +01:00
Clément Fournier 9fcf146241 Add RegexMultiProperty 2018-03-06 23:41:32 +01:00
Clément Fournier d489698157 Add RegexProperty 2018-03-06 23:40:56 +01:00
Clément Fournier f60a64adb8 checkstyle 2018-03-05 22:25:26 +01:00
Clément Fournier 3d5a0aa4c6 Cleanup 2018-03-05 22:14:57 +01:00
Clément Fournier f8864e9060 Make real Ant test cases 2018-03-05 21:58:05 +01:00
Clément Fournier f74a6b3887 Update release notes 2018-03-05 20:56:48 +01:00
Clément Fournier 5d590a259e Add basic Ant test cases, correct behaviour 2018-03-05 20:52:39 +01:00
Clément Fournier 07a9859ce3 Update Ant task and user docs 2018-03-05 17:15:08 +01:00
Clément Fournier ff1c90d753 Some corrections for PR #954 2018-03-05 16:47:34 +01:00
Clément Fournier 0967d50275 Merge branch 'pr-950' 2018-03-05 14:42:21 +01:00
Clément Fournier e2c6f1e467 Add '-no-cache' CLI switch, to disable incremental analysis
- The switch discards the argument provided to '-cache' if any
- Using the switch disables the suggestion to use incremental analysis
- Rule tests use that option to avoid the warning, which clutters build logs
- Refs #946
2018-03-05 13:47:48 +01:00
BBG 4e2aee3da3 Issue #839: SignatureDeclareThrowsException's IgnoreJUnitCompletely property not honored for constructors 2018-03-04 22:03:58 +08:00
BBG 92031b1792 Add ignoredAnnotations ptoperty to unusedPrivateMethod rule 2018-03-04 21:32:19 +08:00
Juan Martín Sotuyo Dodero 30afff46c6 [java] Avoid a NPE in Type Resolution
- If a class extends a class that references / extends a missing class,
it's possible for the `NoClassDefFoundError` to only rise once we call
`isAnonymousClass()` on the `Class`.
 - For consistency with missing classes, we set the type to null.
 - Logging such missing classes is still pending #194
2018-03-04 03:46:05 -03:00
Travis CI (pmd-bot) dc4f6b180b Update documentation 2018-03-04 00:22:50 +00:00
Clément Fournier e43e7316a7 Merge branch pr-943 2018-03-04 01:06:45 +01:00
Clément Fournier 534d0b62f2 Update release notes, refs #943
Closes #907
2018-03-04 00:57:13 +01:00
Clément Fournier c96358506b Minor cleanups 2018-03-04 00:52:00 +01:00
Clément Fournier ba8aeaf648 Use abstract class + interface for AnyTypeDeclaration hierarchy
Remove one breaking API change
2018-03-04 00:37:04 +01:00
Clément Fournier c9cfb1f29f Rename MethodLike to MethodLikeNode 2018-03-04 00:37:01 +01:00
Clément Fournier 0ef1955080 Use abstract class + interface for MethodLike hierarchy
Removes a breaking API change
2018-03-04 00:36:21 +01:00
Juan Martín Sotuyo Dodero fdd399393d Update changelog, refs #941 2018-03-03 17:08:07 -03:00
Juan Martín Sotuyo Dodero 0e4a793dd3 Merge branch 'pr-941' 2018-03-03 17:06:56 -03:00
Juan Martín Sotuyo Dodero a802fafb29 Merge branch 'pr-948' 2018-03-03 16:02:45 -03:00
Juan Martín Sotuyo Dodero 1415d283bc Merge branch 'pr-947' 2018-03-03 16:01:53 -03:00
BBG 8b279fac25 fixes #907 2018-03-03 22:01:21 +08:00
Andreas Dangel 65a5d3f835 [java] Migrate internal rulesets used in unit tests
Avoiding deprecation warnings
References #946
2018-03-03 11:53:22 +01:00
Andreas Dangel 5a5977b1ea Update release notes, fixes #928 2018-03-02 20:34:34 +01:00
Andreas Dangel d6508c1b28 Fix checkstyle 2018-03-02 20:26:36 +01:00
Andreas Dangel c94b3790bf Upgrade checkstyle, use pmd-build-tools 1.1.0-SNAPSHOT 2018-03-02 20:24:48 +01:00
Clément Fournier 57e050f8c5 Fix typo 2018-03-02 18:34:46 +01:00
reudismam e1b954289a Use char notation to represent a character to improve performance. 2018-02-26 19:40:40 -03:00
Juan Martín Sotuyo Dodero c8cd8e1fa8 Changelog update, Add more details about changes in Rhino 2018-02-25 19:29:23 -03:00
Juan Martín Sotuyo Dodero 502e96e3a3 Merge branch 'pr-930' 2018-02-25 19:27:02 -03:00
Juan Martín Sotuyo Dodero 5bf8945f99 Merge branch 'pr-937' 2018-02-25 19:24:52 -03:00
Andreas Dangel 8947876dab Update release script to follow documented release procedure 2018-02-25 12:05:56 +01:00
Andreas Dangel 67a9f84a9c Fix release script 2018-02-25 10:04:45 +01:00
Andreas Dangel b71857e02b Prepare next development version 2018-02-25 10:00:22 +01:00
Andreas Dangel 098b0dcac0 [maven-release-plugin] prepare for next development iteration 2018-02-25 09:53:26 +01:00
Andreas Dangel 3c280b8ef2 Use Files.move instead of File.renameTo
This prevents problems when building PMD under Windows
2018-02-24 20:40:38 +01:00
Andreas Dangel d619fd360d [ecmascript] Update rhino to 1.7.7.2
Refs #699
2018-02-21 19:56:20 +01:00
Clément Fournier 3257aeae4f Corrections for PR #912 2018-02-20 00:34:15 +01:00
Clément Fournier f2ba4e442c Update FormalParameter type resolution for varargs 2018-02-15 23:58:20 +01:00
Clément Fournier 4e3f1395e4 Consider return type covariance 2018-02-15 11:58:02 +01:00
Clément Fournier 6440d043c8 Cleanup, ensure no false positive 2018-02-15 02:33:33 +01:00
Clément Fournier ab634bf720 Consider Object methods inherited into interfaces 2018-02-15 01:15:33 +01:00
Clément Fournier 8884599f8d Consider varargs parameters 2018-02-15 00:12:21 +01:00
Clément Fournier 64a7e3780e Use bridge method as cue to which method is overridden
This adds support for methods inherited from a supertype with type parameters.
Overloads of the inherited (bridged) methods defined in the subclass
with the same number of parameters still go undetected.

RuleViolationComparator contains a good example of this: the two compare
methods compile to three methods: compare(RV,RV), compare(String,String)
and a bridge method compare(Object,Object). But short of doing more
complicated analysis on the type parameters (or reading the bytecode),
there is no way to determine whether the bridge delegates to the
compare(String,String) or compare(RV,RV), so we can't know which is
overridden.

Another corner case is the following:
public <V> void setProperty(MultiValuePropertyDescriptor<V> propertyDescriptor, V... values)

in AbstractDelegateRule, inherited from Rule. I don't know yet why it's
not detected.
2018-02-14 19:40:29 +01:00
Clément Fournier f330007278 Change algorithm to explore hierarchy only once, avoid exploring same classes twice 2018-02-14 17:32:19 +01:00
Clément Fournier f1d0d74087 Checkstyle 2018-02-14 01:22:22 +01:00
Clément Fournier 4bb707a3bd Test case for generic method 2018-02-14 00:42:07 +01:00
Clément Fournier 5ddb5a2a29 Make ASTFormalParameter a typenode
It feels right
2018-02-14 00:25:00 +01:00
Clément Fournier 9b93311c53 Cleanup ASTAnnotation
It's now a typenode
2018-02-14 00:14:20 +01:00
Clément Fournier 7db3f4a006 Add MissingOverrideRule and some tests
Doesn't support method overriden from generic supertype.
Known limitations that are supposed to be fixed shortly
are #910 and anonymous enum constants (the fix for that
is somewhere in my branches, after #895)
2018-02-13 23:29:37 +01:00
Clément Fournier 8cb7573379 Fix problem with outer enum and annotation types 2018-02-13 12:30:38 +01:00
Clément Fournier 733c871b96 Fix nested anonymous class bug with type resolution 2018-02-13 02:46:55 +01:00
Clément Fournier 1d9a2f194d Fix merge fail + checkstyle 2018-02-08 18:55:00 +01:00
Clément Fournier 40a5e3c569 Merge branch 'master' into improve-javaqualifiedname 2018-02-08 17:03:15 +01:00
Clément Fournier a039788dfb Fix the bugfix
Qualified names now use structural comparison to determine equality. Using toString
hid away some bugs. We still use toString to shortcut the comparison,
since it's cached.
2018-02-08 16:59:07 +01:00
Clément Fournier 3ede676e0a Fix two bugs with qname regex parsing 2018-02-08 16:24:46 +01:00
Clément Fournier 8d520b6d8d Update JavaParserVisitorReducedAdapter to consider MethodLike 2018-02-07 23:14:28 +01:00
Clément Fournier b30d64dd4f Make cyclo count lambdas separately 2018-02-01 00:28:32 +01:00
Clément Fournier 7e2930be3f Adapt the metrics framework to consider MethodLike 2018-02-01 00:28:32 +01:00
Clément Fournier ba10a60a7c Add JavaQualifiedName support for lambdas.
Add MethodLike superclass to ASTMethodDecl, ASTConstructorDecl, ASTLambdaExpr
2018-02-01 00:28:27 +01:00
Clément Fournier 1f6fc296c5 Split JavaQualifiedName into static factory + class 2018-01-31 22:44:59 +01:00
Clément Fournier 72a901089f Optimise format regex
Use possessive quantifiers to make it fail faster
2018-01-31 22:44:59 +01:00
Clément Fournier 332dadce2d Cleanup JavaQualifiedName to make it really immutable
Use an immutable list to avoid array copies everywhere
2018-01-31 22:44:59 +01:00
Clément Fournier 5fcfb0af8f Formatting and code rearrangement 2018-01-31 22:44:59 +01:00
Clément Fournier ece8c7e84c Add qualified name support for anonymous classes
* Simplify the API of JavaQualifiedName
* The name of an anonymous class is for now
  only available via JavaQualifiedName factories,
  not from the nodes
2018-01-31 22:44:59 +01:00
Clément Fournier a3c0f7d3ab Documentation 2018-01-31 22:44:59 +01:00
Clément Fournier f7636f27f3 Make JavaQualifiedName represent packages like in the JLS
The unnamed package is not represented as a lone full stop anymore.

Rename QualifiedNameTest into JavaQualifiedNameTest
2018-01-31 22:44:59 +01:00
Clément Fournier 55d3bbe881 Refactor ASTAnyTypeDeclaration into an abstract class.
Remove getQualifiedName's copypasta.
2018-01-31 22:44:59 +01:00
412 changed files with 7745 additions and 3288 deletions

No files matched your search

+4 -3
View File
@@ -29,10 +29,11 @@ When filing a bug report, please provide as much information as possible, so tha
## Documentation
There is some documentation available under <https://pmd.github.io>. Feel free to create a bug report if
documentation is missing, incomplete or outdated.
There is some documentation available under <https://pmd.github.io/pmd>. Feel free to create a bug report if
documentation is missing, incomplete or outdated. See [Bug reports](#bug-reports).
The documentation is generated as a maven site, the source is available at: <https://github.com/pmd/pmd/tree/master/src/site>
The documentation is generated as a Jekyll site, the source is available at: <https://github.com/pmd/pmd/tree/master/docs>. You can find build instructions there.
For more on contributing documentation check <https://pmd.github.io/pmd/pmd_devdocs_writing_documentation.html>
## Questions
+13 -7
View File
@@ -86,7 +86,7 @@ git commit -a -m "Prepare pmd release ${RELEASE_VERSION}"
(
echo "Committing current changes (pmd.github.io)"
cd ../pmd.github.io
git add _posts/$(date -u +%d-%m-%Y)-PMD-${RELEASE_VERSION}.md
git add _posts/$(date -u +%Y-%m-%d)-PMD-${RELEASE_VERSION}.md
git commit -a -m "Prepare pmd release ${RELEASE_VERSION}"
git push
)
@@ -107,19 +107,20 @@ echo
cat <<EOF
PMD ${RELEASE_VERSION} released
* minor version with lots of bug fixes
* Release Notes: https://pmd.github.io/pmd-${RELEASE_VERSION}/pmd_release_notes.html
* Downloads: https://github.com/pmd/pmd/releases/tag/pmd_releases%2F${RELEASE_VERSION}
* Fixed Bugs: https://sourceforge.net/p/pmd/bugs/milestone/PMD-${RELEASE_VERSION}/
* Documentation: https://pmd.github.io/pmd-${RELEASE_VERSION}/
And Copy-Paste the release notes
EOF
echo
echo "Press enter to continue..."
read
echo
echo "Check the milestone on sourceforge:"
echo "<https://sourceforge.net/p/pmd/bugs/milestones>"
echo "Check the milestone on github:"
echo "<https://github.com/pmd/pmd/milestones>"
echo " --> move any open issues to the next milestone, close the current milestone"
echo " --> Maybe there are some milestones on sourceforge, too: <https://sourceforge.net/p/pmd/bugs/milestones>."
echo
echo
echo
@@ -171,7 +172,12 @@ echo
echo "Send out an announcement mail to the mailing list:"
echo "To: PMD Developers List <pmd-devel@lists.sourceforge.net>"
echo "Subject: [ANNOUNCE] PMD ${RELEASE_VERSION} Released"
echo "Body: !!Copy Changelog!!"
echo
echo " * Downloads: https://github.com/pmd/pmd/releases/tag/pmd_releases%2F${RELEASE_VERSION}"
echo " * Documentation: https://pmd.github.io/pmd-${RELEASE_VERSION}/"
echo
echo " And Copy-Paste the release notes"
echo
echo
echo
echo "------------------------------------------"
+2 -2
View File
@@ -1,8 +1,8 @@
repository: pmd/pmd
pmd:
version: 6.1.0
date: 2018-02-25
version: 6.2.0
date: 2018-03-26
output: web
# this property is useful for conditional filtering of content that is separate from the PDF.
@@ -17,13 +17,48 @@ The pages are in general in [Github Flavored Markdown](https://kramdown.gettalon
## Structure
All documentation is stored in the folder `docs/`. This is the folder, that github and the travis-ci scripts
use to render the site.
The documentation sources can be found in two places based on how they are generated:
- the ones that are manually written (like the one you are reading);
- and the ones that are generated automatically from the category files. All the rule documentation
pages are generated that way.
New pages are stored in the different subfolders under `pages`. The folder structure resembles the sidebar structure.
### Handwritten documentation
All handwritten documentation is stored in the subfolders under `docs/pages`. The folder structure resembles the sidebar structure.
Since all pages use a simple *permalink*, in the rendered html pages, all pages are flattened in one directory.
This makes it easy to view the documentation also offline.
### Rule documentation
The categories for a language `%lang%` are located in
`pmd-%lang%/src/main/resources/category/%lang% `. So for Java the categories
can be found under [pmd-java/src/main/resources/category/java](https://github.com/pmd/pmd/tree/master/pmd-java/src/main/resources/category/java).
The XML category files in this directory are transformed during build into markdown pages
describing the rules they contain. These pages are placed under `docs/` like the handwritten
documentation, and are then rendered with Jekyll like the rest of them. The rule documentation
generator is the separate submodule `pmd-doc`.
Modifying the documentation of a rule should thus not be done on the markdown page,
but directly on the XML `rule` tag corresponding to the rule, in the relevant
category file.
The XML documentation of rules can contain GitHub flavoured markdown.
Just wrap the markdown inside CDATA section in the xml. CDATA sections preserve
all formatting inside the delimiters, and allow to write code samples without
escaping special xml characters. For example:
```
<rule ...>
<description>
<![CDATA[
Full description, can contain markup
And paragraphs
]]>
</description>
...
</rule>
```
## Building
There are two ways, to execute jekyll:
+8 -5
View File
@@ -30,6 +30,7 @@ folder: pmd/rules
* [JUnitUseExpected](pmd_rules_java_bestpractices.html#junituseexpected): In JUnit4, use the @Test(expected) annotation to denote tests that should throw exceptions.
* [LooseCoupling](pmd_rules_java_bestpractices.html#loosecoupling): The use of implementation types (i.e., HashSet) as object references limits your ability to use a...
* [MethodReturnsInternalArray](pmd_rules_java_bestpractices.html#methodreturnsinternalarray): Exposing internal arrays to the caller violates object encapsulation since elements can be remove...
* [MissingOverride](pmd_rules_java_bestpractices.html#missingoverride): Annotating overridden methods with @Override ensures at compile time that the method r...
* [OneDeclarationPerLine](pmd_rules_java_bestpractices.html#onedeclarationperline): Java allows the use of several variables declaration of the same type on one line. However, itcan...
* [PositionLiteralsFirstInCaseInsensitiveComparisons](pmd_rules_java_bestpractices.html#positionliteralsfirstincaseinsensitivecomparisons): Position literals first in comparisons, if the second argument is null then NullPointerExceptions...
* [PositionLiteralsFirstInComparisons](pmd_rules_java_bestpractices.html#positionliteralsfirstincomparisons): Position literals first in comparisons, if the second argument is null then NullPointerExceptions...
@@ -68,6 +69,7 @@ folder: pmd/rules
* [ClassNamingConventions](pmd_rules_java_codestyle.html#classnamingconventions): Class names should always begin with an upper case character.
* [CommentDefaultAccessModifier](pmd_rules_java_codestyle.html#commentdefaultaccessmodifier): To avoid mistakes if we want that a Method, Constructor, Field or Nested class have a default acc...
* [ConfusingTernary](pmd_rules_java_codestyle.html#confusingternary): Avoid negation within an "if" expression with an "else" clause. For example, rephrase:'if (x != ...
* [ControlStatementBraces](pmd_rules_java_codestyle.html#controlstatementbraces): Enforce a policy for braces on control statements. It is recommended to use braces on 'if ... els...
* [DefaultPackage](pmd_rules_java_codestyle.html#defaultpackage): Use explicit scoping instead of accidental usage of default package private level.The rule allows...
* [DontImportJavaLang](pmd_rules_java_codestyle.html#dontimportjavalang): Avoid importing anything from the package 'java.lang'. These classes are automatically imported ...
* [DuplicateImports](pmd_rules_java_codestyle.html#duplicateimports): Duplicate or overlapping import statements should be avoided.
@@ -75,10 +77,10 @@ folder: pmd/rules
* [ExtendsObject](pmd_rules_java_codestyle.html#extendsobject): No need to explicitly extend Object.
* [FieldDeclarationsShouldBeAtStartOfClass](pmd_rules_java_codestyle.html#fielddeclarationsshouldbeatstartofclass): Fields should be declared at the top of the class, before any method declarations, constructors, ...
* [ForLoopShouldBeWhileLoop](pmd_rules_java_codestyle.html#forloopshouldbewhileloop): Some for loops can be simplified to while loops, this makes them more concise.
* [ForLoopsMustUseBraces](pmd_rules_java_codestyle.html#forloopsmustusebraces): Avoid using 'for' statements without using curly braces. If the code formatting or indentation is...
* [ForLoopsMustUseBraces](pmd_rules_java_codestyle.html#forloopsmustusebraces): <span style="border-radius: 0.25em; color: #fff; padding: 0.2em 0.6em 0.3em; display: inline; background-color: #d9534f; font-size: 75%;">Deprecated</span> Avoid using 'for' statements without using curly braces. If the code formatting or indentation is...
* [GenericsNaming](pmd_rules_java_codestyle.html#genericsnaming): Names for references to generic values should be limited to a single uppercase letter.
* [IfElseStmtsMustUseBraces](pmd_rules_java_codestyle.html#ifelsestmtsmustusebraces): Avoid using if..else statements without using surrounding braces. If the code formatting or inden...
* [IfStmtsMustUseBraces](pmd_rules_java_codestyle.html#ifstmtsmustusebraces): Avoid using if statements without using braces to surround the code block. If the code formatting...
* [IfElseStmtsMustUseBraces](pmd_rules_java_codestyle.html#ifelsestmtsmustusebraces): <span style="border-radius: 0.25em; color: #fff; padding: 0.2em 0.6em 0.3em; display: inline; background-color: #d9534f; font-size: 75%;">Deprecated</span> Avoid using if..else statements without using surrounding braces. If the code formatting or inden...
* [IfStmtsMustUseBraces](pmd_rules_java_codestyle.html#ifstmtsmustusebraces): <span style="border-radius: 0.25em; color: #fff; padding: 0.2em 0.6em 0.3em; display: inline; background-color: #d9534f; font-size: 75%;">Deprecated</span> Avoid using if statements without using braces to surround the code block. If the code formatting...
* [LocalHomeNamingConvention](pmd_rules_java_codestyle.html#localhomenamingconvention): The Local Home interface of a Session EJB should be suffixed by 'LocalHome'.
* [LocalInterfaceSessionNamingConvention](pmd_rules_java_codestyle.html#localinterfacesessionnamingconvention): The Local Interface of a Session EJB should be suffixed by 'Local'.
* [LocalVariableCouldBeFinal](pmd_rules_java_codestyle.html#localvariablecouldbefinal): A local variable assigned only once can be declared final.
@@ -98,6 +100,7 @@ folder: pmd/rules
* [ShortVariable](pmd_rules_java_codestyle.html#shortvariable): Fields, local variables, or parameter names that are very short are not helpful to the reader.
* [SuspiciousConstantFieldName](pmd_rules_java_codestyle.html#suspiciousconstantfieldname): Field names using all uppercase characters - Sun's Java naming conventions indicating constants -...
* [TooManyStaticImports](pmd_rules_java_codestyle.html#toomanystaticimports): If you overuse the static import feature, it can make your program unreadable and unmaintainable,...
* [UnnecessaryAnnotationValueElement](pmd_rules_java_codestyle.html#unnecessaryannotationvalueelement): Avoid the use of value in annotations when it's the only element.
* [UnnecessaryConstructor](pmd_rules_java_codestyle.html#unnecessaryconstructor): This rule detects when a constructor is not necessary; i.e., when there is only one constructor,i...
* [UnnecessaryFullyQualifiedName](pmd_rules_java_codestyle.html#unnecessaryfullyqualifiedname): Import statements allow the use of non-fully qualified names. The use of a fully qualified namew...
* [UnnecessaryLocalBeforeReturn](pmd_rules_java_codestyle.html#unnecessarylocalbeforereturn): Avoid the creation of unnecessary local variables
@@ -106,7 +109,7 @@ folder: pmd/rules
* [UselessParentheses](pmd_rules_java_codestyle.html#uselessparentheses): Useless parentheses should be removed.
* [UselessQualifiedThis](pmd_rules_java_codestyle.html#uselessqualifiedthis): Look for qualified this usages in the same class.
* [VariableNamingConventions](pmd_rules_java_codestyle.html#variablenamingconventions): A variable naming conventions rule - customize this to your liking. Currently, itchecks for fina...
* [WhileLoopsMustUseBraces](pmd_rules_java_codestyle.html#whileloopsmustusebraces): Avoid using 'while' statements without using braces to surround the code block. If the code forma...
* [WhileLoopsMustUseBraces](pmd_rules_java_codestyle.html#whileloopsmustusebraces): <span style="border-radius: 0.25em; color: #fff; padding: 0.2em 0.6em 0.3em; display: inline; background-color: #d9534f; font-size: 75%;">Deprecated</span> Avoid using 'while' statements without using braces to surround the code block. If the code forma...
## Design
@@ -117,7 +120,7 @@ folder: pmd/rules
* [AvoidDeeplyNestedIfStmts](pmd_rules_java_design.html#avoiddeeplynestedifstmts): Avoid creating deeply nested if-then statements since they are harder to read and error-prone to ...
* [AvoidRethrowingException](pmd_rules_java_design.html#avoidrethrowingexception): Catch blocks that merely rethrow a caught exception only add to code size and runtime complexity.
* [AvoidThrowingNewInstanceOfSameException](pmd_rules_java_design.html#avoidthrowingnewinstanceofsameexception): Catch blocks that merely rethrow a caught exception wrapped inside a new instance of the same typ...
* [AvoidThrowingNullPointerException](pmd_rules_java_design.html#avoidthrowingnullpointerexception): Avoid throwing NullPointerExceptions. These are confusing because most people will assume that th...
* [AvoidThrowingNullPointerException](pmd_rules_java_design.html#avoidthrowingnullpointerexception): Avoid throwing NullPointerExceptions manually. These are confusing because most people will assum...
* [AvoidThrowingRawExceptionTypes](pmd_rules_java_design.html#avoidthrowingrawexceptiontypes): Avoid throwing certain exception types. Rather than throw a raw RuntimeException, Throwable,Excep...
* [ClassWithOnlyPrivateConstructorsShouldBeFinal](pmd_rules_java_design.html#classwithonlyprivateconstructorsshouldbefinal): A class with only private constructors should be final, unless the private constructoris invoked ...
* [CollapsibleIfStatements](pmd_rules_java_design.html#collapsibleifstatements): Sometimes two consecutive 'if' statements can be consolidated by separating their conditions with...
+42 -1
View File
@@ -5,7 +5,7 @@ permalink: pmd_rules_java_bestpractices.html
folder: pmd/rules/java
sidebaractiveurl: /pmd_rules_java.html
editmepath: ../pmd-java/src/main/resources/category/java/bestpractices.xml
keywords: Best Practices, AbstractClassWithoutAbstractMethod, AccessorClassGeneration, AccessorMethodGeneration, ArrayIsStoredDirectly, AvoidPrintStackTrace, AvoidReassigningParameters, AvoidStringBufferField, AvoidUsingHardCodedIP, CheckResultSet, ConstantsInInterface, DefaultLabelNotLastInSwitchStmt, ForLoopCanBeForeach, GuardLogStatement, JUnit4SuitesShouldUseSuiteAnnotation, JUnit4TestShouldUseAfterAnnotation, JUnit4TestShouldUseBeforeAnnotation, JUnit4TestShouldUseTestAnnotation, JUnitAssertionsShouldIncludeMessage, JUnitTestContainsTooManyAsserts, JUnitTestsShouldIncludeAssert, JUnitUseExpected, LooseCoupling, MethodReturnsInternalArray, OneDeclarationPerLine, PositionLiteralsFirstInCaseInsensitiveComparisons, PositionLiteralsFirstInComparisons, PreserveStackTrace, ReplaceEnumerationWithIterator, ReplaceHashtableWithMap, ReplaceVectorWithList, SwitchStmtsShouldHaveDefault, SystemPrintln, UnusedFormalParameter, UnusedImports, UnusedLocalVariable, UnusedPrivateField, UnusedPrivateMethod, UseAssertEqualsInsteadOfAssertTrue, UseAssertNullInsteadOfAssertTrue, UseAssertSameInsteadOfAssertTrue, UseAssertTrueInsteadOfAssertEquals, UseCollectionIsEmpty, UseVarargs
keywords: Best Practices, AbstractClassWithoutAbstractMethod, AccessorClassGeneration, AccessorMethodGeneration, ArrayIsStoredDirectly, AvoidPrintStackTrace, AvoidReassigningParameters, AvoidStringBufferField, AvoidUsingHardCodedIP, CheckResultSet, ConstantsInInterface, DefaultLabelNotLastInSwitchStmt, ForLoopCanBeForeach, GuardLogStatement, JUnit4SuitesShouldUseSuiteAnnotation, JUnit4TestShouldUseAfterAnnotation, JUnit4TestShouldUseBeforeAnnotation, JUnit4TestShouldUseTestAnnotation, JUnitAssertionsShouldIncludeMessage, JUnitTestContainsTooManyAsserts, JUnitTestsShouldIncludeAssert, JUnitUseExpected, LooseCoupling, MethodReturnsInternalArray, MissingOverride, OneDeclarationPerLine, PositionLiteralsFirstInCaseInsensitiveComparisons, PositionLiteralsFirstInComparisons, PreserveStackTrace, ReplaceEnumerationWithIterator, ReplaceHashtableWithMap, ReplaceVectorWithList, SwitchStmtsShouldHaveDefault, SystemPrintln, UnusedFormalParameter, UnusedImports, UnusedLocalVariable, UnusedPrivateField, UnusedPrivateMethod, UseAssertEqualsInsteadOfAssertTrue, UseAssertNullInsteadOfAssertTrue, UseAssertSameInsteadOfAssertTrue, UseAssertTrueInsteadOfAssertEquals, UseCollectionIsEmpty, UseVarargs
---
## AbstractClassWithoutAbstractMethod
@@ -783,6 +783,35 @@ public class SecureSystem {
<rule ref="category/java/bestpractices.xml/MethodReturnsInternalArray" />
```
## MissingOverride
**Since:** PMD 6.2.0
**Priority:** Medium (3)
**Minimum Language Version:** Java 1.5
Annotating overridden methods with @Override ensures at compile time that
the method really overrides one, which helps refactoring and clarifies intent.
**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.bestpractices.MissingOverrideRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/bestpractices/MissingOverrideRule.java)
**Example(s):**
``` java
public class Foo implements Runnable {
// This method is overridden, and should have an @Override annotation
public void run() {
}
}
```
**Use this rule by referencing it:**
``` xml
<rule ref="category/java/bestpractices.xml/MissingOverride" />
```
## OneDeclarationPerLine
**Since:** PMD 5.0
@@ -1198,6 +1227,12 @@ public class Something {
}
```
**This rule has the following properties:**
|Name|Default Value|Description|
|----|-------------|-----------|
|ignoredAnnotations|[lombok.Setter, lombok.Getter, lombok.Builder, lombok.Data, lombok.RequiredArgsConstructor, lombok.AllArgsConstructor, lombok.Value, lombok.NoArgsConstructor, java.lang.Deprecated, javafx.fxml.FXML]|Fully qualified names of the annotation types that should be ignored by this rule|
**Use this rule by referencing it:**
``` xml
<rule ref="category/java/bestpractices.xml/UnusedPrivateField" />
@@ -1221,6 +1256,12 @@ public class Something {
}
```
**This rule has the following properties:**
|Name|Default Value|Description|
|----|-------------|-----------|
|ignoredAnnotations|[java.lang.Deprecated]|Fully qualified names of the annotation types that should be ignored by this rule|
**Use this rule by referencing it:**
``` xml
<rule ref="category/java/bestpractices.xml/UnusedPrivateMethod" />
+115 -1
View File
@@ -5,7 +5,7 @@ permalink: pmd_rules_java_codestyle.html
folder: pmd/rules/java
sidebaractiveurl: /pmd_rules_java.html
editmepath: ../pmd-java/src/main/resources/category/java/codestyle.xml
keywords: Code Style, AbstractNaming, AtLeastOneConstructor, AvoidDollarSigns, AvoidFinalLocalVariable, AvoidPrefixingMethodParameters, AvoidProtectedFieldInFinalClass, AvoidProtectedMethodInFinalClassNotExtending, AvoidUsingNativeCode, BooleanGetMethodName, CallSuperInConstructor, ClassNamingConventions, CommentDefaultAccessModifier, ConfusingTernary, DefaultPackage, DontImportJavaLang, DuplicateImports, EmptyMethodInAbstractClassShouldBeAbstract, ExtendsObject, FieldDeclarationsShouldBeAtStartOfClass, ForLoopShouldBeWhileLoop, ForLoopsMustUseBraces, GenericsNaming, IfElseStmtsMustUseBraces, IfStmtsMustUseBraces, LocalHomeNamingConvention, LocalInterfaceSessionNamingConvention, LocalVariableCouldBeFinal, LongVariable, MDBAndSessionBeanNamingConvention, MethodArgumentCouldBeFinal, MethodNamingConventions, MIsLeadingVariableName, NoPackage, OnlyOneReturn, PackageCase, PrematureDeclaration, RemoteInterfaceNamingConvention, RemoteSessionInterfaceNamingConvention, ShortClassName, ShortMethodName, ShortVariable, SuspiciousConstantFieldName, TooManyStaticImports, UnnecessaryConstructor, UnnecessaryFullyQualifiedName, UnnecessaryLocalBeforeReturn, UnnecessaryModifier, UnnecessaryReturn, UselessParentheses, UselessQualifiedThis, VariableNamingConventions, WhileLoopsMustUseBraces
keywords: Code Style, AbstractNaming, AtLeastOneConstructor, AvoidDollarSigns, AvoidFinalLocalVariable, AvoidPrefixingMethodParameters, AvoidProtectedFieldInFinalClass, AvoidProtectedMethodInFinalClassNotExtending, AvoidUsingNativeCode, BooleanGetMethodName, CallSuperInConstructor, ClassNamingConventions, CommentDefaultAccessModifier, ConfusingTernary, ControlStatementBraces, DefaultPackage, DontImportJavaLang, DuplicateImports, EmptyMethodInAbstractClassShouldBeAbstract, ExtendsObject, FieldDeclarationsShouldBeAtStartOfClass, ForLoopShouldBeWhileLoop, ForLoopsMustUseBraces, GenericsNaming, IfElseStmtsMustUseBraces, IfStmtsMustUseBraces, LocalHomeNamingConvention, LocalInterfaceSessionNamingConvention, LocalVariableCouldBeFinal, LongVariable, MDBAndSessionBeanNamingConvention, MethodArgumentCouldBeFinal, MethodNamingConventions, MIsLeadingVariableName, NoPackage, OnlyOneReturn, PackageCase, PrematureDeclaration, RemoteInterfaceNamingConvention, RemoteSessionInterfaceNamingConvention, ShortClassName, ShortMethodName, ShortVariable, SuspiciousConstantFieldName, TooManyStaticImports, UnnecessaryAnnotationValueElement, UnnecessaryConstructor, UnnecessaryFullyQualifiedName, UnnecessaryLocalBeforeReturn, UnnecessaryModifier, UnnecessaryReturn, UselessParentheses, UselessQualifiedThis, VariableNamingConventions, WhileLoopsMustUseBraces
---
## AbstractNaming
@@ -462,6 +462,65 @@ boolean bar(int x, int y) {
<rule ref="category/java/codestyle.xml/ConfusingTernary" />
```
## ControlStatementBraces
**Since:** PMD 6.2.0
**Priority:** Medium (3)
Enforce a policy for braces on control statements. It is recommended to use braces on 'if ... else'
statements and loop statements, even if they are optional. This usually makes the code clearer, and
helps prepare the future when you need to add another statement. That said, this rule lets you control
which statements are required to have braces via properties.
From 6.2.0 on, this rule supersedes WhileLoopMustUseBraces, ForLoopMustUseBraces, IfStmtMustUseBraces,
and IfElseStmtMustUseBraces.
```
//WhileStatement[$checkWhileStmt and not(Statement/Block) and not($allowEmptyLoop and Statement/EmptyStatement)]
|
//ForStatement[$checkForStmt and not(Statement/Block) and not($allowEmptyLoop and Statement/EmptyStatement)]
|
//DoStatement[$checkDoWhileStmt and not(Statement/Block) and not($allowEmptyLoop and Statement/EmptyStatement)]
|
(: The violation is reported on the sub statement -- not the if statement :)
//Statement[$checkIfElseStmt and parent::IfStatement and not(child::Block or child::IfStatement)]
|
(: Reports case labels if one of their subordinate statements is not braced :)
//SwitchLabel[$checkCaseStmt]
[count(following-sibling::BlockStatement except following-sibling::SwitchLabel[1]/following-sibling::BlockStatement) > 1
or (some $stmt (: in only the block statements until the next label :)
in following-sibling::BlockStatement except following-sibling::SwitchLabel[1]/following-sibling::BlockStatement
satisfies not($stmt/Statement/Block))]
```
**Example(s):**
``` java
while (true) // not recommended
x++;
while (true) { // preferred approach
x++;
}
```
**This rule has the following properties:**
|Name|Default Value|Description|
|----|-------------|-----------|
|checkIfElseStmt|true|Require that 'if ... else' statements use braces|
|checkWhileStmt|true|Require that 'while' loops use braces|
|checkForStmt|true|Require that 'for' loops should use braces|
|checkDoWhileStmt|true|Require that 'do ... while' loops use braces|
|checkCaseStmt|false|Require that cases of a switch have braces|
|allowEmptyLoop|false|Allow loops with an empty statement, e.g. 'while(true);'|
**Use this rule by referencing it:**
``` xml
<rule ref="category/java/codestyle.xml/ControlStatementBraces" />
```
## DefaultPackage
**Since:** PMD 3.4
@@ -682,6 +741,8 @@ public class Foo {
## ForLoopsMustUseBraces
<span style="border-radius: 0.25em; color: #fff; padding: 0.2em 0.6em 0.3em; display: inline; background-color: #d9534f;">Deprecated</span>
**Since:** PMD 0.7
**Priority:** Medium (3)
@@ -749,6 +810,8 @@ public interface GenericDao<EF extends BaseModel, K extends Serializable> {
## IfElseStmtsMustUseBraces
<span style="border-radius: 0.25em; color: #fff; padding: 0.2em 0.6em 0.3em; display: inline; background-color: #d9534f;">Deprecated</span>
**Since:** PMD 0.2
**Priority:** Medium (3)
@@ -784,6 +847,8 @@ if (foo)
## IfStmtsMustUseBraces
<span style="border-radius: 0.25em; color: #fff; padding: 0.2em 0.6em 0.3em; display: inline; background-color: #d9534f;">Deprecated</span>
**Since:** PMD 1.0
**Priority:** Medium (3)
@@ -1431,6 +1496,53 @@ import static Yoko; // Too much !
<rule ref="category/java/codestyle.xml/TooManyStaticImports" />
```
## UnnecessaryAnnotationValueElement
**Since:** PMD 6.2.0
**Priority:** Medium (3)
Avoid the use of value in annotations when it's the only element.
**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.codestyle.UnnecessaryAnnotationValueElementRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/UnnecessaryAnnotationValueElementRule.java)
**Example(s):**
``` java
@TestClassAnnotation(value = "TEST")
public class Foo {
@TestMemberAnnotation(value = "TEST")
private String y;
@TestMethodAnnotation(value = "TEST")
public void bar() {
int x = 42;
return;
}
}
// should be
@TestClassAnnotation("TEST")
public class Foo {
@TestMemberAnnotation("TEST")
private String y;
@TestMethodAnnotation("TEST")
public void bar() {
int x = 42;
return;
}
}
```
**Use this rule by referencing it:**
``` xml
<rule ref="category/java/codestyle.xml/UnnecessaryAnnotationValueElement" />
```
## UnnecessaryConstructor
**Since:** PMD 1.0
@@ -1771,6 +1883,8 @@ public class Foo {
## WhileLoopsMustUseBraces
<span style="border-radius: 0.25em; color: #fff; padding: 0.2em 0.6em 0.3em; display: inline; background-color: #d9534f;">Deprecated</span>
**Since:** PMD 0.7
**Priority:** Medium (3)
+34 -3
View File
@@ -193,9 +193,33 @@ public void bar() {
**Priority:** High (1)
Avoid throwing NullPointerExceptions. These are confusing because most people will assume that the
virtual machine threw it. Consider using an IllegalArgumentException instead; this will be
clearly seen as a programmer-initiated exception.
Avoid throwing NullPointerExceptions manually. These are confusing because most people will assume that the
virtual machine threw it. To avoid a method being called with a null parameter, you may consider
using an IllegalArgumentException instead, making it clearly seen as a programmer-initiated exception.
However, there are better ways to handle this:
>*Effective Java, 3rd Edition, Item 72: Favor the use of standard exceptions*
>
>Arguably, every erroneous method invocation boils down to an illegal argument or state,
but other exceptions are standardly used for certain kinds of illegal arguments and states.
If a caller passes null in some parameter for which null values are prohibited, convention dictates that
NullPointerException be thrown rather than IllegalArgumentException.
To implement that, you are encouraged to use `java.util.Objects.requireNonNull()`
(introduced in Java 1.7). This method is designed primarily for doing parameter
validation in methods and constructors with multiple parameters.
Your parameter validation could thus look like the following:
```
public class Foo {
private String exampleValue;
void setExampleValue(String exampleValue) {
// check, throw and assignment in a single standard call
this.exampleValue = Objects.requireNonNull(exampleValue, "exampleValue must not be null!");
}
}
```
```
//AllocationExpression/ClassOrInterfaceType[@Image='NullPointerException']
@@ -807,6 +831,12 @@ public class Foo {
}
```
**This rule has the following properties:**
|Name|Default Value|Description|
|----|-------------|-----------|
|ignoredAnnotations|[lombok.Setter, lombok.Getter, lombok.Builder, lombok.Data, lombok.RequiredArgsConstructor, lombok.AllArgsConstructor, lombok.Value, lombok.NoArgsConstructor]|Fully qualified names of the annotation types that should be ignored by this rule|
**Use this rule by referencing it:**
``` xml
<rule ref="category/java/design.xml/ImmutableField" />
@@ -1525,6 +1555,7 @@ public class Foo {
|----|-------------|-----------|
|disallowNotAssignment|false|Disallow violations where the first usage is not an assignment|
|checkInnerClasses|false|Check inner classes|
|ignoredAnnotations|[lombok.Setter, lombok.Getter, lombok.Builder, lombok.Data, lombok.RequiredArgsConstructor, lombok.AllArgsConstructor, lombok.Value, lombok.NoArgsConstructor]|Fully qualified names of the annotation types that should be ignored by this rule|
**Use this rule by referencing it:**
``` xml
@@ -29,7 +29,6 @@ A rule for the politically correct... we don't want to offend anyone.
|----|-------------|-----------|
|disallowedTerms|[idiot, jerk]|Illegal terms or phrases|
|caseSensitive|false|Case sensitive|
|wordsAreRegex|false|Use regular expressions|
**Use this rule by referencing it:**
``` xml
@@ -37,6 +37,7 @@ Without further ado, here is the list of available (single-value) properties:
|FileProperty|java.io.File
|MethodProperty|java.lang.reflect.Method
|TypeProperty|java.lang.Class\<?\>
|RegexProperty|java.util.regex.Pattern
Each of these is complemented by a multivalued variant, whose name ends with "MultiProperty", and which returns a list of values, e.g.
@@ -45,6 +46,7 @@ Each of these is complemented by a multivalued variant, whose name ends with "Mu
|LongMultiProperty | List\<Long\>
|EnumeratedMultiProperty\<*E*\>| List\<*E*\>
Note that RegexProperty doesn't have a multivalued variant, since the delimiters could be part of a specific value.
### For Java rules
@@ -121,6 +123,7 @@ XPath rules can also define their own properties. To do so, you must add a `prop
|Character|CharacterProperty
|Boolean|BooleanProperty
|Class|TypeProperty
|Regex|RegexProperty
Note that enumerated properties are not available in XPath rules (yet?).
+9 -2
View File
@@ -244,6 +244,13 @@ The tool comes with a rather extensive help text, simply running with `-help`!
<td>no</td>
<td></td>
</tr>
<tr>
<td>-no-cache</td>
<td>Explicitly disable incremental analysis. This switch turns off suggestions to use Incremental Analysis,
and causes the <i>-cache</i> option to be discarded if it is provided.
</td>
<td></td>
</tr>
</table>
@@ -253,9 +260,9 @@ Please note that if PMD detects any violations, it will exit with status 4 (sinc
This behavior has been introduced to ease PMD integration into scripts or hooks, such as SVN hooks.
<table>
<tr><td>0</td><td>Everything is fine, now violations found</td></tr>
<tr><td>0</td><td>Everything is fine, no violations found</td></tr>
<tr><td>1</td><td>Couldn't understand command line parameters or PMD exited with an exception</td></tr>
<tr><td>4</td><td>At least one violation has been detected unless '-failOnViolation false' is set.</td></tr>
<tr><td>4</td><td>At least one violation has been detected, unless '-failOnViolation false' is set.</td></tr>
</table>
@@ -30,7 +30,7 @@ for you:
changing the Rule, but you do not need to submit a patch back to the
PMD project.
If you need to modify the Rule, see [How to write a rule](/pmd_devdocs_writing_pmd_rules.html).
If you need to modify the Rule, see [How to write a rule](pmd_devdocs_writing_pmd_rules.html).
Otherwise, the other suppression methods are explained in the following sections.
## Annotations
@@ -181,6 +181,6 @@ suppress reporting specifically typed parameters which are unused:
Note for XPath based suppression to work, you must know how to write
an XPath query that matches the AST structure of the nodes of the
violations you wish to suppress. XPath queries are explained in
[XPath Rule tutorial](/pmd_devdocs_writing_xpath_rules.html).
[XPath Rule tutorial](pmd_userdocs_extending_writing_xpath_rules.html).
Suggestions? Comments? Post them [here](https://github.com/pmd/pmd/issues). Thanks!
+9 -1
View File
@@ -77,7 +77,15 @@ Runs a set of static code analysis rules on some source code files and generates
<td>
The location of the analysis cache file to be used.
Setting this property enables Incremental Analysis, which can greatly improve analysis time without loosing analysis quality.
<b>It's use is strongly recommended.</b>
<b>Its use is strongly recommended.</b>
</td>
<td>No</td>
</tr>
<tr>
<td>noCache</td>
<td>
Setting this property to true disables Incremental Analysis, even if <i>cacheLocation</i> is provided.
You can use this to explicitly turn off suggestions to use incremental analysis, or for testing purposes.
</td>
<td>No</td>
</tr>
+107 -69
View File
@@ -4,98 +4,136 @@ permalink: pmd_release_notes.html
keywords: changelog, release notes
---
## 25-February-2018 - 6.1.0
## 26-March-2018 - 6.2.0
The PMD team is pleased to announce PMD 6.1.0.
The PMD team is pleased to announce PMD 6.2.0.
This is a minor release.
### Table Of Contents
* [New and noteworthy](#new-and-noteworthy)
* [Designer UI](#designer-ui)
* [Fixed Issues](#fixed-issues)
* [API Changes](#api-changes)
* [Changes to the Node interface](#changes-to-the-node-interface)
* [Changes to CPD renderers](#changes-to-cpd-renderers)
* [External Contributions](#external-contributions)
* [Ecmascript (JavaScript)](#ecmascript-javascript)
* [Disable Incremental Analysis](#disable-incremental-analysis)
* [New Rules](#new-rules)
* [Modified Rules](#modified-rules)
* [Fixed Issues](#fixed-issues)
* [API Changes](#api-changes)
* [External Contributions](#external-contributions)
### New and noteworthy
#### Designer UI
#### Ecmascript (JavaScript)
The Designer now supports configuring properties for XPath based rule development.
The Designer is still under development and any feedback is welcome.
The [Rhino Library](https://github.com/mozilla/rhino) has been upgraded from version 1.7.7 to version 1.7.7.2.
You can start the designer via `run.sh designer` or `designer.bat`.
Detailed changes for changed in Rhino can be found:
* [For 1.7.7.2](https://github.com/mozilla/rhino/blob/master/RELEASE-NOTES.md#rhino-1772)
* [For 1.7.7.1](https://github.com/mozilla/rhino/blob/master/RELEASE-NOTES.md#rhino-1771)
Both are bugfixing releases.
#### Disable Incremental Analysis
Some time ago, we added support for [Incremental Analysis](pmd_userdocs_getting_started.html). On PMD 6.0.0, we
started to add warns when not using it, as we strongly believe it's a great improvement to our user's experience as
analysis time is greatly reduced; and in the future we plan to have it enabled by default. However, we realize some
scenarios don't benefit from it (ie: CI jobs), and having the warning logged can be noisy and cause confusion.
To this end, we have added a new flag to allow you to explicitly disable incremental analysis. On CLI, this is
the new `-no-cache` flag. On Ant, there is a `noCache` attribute for the `<pmd>` task.
On both scenarios, disabling the cache takes precedence over setting a cache location.
#### New Rules
* The new Java rule [`MissingOverride`](pmd_rules_java_bestpractices.html#missingoverride)
(category `bestpractices`) detects overridden and implemented methods, which are not marked with the
`@Override` annotation. Annotating overridden methods with `@Override` ensures at compile time that
the method really overrides one, which helps refactoring and clarifies intent.
* The new Java rule [`UnnecessaryAnnotationValueElement`](pmd_rules_java_codestyle.html#unnecessaryannotationvalueelement)
(category `codestyle`) detects annotations with a single element (`value`) that explicitely names it.
That is, doing `@SuppressWarnings(value = "unchecked")` would be flagged in favor of
`@SuppressWarnings("unchecked")`.
* The new Java rule [`ControlStatementBraces`](pmd_rules_java_codestyle.html#controlstatementbraces)
(category `codestyle`) enforces the presence of braces on control statements where they are optional.
Properties allow to customize which statements are required to have braces. This rule replaces the now
deprecated rules `WhileLoopMustUseBraces`, `ForLoopMustUseBraces`, `IfStmtMustUseBraces`, and
`IfElseStmtMustUseBraces`. More than covering the use cases of those rules, this rule also supports
`do ... while` statements and `case` labels of `switch` statements (disabled by default).
#### Modified Rules
* The Java rule `CommentContentRule` (`java-documentation`) previously had the property `wordsAreRegex`. But this
property never had been implemented and is removed now.
* The Java rule `UnusedPrivateField` (`java-bestpractices`) now has a new `ignoredAnnotations` property
that allows to configure annotations that imply the field should be ignored. By default `@java.lang.Deprecated`
and `@javafx.fxml.FXML` are ignored.
* The Java rule `UnusedPrivateMethod` (`java-bestpractices`) now has a new `ignoredAnnotations` property
that allows to configure annotations that imply the method should be ignored. By default `@java.lang.Deprecated`
is ignored.
* The Java rule `ImmutableField` (`java-design`) now has a new `ignoredAnnotations` property
that allows to configure annotations that imply the method should be ignored. By default several `lombok`
annotations are ignored
* The Java rule `SingularField` (`java-design`) now has a new `ignoredAnnotations` property
that allows to configure annotations that imply the method should be ignored. By default several `lombok`
annotations are ignored
#### Deprecated Rules
* The Java rules `WhileLoopMustUseBraces`, `ForLoopMustUseBraces`, `IfStmtMustUseBraces`, and `IfElseStmtMustUseBraces`
are deprecated. They will be replaced by the new rule `ControlStatementBraces`, in the category `codestyle`.
### Fixed Issues
* all
* [#569](https://github.com/pmd/pmd/issues/569): \[core] XPath support requires specific toString implementations
* [#795](https://github.com/pmd/pmd/issues/795): \[cpd] java.lang.OutOfMemoryError
* [#848](https://github.com/pmd/pmd/issues/848): \[doc] Test failures when building pmd-doc under Windows
* [#872](https://github.com/pmd/pmd/issues/872): \[core] NullPointerException at FileDataSource.glomName()
* [#854](https://github.com/pmd/pmd/issues/854): \[ci] Use Java9 for building PMD
* doc
* [#791](https://github.com/pmd/pmd/issues/791): \[doc] Documentation site reorganisation
* [#891](https://github.com/pmd/pmd/issues/891): \[doc] Apex @SuppressWarnings should use single quotes instead of double quotes
* [#909](https://github.com/pmd/pmd/issues/909): \[doc] Please add new PMD Eclipse Plugin to tool integration section
* java
* [#825](https://github.com/pmd/pmd/issues/825): \[java] Excessive\*Length ignores too much
* [#888](https://github.com/pmd/pmd/issues/888): \[java] ParseException occurs with valid '<>' in Java 1.8 mode
* [#920](https://github.com/pmd/pmd/pull/920): \[java] Update valid identifiers in grammar
* java-bestpractices
* [#784](https://github.com/pmd/pmd/issues/784): \[java] ForLoopCanBeForeach false-positive
* [#925](https://github.com/pmd/pmd/issues/925): \[java] UnusedImports false positive for static import
* [#928](https://github.com/pmd/pmd/issues/928): \[core] PMD build failure on Windows
* java-bestpracrtices
* [#907](https://github.com/pmd/pmd/issues/907): \[java] UnusedPrivateField false-positive with @FXML
* [#963](https://github.com/pmd/pmd/issues/965): \[java] ArrayIsStoredDirectly not triggered from variadic functions
* java-codestyle
* [#974](https://github.com/pmd/pmd/issues/974): \[java] Merge \*StmtMustUseBraces rules
* [#983](https://github.com/pmd/pmd/issues/983): \[java] Detect annotations with single value element
* java-design
* [#855](https://github.com/pmd/pmd/issues/855): \[java] ImmutableField false-positive with lambdas
* java-documentation
* [#877](https://github.com/pmd/pmd/issues/877): \[java] CommentRequired valid rule configuration causes PMD error
* java-errorprone
* [#885](https://github.com/pmd/pmd/issues/885): \[java] CompareObjectsWithEqualsRule trigger by enum1 != enum2
* java-performance
* [#541](https://github.com/pmd/pmd/issues/541): \[java] ConsecutiveLiteralAppends with types other than string
* scala
* [#853](https://github.com/pmd/pmd/issues/853): \[scala] Upgrade scala version to support Java 9
* xml
* [#739](https://github.com/pmd/pmd/issues/739): \[xml] IllegalAccessException when accessing attribute using Saxon on JRE 9
* [#832](https://github.com/pmd/pmd/issues/832): \[java] AvoidThrowingNullPointerException documentation suggestion
* [#837](https://github.com/pmd/pmd/issues/837): \[java] CFGs of declared but not called lambdas are treated as parts of an enclosing method's CFG
* [#839](https://github.com/pmd/pmd/issues/839): \[java] SignatureDeclareThrowsException's IgnoreJUnitCompletely property not honored for constructors
* [#968](https://github.com/pmd/pmd/issues/968): \[java] UseUtilityClassRule reports false positive with lombok NoArgsConstructor
* documentation
* [#978](https://github.com/pmd/pmd/issues/978): \[core] Broken link in CONTRIBUTING.md
* [#992](https://github.com/pmd/pmd/issues/992): \[core] Include info about rule doc generation in "Writing Documentation" md page
### API Changes
#### Changes to the Node interface
* A new CLI switch, `-no-cache`, disables incremental analysis and the related suggestion. This overrides the
`-cache` option. The corresponding Ant task parameter is `noCache`.
The method `getXPathNodeName` is added to the `Node` interface, which removes the
use of the `toString` of a node to get its XPath element name (see [#569](https://github.com/pmd/pmd/issues/569)).
A default implementation is provided in `AbstractNode`, to stay compatible
with existing implementors.
* The static method `PMDParameters.transformParametersIntoConfiguration(PMDParameters)` is now deprecated,
for removal in 7.0.0. The new instance method `PMDParameters.toConfiguration()` replaces it.
The `toString` method of a Node is not changed for the time being, and still produces
the name of the XPath node. That behaviour may however change in future major releases,
e.g. to produce a more useful message for debugging.
#### Changes to CPD renderers
The interface `net.sourceforge.pmd.cpd.Renderer` has been deprecated. A new interface `net.sourceforge.pmd.cpd.renderer.CPDRenderer`
has been introduced to replace it. The main difference is that the new interface is meant to render directly to a `java.io.Writer`
rather than to a String. This allows to greatly reduce the memory footprint of CPD, as on large projects, with many duplications,
it was causing `OutOfMemoryError`s (see [#795](https://github.com/pmd/pmd/issues/795)).
`net.sourceforge.pmd.cpd.FileReporter` has also been deprecated as part of this change, as it's no longer needed.
* The method `ASTConstructorDeclaration.getParameters()` has been deprecated in favor of the new method
`getFormalParameters()`. This method is available for both `ASTConstructorDeclaration` and
`ASTMethodDeclaration`.
### External Contributions
* [#790](https://github.com/pmd/pmd/pull/790): \[java] Added some comments for JDK 9 - [Tobias Weimer](https://github.com/tweimer)
* [#803](https://github.com/pmd/pmd/pull/803): \[doc] Added SpotBugs as successor of FindBugs - [Tobias Weimer](https://github.com/tweimer)
* [#828](https://github.com/pmd/pmd/pull/828): \[core] Add operations to manipulate a document - [Gonzalo Ibars Ingman](https://github.com/gibarsin)
* [#830](https://github.com/pmd/pmd/pull/830): \[java] UseArraysAsList: Description added - [Tobias Weimer](https://github.com/tweimer)
* [#845](https://github.com/pmd/pmd/pull/845): \[java] Fix false negative PreserveStackTrace on string concatenation - [Alberto Fernández](https://github.com/albfernandez)
* [#868](https://github.com/pmd/pmd/pull/868): \[core] Improve XPath documentation && make small refactors - [Gonzalo Ibars Ingman](https://github.com/gibarsin)
* [#875](https://github.com/pmd/pmd/pull/875): \[core] Support shortnames when using filelist - [John Zhang](https://github.com/johnjiabinzhang)
* [#886](https://github.com/pmd/pmd/pull/886): \[java] Fix #885 - [Matias Comercio](https://github.com/MatiasComercio)
* [#900](https://github.com/pmd/pmd/pull/900): \[core] Use the isEmpty method instead of comparing the value of size() to 0 - [reudismam](https://github.com/reudismam)
* [#914](https://github.com/pmd/pmd/pull/914): \[doc] Apex @SuppressWarnings documentation updated - [Akshat Bahety](https://github.com/akshatbahety)
* [#918](https://github.com/pmd/pmd/pull/918): \[doc] Add qa-eclipse as new tool - [Akshat Bahety](https://github.com/akshatbahety)
* [#927](https://github.com/pmd/pmd/pull/927): \[java]\[doc] Fix example of AbstractClassWithoutAnyMethod - [Kazuma Watanabe](https://github.com/wata727)
* [#941](https://github.com/pmd/pmd/pull/941): \[java] Use char notation to represent a character to improve performance - [reudismam](https://github.com/reudismam)
* [#943](https://github.com/pmd/pmd/pull/943): \[java] UnusedPrivateField false-positive with @FXML - [BBG](https://github.com/djydewang)
* [#951](https://github.com/pmd/pmd/pull/951): \[java] Add ignoredAnnotations property to unusedPrivateMethod rule - [BBG](https://github.com/djydewang)
* [#952](https://github.com/pmd/pmd/pull/952): \[java] SignatureDeclareThrowsException's IgnoreJUnitCompletely property not honored for constructors - [BBG](https://github.com/djydewang)
* [#958](https://github.com/pmd/pmd/pull/958): \[java] Refactor how we ignore annotated elements in rules - [BBG](https://github.com/djydewang)
* [#965](https://github.com/pmd/pmd/pull/965): \[java] Make Varargs trigger ArrayIsStoredDirectly - [Stephen](https://github.com/pmd/pmd/issues/907)
* [#967](https://github.com/pmd/pmd/pull/967): \[doc] Issue 959: fixed broken link to XPath Rule Tutorial - [Andrey Mochalov](https://github.com/epidemia)
* [#969](https://github.com/pmd/pmd/pull/969): \[java] Issue 968 Add logic to handle lombok private constructors with utility classes - [Kirk Clemens](https://github.com/clem0110)
* [#970](https://github.com/pmd/pmd/pull/970): \[java] Fixed inefficient use of keySet iterator instead of entrySet iterator - [Andrey Mochalov](https://github.com/epidemia)
* [#984](https://github.com/pmd/pmd/pull/984): \[java] issue983 Add new UnnecessaryAnnotationValueElement rule - [Kirk Clemens](https://github.com/clem0110)
* [#989](https://github.com/pmd/pmd/pull/989): \[core] Update Contribute.md to close Issue #978 - [Bolarinwa Saheed Olayemi](https://github.com/refactormyself)
* [#990](https://github.com/pmd/pmd/pull/990): \[java] Updated Doc on AvoidThrowingNullPointerException to close Issue #832 - [Bolarinwa Saheed Olayemi](https://github.com/refactormyself)
* [#993](https://github.com/pmd/pmd/pull/993): \[core] Update writing_documentation.md to fix Issue #992 - [Bolarinwa Saheed Olayemi](https://github.com/refactormyself)
+96
View File
@@ -6,6 +6,102 @@ permalink: pmd_release_notes_old.html
Previous versions of PMD can be downloaded here:
http://sourceforge.net/projects/pmd/files/pmd/
## 25-February-2018 - 6.1.0
The PMD team is pleased to announce PMD 6.1.0.
This is a minor release.
### Table Of Contents
* [New and noteworthy](#new-and-noteworthy)
* [Designer UI](#designer-ui)
* [Fixed Issues](#fixed-issues)
* [API Changes](#api-changes)
* [Changes to the Node interface](#changes-to-the-node-interface)
* [Changes to CPD renderers](#changes-to-cpd-renderers)
* [External Contributions](#external-contributions)
### New and noteworthy
#### Designer UI
The Designer now supports configuring properties for XPath based rule development.
The Designer is still under development and any feedback is welcome.
You can start the designer via `run.sh designer` or `designer.bat`.
### Fixed Issues
* all
* [#569](https://github.com/pmd/pmd/issues/569): \[core] XPath support requires specific toString implementations
* [#795](https://github.com/pmd/pmd/issues/795): \[cpd] java.lang.OutOfMemoryError
* [#848](https://github.com/pmd/pmd/issues/848): \[doc] Test failures when building pmd-doc under Windows
* [#872](https://github.com/pmd/pmd/issues/872): \[core] NullPointerException at FileDataSource.glomName()
* [#854](https://github.com/pmd/pmd/issues/854): \[ci] Use Java9 for building PMD
* doc
* [#791](https://github.com/pmd/pmd/issues/791): \[doc] Documentation site reorganisation
* [#891](https://github.com/pmd/pmd/issues/891): \[doc] Apex @SuppressWarnings should use single quotes instead of double quotes
* [#909](https://github.com/pmd/pmd/issues/909): \[doc] Please add new PMD Eclipse Plugin to tool integration section
* java
* [#825](https://github.com/pmd/pmd/issues/825): \[java] Excessive\*Length ignores too much
* [#888](https://github.com/pmd/pmd/issues/888): \[java] ParseException occurs with valid '<>' in Java 1.8 mode
* [#920](https://github.com/pmd/pmd/pull/920): \[java] Update valid identifiers in grammar
* java-bestpractices
* [#784](https://github.com/pmd/pmd/issues/784): \[java] ForLoopCanBeForeach false-positive
* [#925](https://github.com/pmd/pmd/issues/925): \[java] UnusedImports false positive for static import
* java-design
* [#855](https://github.com/pmd/pmd/issues/855): \[java] ImmutableField false-positive with lambdas
* java-documentation
* [#877](https://github.com/pmd/pmd/issues/877): \[java] CommentRequired valid rule configuration causes PMD error
* java-errorprone
* [#885](https://github.com/pmd/pmd/issues/885): \[java] CompareObjectsWithEqualsRule trigger by enum1 != enum2
* java-performance
* [#541](https://github.com/pmd/pmd/issues/541): \[java] ConsecutiveLiteralAppends with types other than string
* scala
* [#853](https://github.com/pmd/pmd/issues/853): \[scala] Upgrade scala version to support Java 9
* xml
* [#739](https://github.com/pmd/pmd/issues/739): \[xml] IllegalAccessException when accessing attribute using Saxon on JRE 9
### API Changes
#### Changes to the Node interface
The method `getXPathNodeName` is added to the `Node` interface, which removes the
use of the `toString` of a node to get its XPath element name (see [#569](https://github.com/pmd/pmd/issues/569)).
A default implementation is provided in `AbstractNode`, to stay compatible
with existing implementors.
The `toString` method of a Node is not changed for the time being, and still produces
the name of the XPath node. That behaviour may however change in future major releases,
e.g. to produce a more useful message for debugging.
#### Changes to CPD renderers
The interface `net.sourceforge.pmd.cpd.Renderer` has been deprecated. A new interface `net.sourceforge.pmd.cpd.renderer.CPDRenderer`
has been introduced to replace it. The main difference is that the new interface is meant to render directly to a `java.io.Writer`
rather than to a String. This allows to greatly reduce the memory footprint of CPD, as on large projects, with many duplications,
it was causing `OutOfMemoryError`s (see [#795](https://github.com/pmd/pmd/issues/795)).
`net.sourceforge.pmd.cpd.FileReporter` has also been deprecated as part of this change, as it's no longer needed.
### External Contributions
* [#790](https://github.com/pmd/pmd/pull/790): \[java] Added some comments for JDK 9 - [Tobias Weimer](https://github.com/tweimer)
* [#803](https://github.com/pmd/pmd/pull/803): \[doc] Added SpotBugs as successor of FindBugs - [Tobias Weimer](https://github.com/tweimer)
* [#828](https://github.com/pmd/pmd/pull/828): \[core] Add operations to manipulate a document - [Gonzalo Ibars Ingman](https://github.com/gibarsin)
* [#830](https://github.com/pmd/pmd/pull/830): \[java] UseArraysAsList: Description added - [Tobias Weimer](https://github.com/tweimer)
* [#845](https://github.com/pmd/pmd/pull/845): \[java] Fix false negative PreserveStackTrace on string concatenation - [Alberto Fernández](https://github.com/albfernandez)
* [#868](https://github.com/pmd/pmd/pull/868): \[core] Improve XPath documentation && make small refactors - [Gonzalo Ibars Ingman](https://github.com/gibarsin)
* [#875](https://github.com/pmd/pmd/pull/875): \[core] Support shortnames when using filelist - [John Zhang](https://github.com/johnjiabinzhang)
* [#886](https://github.com/pmd/pmd/pull/886): \[java] Fix #885 - [Matias Comercio](https://github.com/MatiasComercio)
* [#900](https://github.com/pmd/pmd/pull/900): \[core] Use the isEmpty method instead of comparing the value of size() to 0 - [reudismam](https://github.com/reudismam)
* [#914](https://github.com/pmd/pmd/pull/914): \[doc] Apex @SuppressWarnings documentation updated - [Akshat Bahety](https://github.com/akshatbahety)
* [#918](https://github.com/pmd/pmd/pull/918): \[doc] Add qa-eclipse as new tool - [Akshat Bahety](https://github.com/akshatbahety)
* [#927](https://github.com/pmd/pmd/pull/927): \[java]\[doc] Fix example of AbstractClassWithoutAnyMethod - [Kazuma Watanabe](https://github.com/wata727)
## 21-January-2018 - 6.0.1
The PMD team is pleased to announce PMD 6.0.1.
+4 -2
View File
@@ -8,12 +8,14 @@
<parent>
<groupId>net.sourceforge.pmd</groupId>
<artifactId>pmd</artifactId>
<version>6.1.0</version>
<version>6.2.0</version>
</parent>
<properties>
<config.basedir>${basedir}/../pmd-core</config.basedir>
<java.version>8</java.version>
<!-- Workaround for https://youtrack.jetbrains.com/issue/IDEA-188690 -->
<maven.compiler.source>1.${java.version}</maven.compiler.source>
<maven.compiler.target>1.${java.version}</maven.compiler.target>
<apex.jorje.version>2017-11-17</apex.jorje.version>
</properties>
+4 -3
View File
@@ -7,13 +7,14 @@
<parent>
<groupId>net.sourceforge.pmd</groupId>
<artifactId>pmd</artifactId>
<version>6.1.0</version>
<version>6.2.0</version>
</parent>
<properties>
<config.basedir>${basedir}/../pmd-core</config.basedir>
<java.version>8</java.version>
<!-- Workaround for https://youtrack.jetbrains.com/issue/IDEA-188690 -->
<maven.compiler.source>1.${java.version}</maven.compiler.source>
<maven.compiler.target>1.${java.version}</maven.compiler.target>
</properties>
<build>
@@ -15,11 +15,9 @@ import net.sourceforge.pmd.lang.apex.ast.ApexNode;
import net.sourceforge.pmd.lang.apex.ast.DumpFacade;
import net.sourceforge.pmd.lang.apex.multifile.ApexMultifileVisitorFacade;
import net.sourceforge.pmd.lang.apex.rule.ApexRuleViolationFactory;
import net.sourceforge.pmd.lang.ast.xpath.AbstractASTXPathHandler;
import net.sourceforge.pmd.lang.ast.xpath.DefaultASTXPathHandler;
import net.sourceforge.pmd.lang.rule.RuleViolationFactory;
import net.sf.saxon.sxpath.IndependentContext;
public class ApexHandler extends AbstractLanguageVersionHandler {
@Override
@@ -30,13 +28,7 @@ public class ApexHandler extends AbstractLanguageVersionHandler {
@Override
public XPathHandler getXPathHandler() {
return new AbstractASTXPathHandler() {
public void initialize() {
}
public void initialize(IndependentContext context) {
}
};
return new DefaultASTXPathHandler();
}
public RuleViolationFactory getRuleViolationFactory() {
@@ -5,29 +5,10 @@
package net.sourceforge.pmd.lang.apex;
import net.sourceforge.pmd.lang.ParserOptions;
import net.sourceforge.pmd.util.StringUtil;
public class ApexParserOptions extends ParserOptions {
@Override
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
result = prime * result + (1237);
result = prime * result + (1237);
result = prime * result;
return result;
}
// empty class for now, since we don't have extra options for Apex
// Once you add something here, make sure to override hashCode and equals
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null || getClass() != obj.getClass()) {
return false;
}
final ApexParserOptions that = (ApexParserOptions) obj;
return StringUtil.isSame(this.suppressMarker, that.suppressMarker, false, false, false);
}
}
@@ -28,15 +28,10 @@ public class ApexParser {
protected final ApexParserOptions parserOptions;
private Map<Integer, String> suppressMap;
private String suppressMarker = "NOPMD";
public ApexParser(ApexParserOptions parserOptions) {
ApexJorjeLogging.disableLogging();
this.parserOptions = parserOptions;
if (parserOptions.getSuppressMarker() != null) {
suppressMarker = parserOptions.getSuppressMarker();
}
}
public Compilation parseApex(final String sourceCode) throws ParseException {
@@ -45,8 +40,7 @@ public class ApexParser {
Locations.useIndexFactory();
CompilerService.INSTANCE.visitAstFromString(sourceCode, visitor);
Compilation astRoot = visitor.getTopLevel();
return astRoot;
return visitor.getTopLevel();
}
public ApexNode<Compilation> parse(final Reader reader) {
@@ -60,8 +54,7 @@ public class ApexParser {
throw new ParseException("Couldn't parse the source - there is not root node - Syntax Error??");
}
ApexNode<Compilation> tree = treeBuilder.build(astRoot);
return tree;
return treeBuilder.build(astRoot);
} catch (IOException e) {
throw new ParseException(e);
}
@@ -20,7 +20,7 @@ import apex.jorje.semantic.symbol.type.TypeInfo;
*
* @author Clément Fournier
*/
public class ApexQualifiedName implements QualifiedName {
public final class ApexQualifiedName implements QualifiedName {
private final String nameSpace;
@@ -155,7 +155,7 @@ public class ApexQualifiedName implements QualifiedName {
List<TypeInfo> paramTypes = node.getNode().getMethodInfo().getParameterTypes();
if (paramTypes.size() > 0) {
if (!paramTypes.isEmpty()) {
sb.append(paramTypes.get(0).getApexName());
for (int i = 1; i < paramTypes.size(); i++) {
@@ -84,11 +84,10 @@ public class CompilerService {
List<SourceFile> sourceFiles = sources.stream().map(s -> SourceFile.builder().setBody(s).build())
.collect(Collectors.toList());
CompilationInput compilationUnit = createCompilationInput(sourceFiles, visitor);
return compile(compilationUnit, visitor, compilerStage);
return compile(compilationUnit, compilerStage);
}
private ApexCompiler compile(CompilationInput compilationInput, AstVisitor<AdditionalPassScope> visitor,
CompilerStage compilerStage) {
private ApexCompiler compile(CompilationInput compilationInput, CompilerStage compilerStage) {
ApexCompiler compiler = ApexCompiler.builder().setInput(compilationInput).build();
compiler.compile(compilerStage);
callAdditionalPassVisitor(compiler);
@@ -29,11 +29,11 @@ import apex.jorje.semantic.symbol.type.TypeInfo;
/**
* @author jspagnola
*/
public class EmptySymbolProvider implements SymbolProvider {
public final class EmptySymbolProvider implements SymbolProvider {
private static final EmptySymbolProvider INSTANCE = new EmptySymbolProvider();
EmptySymbolProvider() {
private EmptySymbolProvider() {
}
public static EmptySymbolProvider get() {
@@ -34,6 +34,7 @@ import apex.jorje.semantic.symbol.resolver.SymbolResolver;
*
* @author jspagnola
*/
@SuppressWarnings("PMD.MissingStaticMethodInNonInstantiatableClass") // this class provides utility classes
public final class TestQueryValidators {
private TestQueryValidators() {
@@ -18,10 +18,6 @@ public class ApexOperationSigMask {
private Set<Visibility> visMask = EnumSet.allOf(Visibility.class);
public ApexOperationSigMask() {
}
/**
* Sets the mask to cover all visibilities.
*/
@@ -16,14 +16,13 @@ import net.sourceforge.pmd.lang.apex.metrics.signature.ApexOperationSigMask;
*
* @author Clément Fournier
*/
class ApexProjectMirror implements ApexSignatureMatcher {
final class ApexProjectMirror implements ApexSignatureMatcher {
static final ApexProjectMirror INSTANCE = new ApexProjectMirror();
private final Map<ApexQualifiedName, ApexClassStats> classes = new HashMap<>();
ApexProjectMirror() {
private ApexProjectMirror() {
}
@@ -21,7 +21,7 @@ public abstract class AbstractStatisticalApexRule extends AbstractApexRule imple
}
public Object[] getViolationParameters(DataPoint point) {
return null;
return new Object[0];
}
@Override
@@ -22,6 +22,7 @@ import net.sourceforge.pmd.lang.rule.ParametricRuleViolation;
* </ul>
* @param <T>
*/
@SuppressWarnings("PMD.UseUtilityClass") // we inherit non-static methods...
public class ApexRuleViolation<T> extends ParametricRuleViolation<Node> {
public ApexRuleViolation(Rule rule, RuleContext ctx, Node node, String message, int beginLine, int endLine) {
@@ -7,6 +7,7 @@ package net.sourceforge.pmd.lang.apex.rule.bestpractices;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Set;
import net.sourceforge.pmd.lang.apex.ast.ASTBlockStatement;
@@ -51,7 +52,7 @@ public class ApexUnitTestClassShouldHaveAssertsRule extends AbstractApexUnitTest
boolean isAssertFound = false;
for (final ASTMethodCallExpression methodCallExpression : methodCalls) {
if (ASSERT_METHODS.contains(methodCallExpression.getFullMethodName().toLowerCase())) {
if (ASSERT_METHODS.contains(methodCallExpression.getFullMethodName().toLowerCase(Locale.ROOT))) {
isAssertFound = true;
break;
}
@@ -45,10 +45,10 @@ public class MethodNamingConventionsRule extends AbstractApexRule {
}
private boolean isPropertyAccessor(ASTMethod node) {
return (node.getParentsOfType(ASTProperty.class).size() > 0);
return !node.getParentsOfType(ASTProperty.class).isEmpty();
}
private boolean isConstructor(ASTMethod node) {
return (node.getNode().getMethodInfo().isConstructor());
return node.getNode().getMethodInfo().isConstructor();
}
}
Loaded 30 of 412 files, more files were not shown because too many files have changed in this diff. Show more