update build, pmd
This commit is contained in:
parent
098fc46687
commit
1912c018d5
15 changed files with 10546 additions and 101 deletions
|
@ -1,7 +1,3 @@
|
||||||
language: java
|
language: java
|
||||||
sudo: required
|
|
||||||
jdk:
|
jdk:
|
||||||
- openjdk11
|
- openjdk11
|
||||||
cache:
|
|
||||||
directories:
|
|
||||||
- $HOME/.m2
|
|
||||||
|
|
94
build.gradle
94
build.gradle
|
@ -1,25 +1,11 @@
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id "org.sonarqube" version "2.6.1"
|
id "org.sonarqube" version "2.8"
|
||||||
id "io.codearte.nexus-staging" version "0.11.0"
|
id "io.codearte.nexus-staging" version "0.21.0"
|
||||||
id "com.github.spotbugs" version "1.6.9"
|
id "com.github.spotbugs" version "2.0.1"
|
||||||
id "org.xbib.gradle.plugin.asciidoctor" version "1.6.0.1"
|
id "org.xbib.gradle.plugin.asciidoctor" version "1.6.0.1"
|
||||||
}
|
}
|
||||||
|
|
||||||
printf "Host: %s\nOS: %s %s %s\nJVM: %s %s %s %s\nGradle: %s Groovy: %s Java: %s\n" +
|
|
||||||
"Build: group: ${project.group} name: ${project.name} version: ${project.version}\n",
|
|
||||||
InetAddress.getLocalHost(),
|
|
||||||
System.getProperty("os.name"),
|
|
||||||
System.getProperty("os.arch"),
|
|
||||||
System.getProperty("os.version"),
|
|
||||||
System.getProperty("java.version"),
|
|
||||||
System.getProperty("java.vm.version"),
|
|
||||||
System.getProperty("java.vm.vendor"),
|
|
||||||
System.getProperty("java.vm.name"),
|
|
||||||
gradle.gradleVersion,
|
|
||||||
GroovySystem.getVersion(),
|
|
||||||
JavaVersion.current()
|
|
||||||
|
|
||||||
if (JavaVersion.current() < JavaVersion.VERSION_11) {
|
if (JavaVersion.current() < JavaVersion.VERSION_11) {
|
||||||
throw new GradleException("This build must be run with java 11")
|
throw new GradleException("This build must be run with java 11")
|
||||||
}
|
}
|
||||||
|
@ -27,7 +13,6 @@ if (JavaVersion.current() < JavaVersion.VERSION_11) {
|
||||||
subprojects {
|
subprojects {
|
||||||
apply plugin: 'java'
|
apply plugin: 'java'
|
||||||
apply plugin: 'maven'
|
apply plugin: 'maven'
|
||||||
apply plugin: 'signing'
|
|
||||||
apply plugin: 'com.github.spotbugs'
|
apply plugin: 'com.github.spotbugs'
|
||||||
apply plugin: 'pmd'
|
apply plugin: 'pmd'
|
||||||
apply plugin: 'checkstyle'
|
apply plugin: 'checkstyle'
|
||||||
|
@ -65,9 +50,7 @@ subprojects {
|
||||||
test {
|
test {
|
||||||
enabled = true
|
enabled = true
|
||||||
useJUnitPlatform()
|
useJUnitPlatform()
|
||||||
// we MUST use this hack because of Elasticsearch 2.2.1 Lucene 5.4.1 MMapDirectory unmap() hackery
|
|
||||||
doFirst {
|
doFirst {
|
||||||
|
|
||||||
jvmArgs = [
|
jvmArgs = [
|
||||||
'--add-exports=java.base/jdk.internal.ref=ALL-UNNAMED',
|
'--add-exports=java.base/jdk.internal.ref=ALL-UNNAMED',
|
||||||
'--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED',
|
'--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED',
|
||||||
|
@ -77,6 +60,7 @@ subprojects {
|
||||||
systemProperty 'java.util.logging.manager', 'org.apache.logging.log4j.jul.LogManager'
|
systemProperty 'java.util.logging.manager', 'org.apache.logging.log4j.jul.LogManager'
|
||||||
systemProperty 'path.home', "${project.buildDir}"
|
systemProperty 'path.home', "${project.buildDir}"
|
||||||
systemProperty 'jna.debug_load', 'true'
|
systemProperty 'jna.debug_load', 'true'
|
||||||
|
failFast = true
|
||||||
testLogging {
|
testLogging {
|
||||||
events 'PASSED', 'FAILED', 'SKIPPED'
|
events 'PASSED', 'FAILED', 'SKIPPED'
|
||||||
}
|
}
|
||||||
|
@ -121,14 +105,6 @@ subprojects {
|
||||||
archives javadocJar, sourcesJar
|
archives javadocJar, sourcesJar
|
||||||
}
|
}
|
||||||
|
|
||||||
if (project.hasProperty('signing.keyId')) {
|
|
||||||
signing {
|
|
||||||
sign configurations.archives
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
apply from: "${rootProject.projectDir}/gradle/publish.gradle"
|
|
||||||
|
|
||||||
spotbugs {
|
spotbugs {
|
||||||
effort = "max"
|
effort = "max"
|
||||||
reportLevel = "low"
|
reportLevel = "low"
|
||||||
|
@ -178,4 +154,66 @@ subprojects {
|
||||||
property "sonar.junit.reportsPath", "build/test-results/test/"
|
property "sonar.junit.reportsPath", "build/test-results/test/"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ext {
|
||||||
|
description = 'Extensions for Elasticsearch clients (node and transport)'
|
||||||
|
scmUrl = 'https://github.com/jprante/elx'
|
||||||
|
scmConnection = 'scm:git:git://github.com/jprante/elx.git'
|
||||||
|
scmDeveloperConnection = 'scm:git:git://github.com/jprante/elx.git'
|
||||||
|
}
|
||||||
|
|
||||||
|
task sonaTypeUpload(type: Upload, dependsOn: build) {
|
||||||
|
group = 'publish'
|
||||||
|
configuration = configurations.archives
|
||||||
|
uploadDescriptor = true
|
||||||
|
repositories {
|
||||||
|
if (project.hasProperty('ossrhUsername')) {
|
||||||
|
mavenDeployer {
|
||||||
|
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
|
||||||
|
repository(url: 'https://oss.sonatype.org/service/local/staging/deploy/maven2') {
|
||||||
|
authentication(userName: ossrhUsername, password: ossrhPassword)
|
||||||
|
}
|
||||||
|
snapshotRepository(url: 'https://oss.sonatype.org/content/repositories/snapshots') {
|
||||||
|
authentication(userName: ossrhUsername, password: ossrhPassword)
|
||||||
|
}
|
||||||
|
pom.project {
|
||||||
|
groupId project.group
|
||||||
|
artifactId project.name
|
||||||
|
version project.version
|
||||||
|
name project.name
|
||||||
|
description description
|
||||||
|
packaging 'jar'
|
||||||
|
inceptionYear '2019'
|
||||||
|
url scmUrl
|
||||||
|
organization {
|
||||||
|
name 'xbib'
|
||||||
|
url 'http://xbib.org'
|
||||||
|
}
|
||||||
|
developers {
|
||||||
|
developer {
|
||||||
|
id 'xbib'
|
||||||
|
name 'Jörg Prante'
|
||||||
|
email 'joergprante@gmail.com'
|
||||||
|
url 'https://github.com/jprante'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
scm {
|
||||||
|
url scmUrl
|
||||||
|
connection scmConnection
|
||||||
|
developerConnection scmDeveloperConnection
|
||||||
|
}
|
||||||
|
licenses {
|
||||||
|
license {
|
||||||
|
name 'The Apache License, Version 2.0'
|
||||||
|
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
nexusStaging {
|
||||||
|
packageGroup = "org.xbib"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
1636
config/pmd/category/java/bestpractices.xml
Normal file
1636
config/pmd/category/java/bestpractices.xml
Normal file
File diff suppressed because it is too large
Load diff
13
config/pmd/category/java/categories.properties
Normal file
13
config/pmd/category/java/categories.properties
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
#
|
||||||
|
# BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||||
|
#
|
||||||
|
|
||||||
|
rulesets.filenames=\
|
||||||
|
category/java/bestpractices.xml,\
|
||||||
|
category/java/codestyle.xml,\
|
||||||
|
category/java/design.xml,\
|
||||||
|
category/java/documentation.xml,\
|
||||||
|
category/java/errorprone.xml,\
|
||||||
|
category/java/multithreading.xml,\
|
||||||
|
category/java/performance.xml,\
|
||||||
|
category/java/security.xml
|
2176
config/pmd/category/java/codestyle.xml
Normal file
2176
config/pmd/category/java/codestyle.xml
Normal file
File diff suppressed because it is too large
Load diff
1657
config/pmd/category/java/design.xml
Normal file
1657
config/pmd/category/java/design.xml
Normal file
File diff suppressed because it is too large
Load diff
144
config/pmd/category/java/documentation.xml
Normal file
144
config/pmd/category/java/documentation.xml
Normal file
|
@ -0,0 +1,144 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
|
||||||
|
<ruleset name="Documentation"
|
||||||
|
xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 https://pmd.sourceforge.io/ruleset_2_0_0.xsd">
|
||||||
|
|
||||||
|
<description>
|
||||||
|
Rules that are related to code documentation.
|
||||||
|
</description>
|
||||||
|
|
||||||
|
<rule name="CommentContent"
|
||||||
|
since="5.0"
|
||||||
|
message="Invalid words or phrases found"
|
||||||
|
class="net.sourceforge.pmd.lang.java.rule.documentation.CommentContentRule"
|
||||||
|
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_documentation.html#commentcontent">
|
||||||
|
<description>
|
||||||
|
A rule for the politically correct... we don't want to offend anyone.
|
||||||
|
</description>
|
||||||
|
<priority>3</priority>
|
||||||
|
<example>
|
||||||
|
<![CDATA[
|
||||||
|
//OMG, this is horrible, Bob is an idiot !!!
|
||||||
|
]]>
|
||||||
|
</example>
|
||||||
|
</rule>
|
||||||
|
|
||||||
|
<rule name="CommentRequired"
|
||||||
|
since="5.1"
|
||||||
|
message="Comment is required"
|
||||||
|
class="net.sourceforge.pmd.lang.java.rule.documentation.CommentRequiredRule"
|
||||||
|
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_documentation.html#commentrequired">
|
||||||
|
<description>
|
||||||
|
Denotes whether comments are required (or unwanted) for specific language elements.
|
||||||
|
</description>
|
||||||
|
<priority>3</priority>
|
||||||
|
<example>
|
||||||
|
<![CDATA[
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @author Jon Doe
|
||||||
|
*/
|
||||||
|
]]>
|
||||||
|
</example>
|
||||||
|
</rule>
|
||||||
|
|
||||||
|
<rule name="CommentSize"
|
||||||
|
since="5.0"
|
||||||
|
message="Comment is too large"
|
||||||
|
class="net.sourceforge.pmd.lang.java.rule.documentation.CommentSizeRule"
|
||||||
|
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_documentation.html#commentsize">
|
||||||
|
<description>
|
||||||
|
Determines whether the dimensions of non-header comments found are within the specified limits.
|
||||||
|
</description>
|
||||||
|
<priority>3</priority>
|
||||||
|
<example>
|
||||||
|
<![CDATA[
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* too many lines!
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
]]>
|
||||||
|
</example>
|
||||||
|
</rule>
|
||||||
|
|
||||||
|
<rule name="UncommentedEmptyConstructor"
|
||||||
|
language="java"
|
||||||
|
since="3.4"
|
||||||
|
message="Document empty constructor"
|
||||||
|
class="net.sourceforge.pmd.lang.rule.XPathRule"
|
||||||
|
typeResolution="true"
|
||||||
|
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_documentation.html#uncommentedemptyconstructor">
|
||||||
|
<description>
|
||||||
|
Uncommented Empty Constructor finds instances where a constructor does not
|
||||||
|
contain statements, but there is no comment. By explicitly commenting empty
|
||||||
|
constructors it is easier to distinguish between intentional (commented)
|
||||||
|
and unintentional empty constructors.
|
||||||
|
</description>
|
||||||
|
<priority>3</priority>
|
||||||
|
<properties>
|
||||||
|
<property name="xpath">
|
||||||
|
<value>
|
||||||
|
<![CDATA[
|
||||||
|
//ConstructorDeclaration[@Private='false']
|
||||||
|
[count(BlockStatement) = 0 and ($ignoreExplicitConstructorInvocation = 'true' or not(ExplicitConstructorInvocation)) and @containsComment = 'false']
|
||||||
|
[not(../Annotation/MarkerAnnotation/Name[pmd-java:typeIs('javax.inject.Inject')])]
|
||||||
|
]]>
|
||||||
|
</value>
|
||||||
|
</property>
|
||||||
|
<property name="ignoreExplicitConstructorInvocation" type="Boolean" description="Ignore explicit constructor invocation when deciding whether constructor is empty or not" value="false"/>
|
||||||
|
</properties>
|
||||||
|
<example>
|
||||||
|
<![CDATA[
|
||||||
|
public Foo() {
|
||||||
|
// This constructor is intentionally empty. Nothing special is needed here.
|
||||||
|
}
|
||||||
|
]]>
|
||||||
|
</example>
|
||||||
|
</rule>
|
||||||
|
|
||||||
|
<rule name="UncommentedEmptyMethodBody"
|
||||||
|
language="java"
|
||||||
|
since="3.4"
|
||||||
|
message="Document empty method body"
|
||||||
|
class="net.sourceforge.pmd.lang.rule.XPathRule"
|
||||||
|
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_documentation.html#uncommentedemptymethodbody">
|
||||||
|
<description>
|
||||||
|
Uncommented Empty Method Body finds instances where a method body does not contain
|
||||||
|
statements, but there is no comment. By explicitly commenting empty method bodies
|
||||||
|
it is easier to distinguish between intentional (commented) and unintentional
|
||||||
|
empty methods.
|
||||||
|
</description>
|
||||||
|
<priority>3</priority>
|
||||||
|
<properties>
|
||||||
|
<property name="xpath">
|
||||||
|
<value>
|
||||||
|
<![CDATA[
|
||||||
|
//MethodDeclaration/Block[count(BlockStatement) = 0 and @containsComment = 'false']
|
||||||
|
]]>
|
||||||
|
</value>
|
||||||
|
</property>
|
||||||
|
</properties>
|
||||||
|
<example>
|
||||||
|
<![CDATA[
|
||||||
|
public void doSomething() {
|
||||||
|
}
|
||||||
|
]]>
|
||||||
|
</example>
|
||||||
|
</rule>
|
||||||
|
|
||||||
|
</ruleset>
|
3383
config/pmd/category/java/errorprone.xml
Normal file
3383
config/pmd/category/java/errorprone.xml
Normal file
File diff suppressed because it is too large
Load diff
393
config/pmd/category/java/multithreading.xml
Normal file
393
config/pmd/category/java/multithreading.xml
Normal file
|
@ -0,0 +1,393 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
|
||||||
|
<ruleset name="Multithreading"
|
||||||
|
xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 https://pmd.sourceforge.io/ruleset_2_0_0.xsd">
|
||||||
|
|
||||||
|
<description>
|
||||||
|
Rules that flag issues when dealing with multiple threads of execution.
|
||||||
|
</description>
|
||||||
|
|
||||||
|
<rule name="AvoidSynchronizedAtMethodLevel"
|
||||||
|
language="java"
|
||||||
|
since="3.0"
|
||||||
|
message="Use block level rather than method level synchronization"
|
||||||
|
class="net.sourceforge.pmd.lang.rule.XPathRule"
|
||||||
|
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_multithreading.html#avoidsynchronizedatmethodlevel">
|
||||||
|
<description>
|
||||||
|
Method-level synchronization can cause problems when new code is added to the method.
|
||||||
|
Block-level synchronization helps to ensure that only the code that needs synchronization
|
||||||
|
gets it.
|
||||||
|
</description>
|
||||||
|
<priority>3</priority>
|
||||||
|
<properties>
|
||||||
|
<property name="xpath">
|
||||||
|
<value>//MethodDeclaration[@Synchronized='true']</value>
|
||||||
|
</property>
|
||||||
|
</properties>
|
||||||
|
<example>
|
||||||
|
<![CDATA[
|
||||||
|
public class Foo {
|
||||||
|
// Try to avoid this:
|
||||||
|
synchronized void foo() {
|
||||||
|
}
|
||||||
|
// Prefer this:
|
||||||
|
void bar() {
|
||||||
|
synchronized(this) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Try to avoid this for static methods:
|
||||||
|
static synchronized void fooStatic() {
|
||||||
|
}
|
||||||
|
|
||||||
|
// Prefer this:
|
||||||
|
static void barStatic() {
|
||||||
|
synchronized(Foo.class) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]]>
|
||||||
|
</example>
|
||||||
|
</rule>
|
||||||
|
|
||||||
|
<rule name="AvoidThreadGroup"
|
||||||
|
language="java"
|
||||||
|
since="3.6"
|
||||||
|
message="Avoid using java.lang.ThreadGroup; it is not thread safe"
|
||||||
|
class="net.sourceforge.pmd.lang.rule.XPathRule"
|
||||||
|
typeResolution="true"
|
||||||
|
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_multithreading.html#avoidthreadgroup">
|
||||||
|
<description>
|
||||||
|
Avoid using java.lang.ThreadGroup; although it is intended to be used in a threaded environment
|
||||||
|
it contains methods that are not thread-safe.
|
||||||
|
</description>
|
||||||
|
<priority>3</priority>
|
||||||
|
<properties>
|
||||||
|
<property name="xpath">
|
||||||
|
<value>
|
||||||
|
<![CDATA[
|
||||||
|
//AllocationExpression/ClassOrInterfaceType[pmd-java:typeIs('java.lang.ThreadGroup')]|
|
||||||
|
//PrimarySuffix[contains(@Image, 'getThreadGroup')]
|
||||||
|
]]>
|
||||||
|
</value>
|
||||||
|
</property>
|
||||||
|
</properties>
|
||||||
|
<example>
|
||||||
|
<![CDATA[
|
||||||
|
public class Bar {
|
||||||
|
void buz() {
|
||||||
|
ThreadGroup tg = new ThreadGroup("My threadgroup");
|
||||||
|
tg = new ThreadGroup(tg, "my thread group");
|
||||||
|
tg = Thread.currentThread().getThreadGroup();
|
||||||
|
tg = System.getSecurityManager().getThreadGroup();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]]>
|
||||||
|
</example>
|
||||||
|
</rule>
|
||||||
|
|
||||||
|
<rule name="AvoidUsingVolatile"
|
||||||
|
language="java"
|
||||||
|
since="4.1"
|
||||||
|
class="net.sourceforge.pmd.lang.rule.XPathRule"
|
||||||
|
message="Use of modifier volatile is not recommended."
|
||||||
|
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_multithreading.html#avoidusingvolatile">
|
||||||
|
<description>
|
||||||
|
Use of the keyword 'volatile' is generally used to fine tune a Java application, and therefore, requires
|
||||||
|
a good expertise of the Java Memory Model. Moreover, its range of action is somewhat misknown. Therefore,
|
||||||
|
the volatile keyword should not be used for maintenance purpose and portability.
|
||||||
|
</description>
|
||||||
|
<priority>2</priority>
|
||||||
|
<properties>
|
||||||
|
<property name="xpath">
|
||||||
|
<value>//FieldDeclaration[contains(@Volatile,'true')]</value>
|
||||||
|
</property>
|
||||||
|
</properties>
|
||||||
|
<example>
|
||||||
|
<![CDATA[
|
||||||
|
public class ThrDeux {
|
||||||
|
private volatile String var1; // not suggested
|
||||||
|
private String var2; // preferred
|
||||||
|
}
|
||||||
|
]]>
|
||||||
|
</example>
|
||||||
|
</rule>
|
||||||
|
|
||||||
|
<rule name="DoNotUseThreads"
|
||||||
|
language="java"
|
||||||
|
since="4.1"
|
||||||
|
class="net.sourceforge.pmd.lang.rule.XPathRule"
|
||||||
|
message="To be compliant to J2EE, a webapp should not use any thread."
|
||||||
|
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_multithreading.html#donotusethreads">
|
||||||
|
<description>
|
||||||
|
The J2EE specification explicitly forbids the use of threads.
|
||||||
|
</description>
|
||||||
|
<priority>3</priority>
|
||||||
|
<properties>
|
||||||
|
<property name="xpath">
|
||||||
|
<value>//ClassOrInterfaceType[@Image = 'Thread' or @Image = 'Runnable']</value>
|
||||||
|
</property>
|
||||||
|
</properties>
|
||||||
|
<example>
|
||||||
|
<![CDATA[
|
||||||
|
// This is not allowed
|
||||||
|
public class UsingThread extends Thread {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Neither this,
|
||||||
|
public class OtherThread implements Runnable {
|
||||||
|
// Nor this ...
|
||||||
|
public void methode() {
|
||||||
|
Runnable thread = new Thread(); thread.run();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]]>
|
||||||
|
</example>
|
||||||
|
</rule>
|
||||||
|
|
||||||
|
<rule name="DontCallThreadRun"
|
||||||
|
language="java"
|
||||||
|
since="4.3"
|
||||||
|
message="Don't call Thread.run() explicitly, use Thread.start()"
|
||||||
|
class="net.sourceforge.pmd.lang.rule.XPathRule"
|
||||||
|
typeResolution="true"
|
||||||
|
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_multithreading.html#dontcallthreadrun">
|
||||||
|
<description>
|
||||||
|
Explicitly calling Thread.run() method will execute in the caller's thread of control. Instead, call Thread.start() for the intended behavior.
|
||||||
|
</description>
|
||||||
|
<priority>4</priority>
|
||||||
|
<properties>
|
||||||
|
<property name="xpath">
|
||||||
|
<value>
|
||||||
|
<![CDATA[
|
||||||
|
//StatementExpression/PrimaryExpression
|
||||||
|
[
|
||||||
|
PrimaryPrefix
|
||||||
|
[
|
||||||
|
./Name[ends-with(@Image, '.run') or @Image = 'run']
|
||||||
|
and substring-before(Name/@Image, '.') =//VariableDeclarator/VariableDeclaratorId/@Image
|
||||||
|
[../../../Type/ReferenceType/ClassOrInterfaceType[pmd-java:typeIs('java.lang.Thread')]]
|
||||||
|
or (./AllocationExpression/ClassOrInterfaceType[pmd-java:typeIs('java.lang.Thread')]
|
||||||
|
and ../PrimarySuffix[@Image = 'run'])
|
||||||
|
]
|
||||||
|
]
|
||||||
|
]]>
|
||||||
|
</value>
|
||||||
|
</property>
|
||||||
|
</properties>
|
||||||
|
<example>
|
||||||
|
<![CDATA[
|
||||||
|
Thread t = new Thread();
|
||||||
|
t.run(); // use t.start() instead
|
||||||
|
new Thread().run(); // same violation
|
||||||
|
]]>
|
||||||
|
</example>
|
||||||
|
</rule>
|
||||||
|
|
||||||
|
<rule name="DoubleCheckedLocking"
|
||||||
|
language="java"
|
||||||
|
since="1.04"
|
||||||
|
message="Double checked locking is not thread safe in Java."
|
||||||
|
class="net.sourceforge.pmd.lang.java.rule.multithreading.DoubleCheckedLockingRule"
|
||||||
|
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_multithreading.html#doublecheckedlocking">
|
||||||
|
<description>
|
||||||
|
Partially created objects can be returned by the Double Checked Locking pattern when used in Java.
|
||||||
|
An optimizing JRE may assign a reference to the baz variable before it calls the constructor of the object the
|
||||||
|
reference points to.
|
||||||
|
|
||||||
|
Note: With Java 5, you can make Double checked locking work, if you declare the variable to be `volatile`.
|
||||||
|
|
||||||
|
For more details refer to: <http://www.javaworld.com/javaworld/jw-02-2001/jw-0209-double.html>
|
||||||
|
or <http://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html>
|
||||||
|
</description>
|
||||||
|
<priority>1</priority>
|
||||||
|
<example>
|
||||||
|
<![CDATA[
|
||||||
|
public class Foo {
|
||||||
|
/*volatile */ Object baz = null; // fix for Java5 and later: volatile
|
||||||
|
Object bar() {
|
||||||
|
if (baz == null) { // baz may be non-null yet not fully created
|
||||||
|
synchronized(this) {
|
||||||
|
if (baz == null) {
|
||||||
|
baz = new Object();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return baz;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]]>
|
||||||
|
</example>
|
||||||
|
</rule>
|
||||||
|
|
||||||
|
<rule name="NonThreadSafeSingleton"
|
||||||
|
since="3.4"
|
||||||
|
message="Singleton is not thread safe"
|
||||||
|
class="net.sourceforge.pmd.lang.java.rule.multithreading.NonThreadSafeSingletonRule"
|
||||||
|
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_multithreading.html#nonthreadsafesingleton">
|
||||||
|
<description>
|
||||||
|
Non-thread safe singletons can result in bad state changes. Eliminate
|
||||||
|
static singletons if possible by instantiating the object directly. Static
|
||||||
|
singletons are usually not needed as only a single instance exists anyway.
|
||||||
|
Other possible fixes are to synchronize the entire method or to use an
|
||||||
|
[initialize-on-demand holder class](https://en.wikipedia.org/wiki/Initialization-on-demand_holder_idiom).
|
||||||
|
|
||||||
|
Refrain from using the double-checked locking pattern. The Java Memory Model doesn't
|
||||||
|
guarantee it to work unless the variable is declared as `volatile`, adding an uneeded
|
||||||
|
performance penalty. [Reference](http://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html)
|
||||||
|
|
||||||
|
See Effective Java, item 48.
|
||||||
|
</description>
|
||||||
|
<priority>3</priority>
|
||||||
|
<example>
|
||||||
|
<![CDATA[
|
||||||
|
private static Foo foo = null;
|
||||||
|
|
||||||
|
//multiple simultaneous callers may see partially initialized objects
|
||||||
|
public static Foo getFoo() {
|
||||||
|
if (foo==null) {
|
||||||
|
foo = new Foo();
|
||||||
|
}
|
||||||
|
return foo;
|
||||||
|
}
|
||||||
|
]]>
|
||||||
|
</example>
|
||||||
|
</rule>
|
||||||
|
|
||||||
|
<rule name="UnsynchronizedStaticDateFormatter"
|
||||||
|
since="3.6"
|
||||||
|
deprecated="true"
|
||||||
|
message="Static DateFormatter objects should be accessed in a synchronized manner"
|
||||||
|
class="net.sourceforge.pmd.lang.java.rule.multithreading.UnsynchronizedStaticDateFormatterRule"
|
||||||
|
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_multithreading.html#unsynchronizedstaticdateformatter">
|
||||||
|
<description>
|
||||||
|
SimpleDateFormat instances are not synchronized. Sun recommends using separate format instances
|
||||||
|
for each thread. If multiple threads must access a static formatter, the formatter must be
|
||||||
|
synchronized either on method or block level.
|
||||||
|
|
||||||
|
This rule has been deprecated in favor of the rule {% rule UnsynchronizedStaticFormatter %}.
|
||||||
|
</description>
|
||||||
|
<priority>3</priority>
|
||||||
|
<example>
|
||||||
|
<![CDATA[
|
||||||
|
public class Foo {
|
||||||
|
private static final SimpleDateFormat sdf = new SimpleDateFormat();
|
||||||
|
void bar() {
|
||||||
|
sdf.format(); // poor, no thread-safety
|
||||||
|
}
|
||||||
|
synchronized void foo() {
|
||||||
|
sdf.format(); // preferred
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]]>
|
||||||
|
</example>
|
||||||
|
</rule>
|
||||||
|
|
||||||
|
<rule name="UnsynchronizedStaticFormatter"
|
||||||
|
since="6.11.0"
|
||||||
|
message="Static Formatter objects should be accessed in a synchronized manner"
|
||||||
|
class="net.sourceforge.pmd.lang.java.rule.multithreading.UnsynchronizedStaticFormatterRule"
|
||||||
|
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_multithreading.html#unsynchronizedstaticformatter">
|
||||||
|
<description>
|
||||||
|
Instances of `java.text.Format` are generally not synchronized.
|
||||||
|
Sun recommends using separate format instances for each thread.
|
||||||
|
If multiple threads must access a static formatter, the formatter must be
|
||||||
|
synchronized either on method or block level.
|
||||||
|
</description>
|
||||||
|
<priority>3</priority>
|
||||||
|
<example>
|
||||||
|
<![CDATA[
|
||||||
|
public class Foo {
|
||||||
|
private static final SimpleDateFormat sdf = new SimpleDateFormat();
|
||||||
|
void bar() {
|
||||||
|
sdf.format(); // poor, no thread-safety
|
||||||
|
}
|
||||||
|
synchronized void foo() {
|
||||||
|
sdf.format(); // preferred
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]]>
|
||||||
|
</example>
|
||||||
|
</rule>
|
||||||
|
|
||||||
|
<rule name="UseConcurrentHashMap"
|
||||||
|
language="java"
|
||||||
|
minimumLanguageVersion="1.5"
|
||||||
|
since="4.2.6"
|
||||||
|
message="If you run in Java5 or newer and have concurrent access, you should use the ConcurrentHashMap implementation"
|
||||||
|
class="net.sourceforge.pmd.lang.rule.XPathRule"
|
||||||
|
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_multithreading.html#useconcurrenthashmap">
|
||||||
|
<description>
|
||||||
|
Since Java5 brought a new implementation of the Map designed for multi-threaded access, you can
|
||||||
|
perform efficient map reads without blocking other threads.
|
||||||
|
</description>
|
||||||
|
<priority>3</priority>
|
||||||
|
<properties>
|
||||||
|
<property name="xpath">
|
||||||
|
<value>
|
||||||
|
<![CDATA[
|
||||||
|
//Type[../VariableDeclarator/VariableInitializer//AllocationExpression/ClassOrInterfaceType[@Image != 'ConcurrentHashMap']]
|
||||||
|
/ReferenceType/ClassOrInterfaceType[@Image = 'Map']
|
||||||
|
]]>
|
||||||
|
</value>
|
||||||
|
</property>
|
||||||
|
</properties>
|
||||||
|
<example>
|
||||||
|
<![CDATA[
|
||||||
|
public class ConcurrentApp {
|
||||||
|
public void getMyInstance() {
|
||||||
|
Map map1 = new HashMap(); // fine for single-threaded access
|
||||||
|
Map map2 = new ConcurrentHashMap(); // preferred for use with multiple threads
|
||||||
|
|
||||||
|
// the following case will be ignored by this rule
|
||||||
|
Map map3 = someModule.methodThatReturnMap(); // might be OK, if the returned map is already thread-safe
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]]>
|
||||||
|
</example>
|
||||||
|
</rule>
|
||||||
|
|
||||||
|
<rule name="UseNotifyAllInsteadOfNotify"
|
||||||
|
language="java"
|
||||||
|
since="3.0"
|
||||||
|
message="Call Thread.notifyAll() rather than Thread.notify()"
|
||||||
|
class="net.sourceforge.pmd.lang.rule.XPathRule"
|
||||||
|
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_multithreading.html#usenotifyallinsteadofnotify">
|
||||||
|
<description>
|
||||||
|
Thread.notify() awakens a thread monitoring the object. If more than one thread is monitoring, then only
|
||||||
|
one is chosen. The thread chosen is arbitrary; thus its usually safer to call notifyAll() instead.
|
||||||
|
</description>
|
||||||
|
<priority>3</priority>
|
||||||
|
<properties>
|
||||||
|
<property name="xpath">
|
||||||
|
<value>
|
||||||
|
<![CDATA[
|
||||||
|
//StatementExpression/PrimaryExpression
|
||||||
|
[PrimarySuffix/Arguments[@ArgumentCount = '0']]
|
||||||
|
[
|
||||||
|
PrimaryPrefix[
|
||||||
|
./Name[@Image='notify' or ends-with(@Image,'.notify')]
|
||||||
|
or ../PrimarySuffix/@Image='notify'
|
||||||
|
or (./AllocationExpression and ../PrimarySuffix[@Image='notify'])
|
||||||
|
]
|
||||||
|
]
|
||||||
|
]]>
|
||||||
|
</value>
|
||||||
|
</property>
|
||||||
|
</properties>
|
||||||
|
<example>
|
||||||
|
<![CDATA[
|
||||||
|
void bar() {
|
||||||
|
x.notify();
|
||||||
|
// If many threads are monitoring x, only one (and you won't know which) will be notified.
|
||||||
|
// use instead:
|
||||||
|
x.notifyAll();
|
||||||
|
}
|
||||||
|
]]>
|
||||||
|
</example>
|
||||||
|
</rule>
|
||||||
|
|
||||||
|
</ruleset>
|
1006
config/pmd/category/java/performance.xml
Normal file
1006
config/pmd/category/java/performance.xml
Normal file
File diff suppressed because it is too large
Load diff
65
config/pmd/category/java/security.xml
Normal file
65
config/pmd/category/java/security.xml
Normal file
|
@ -0,0 +1,65 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
|
||||||
|
<ruleset name="Security" xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 https://pmd.sourceforge.io/ruleset_2_0_0.xsd">
|
||||||
|
|
||||||
|
<description>
|
||||||
|
Rules that flag potential security flaws.
|
||||||
|
</description>
|
||||||
|
|
||||||
|
<rule name="HardCodedCryptoKey"
|
||||||
|
since="6.4.0"
|
||||||
|
message="Do not use hard coded encryption keys"
|
||||||
|
class="net.sourceforge.pmd.lang.java.rule.security.HardCodedCryptoKeyRule"
|
||||||
|
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_security.html#hardcodedcryptokey">
|
||||||
|
<description>
|
||||||
|
Do not use hard coded values for cryptographic operations. Please store keys outside of source code.
|
||||||
|
</description>
|
||||||
|
<priority>3</priority>
|
||||||
|
<example>
|
||||||
|
<![CDATA[
|
||||||
|
public class Foo {
|
||||||
|
void good() {
|
||||||
|
SecretKeySpec secretKeySpec = new SecretKeySpec(Properties.getKey(), "AES");
|
||||||
|
}
|
||||||
|
|
||||||
|
void bad() {
|
||||||
|
SecretKeySpec secretKeySpec = new SecretKeySpec("my secret here".getBytes(), "AES");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]]>
|
||||||
|
</example>
|
||||||
|
</rule>
|
||||||
|
|
||||||
|
<rule name="InsecureCryptoIv"
|
||||||
|
since="6.3.0"
|
||||||
|
message="Do not use hard coded initialization vector in crypto operations"
|
||||||
|
class="net.sourceforge.pmd.lang.java.rule.security.InsecureCryptoIvRule"
|
||||||
|
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_security.html#insecurecryptoiv">
|
||||||
|
<description>
|
||||||
|
Do not use hard coded initialization vector in cryptographic operations. Please use a randomly generated IV.
|
||||||
|
</description>
|
||||||
|
<priority>3</priority>
|
||||||
|
<example>
|
||||||
|
<![CDATA[
|
||||||
|
public class Foo {
|
||||||
|
void good() {
|
||||||
|
SecureRandom random = new SecureRandom();
|
||||||
|
byte iv[] = new byte[16];
|
||||||
|
random.nextBytes(bytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
void bad() {
|
||||||
|
byte[] iv = new byte[] { 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, };
|
||||||
|
}
|
||||||
|
|
||||||
|
void alsoBad() {
|
||||||
|
byte[] iv = "secret iv in here".getBytes();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]]>
|
||||||
|
</example>
|
||||||
|
</rule>
|
||||||
|
|
||||||
|
</ruleset>
|
|
@ -1,62 +0,0 @@
|
||||||
ext {
|
|
||||||
description = 'Extensions for Elasticsearch clients (node and transport)'
|
|
||||||
scmUrl = 'https://github.com/jprante/elx'
|
|
||||||
scmConnection = 'scm:git:git://github.com/jprante/elx.git'
|
|
||||||
scmDeveloperConnection = 'scm:git:git://github.com/jprante/elx.git'
|
|
||||||
}
|
|
||||||
|
|
||||||
task sonaTypeUpload(type: Upload, dependsOn: build) {
|
|
||||||
group = 'publish'
|
|
||||||
configuration = configurations.archives
|
|
||||||
uploadDescriptor = true
|
|
||||||
repositories {
|
|
||||||
if (project.hasProperty('ossrhUsername')) {
|
|
||||||
mavenDeployer {
|
|
||||||
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
|
|
||||||
repository(url: 'https://oss.sonatype.org/service/local/staging/deploy/maven2') {
|
|
||||||
authentication(userName: ossrhUsername, password: ossrhPassword)
|
|
||||||
}
|
|
||||||
snapshotRepository(url: 'https://oss.sonatype.org/content/repositories/snapshots') {
|
|
||||||
authentication(userName: ossrhUsername, password: ossrhPassword)
|
|
||||||
}
|
|
||||||
pom.project {
|
|
||||||
groupId project.group
|
|
||||||
artifactId project.name
|
|
||||||
version project.version
|
|
||||||
name project.name
|
|
||||||
description description
|
|
||||||
packaging 'jar'
|
|
||||||
inceptionYear '2019'
|
|
||||||
url scmUrl
|
|
||||||
organization {
|
|
||||||
name 'xbib'
|
|
||||||
url 'http://xbib.org'
|
|
||||||
}
|
|
||||||
developers {
|
|
||||||
developer {
|
|
||||||
id 'xbib'
|
|
||||||
name 'Jörg Prante'
|
|
||||||
email 'joergprante@gmail.com'
|
|
||||||
url 'https://github.com/jprante'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
scm {
|
|
||||||
url scmUrl
|
|
||||||
connection scmConnection
|
|
||||||
developerConnection scmDeveloperConnection
|
|
||||||
}
|
|
||||||
licenses {
|
|
||||||
license {
|
|
||||||
name 'The Apache License, Version 2.0'
|
|
||||||
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
nexusStaging {
|
|
||||||
packageGroup = "org.xbib"
|
|
||||||
}
|
|
6
gradle/wrapper/gradle-wrapper.properties
vendored
6
gradle/wrapper/gradle-wrapper.properties
vendored
|
@ -1,6 +1,6 @@
|
||||||
#Mon May 06 11:25:14 CEST 2019
|
#Wed Apr 01 22:38:01 CEST 2020
|
||||||
|
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.3-all.zip
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
|
6
gradlew
vendored
6
gradlew
vendored
|
@ -7,7 +7,7 @@
|
||||||
# you may not use this file except in compliance with the License.
|
# you may not use this file except in compliance with the License.
|
||||||
# You may obtain a copy of the License at
|
# You may obtain a copy of the License at
|
||||||
#
|
#
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
# https://www.apache.org/licenses/LICENSE-2.0
|
||||||
#
|
#
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
@ -125,8 +125,8 @@ if $darwin; then
|
||||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# For Cygwin, switch paths to Windows format before running java
|
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||||
if $cygwin ; then
|
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
|
||||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||||
|
|
2
gradlew.bat
vendored
2
gradlew.bat
vendored
|
@ -5,7 +5,7 @@
|
||||||
@rem you may not use this file except in compliance with the License.
|
@rem you may not use this file except in compliance with the License.
|
||||||
@rem You may obtain a copy of the License at
|
@rem You may obtain a copy of the License at
|
||||||
@rem
|
@rem
|
||||||
@rem http://www.apache.org/licenses/LICENSE-2.0
|
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||||
@rem
|
@rem
|
||||||
@rem Unless required by applicable law or agreed to in writing, software
|
@rem Unless required by applicable law or agreed to in writing, software
|
||||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
|
Loading…
Reference in a new issue