You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ah...@apache.org on 2019/07/31 21:47:22 UTC
[commons-rng] 04/08: RNG-110: PMD rule exceptions to allow Sampler
factory constructors.
This is an automated email from the ASF dual-hosted git repository.
aherbert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-rng.git
commit 6da71403f9cb59cf112823715fdc9b57d15084d1
Author: Alex Herbert <ah...@apache.org>
AuthorDate: Fri Jul 19 22:32:22 2019 +0100
RNG-110: PMD rule exceptions to allow Sampler factory constructors.
Samplers can be utility classes without a Utils/Helper suffix.
Samplers can have short method names, e.g. of(...).
---
src/main/resources/pmd/pmd-ruleset.xml | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/main/resources/pmd/pmd-ruleset.xml b/src/main/resources/pmd/pmd-ruleset.xml
index 9b48ba1..39d64db 100644
--- a/src/main/resources/pmd/pmd-ruleset.xml
+++ b/src/main/resources/pmd/pmd-ruleset.xml
@@ -84,11 +84,14 @@
<property name="violationSuppressXPath"
value="//ClassOrInterfaceDeclaration[@Image='ListSampler' or @Image='ProviderBuilder'
or @Image='ThreadLocalRandomSource' or @Image='SeedFactory']"/>
+ <!-- Allow samplers to have only factory constructors -->
+ <property name="utilityClassPattern" value="[A-Z][a-zA-Z0-9]+(Utils?|Helper|Sampler)" />
</properties>
</rule>
<rule ref="category/java/codestyle.xml/ShortMethodName">
<properties>
- <property name="violationSuppressXPath" value="//ClassOrInterfaceDeclaration[@Image='RejectionInversionZipfSampler']"/>
+ <!-- Allow samplers to have factory constructor method 'of' -->
+ <property name="violationSuppressXPath" value="//ClassOrInterfaceDeclaration[matches(@Image, '^.*Sampler$')]"/>
</properties>
</rule>