You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by nt...@apache.org on 2018/02/02 13:07:39 UTC
[05/11] cayenne git commit: Code check and code-coverage and
code-quality options
Code check and code-coverage and code-quality options
Project: http://git-wip-us.apache.org/repos/asf/cayenne/repo
Commit: http://git-wip-us.apache.org/repos/asf/cayenne/commit/ea745fd6
Tree: http://git-wip-us.apache.org/repos/asf/cayenne/tree/ea745fd6
Diff: http://git-wip-us.apache.org/repos/asf/cayenne/diff/ea745fd6
Branch: refs/heads/master
Commit: ea745fd6d261454b6074c7b42a56fe4d62ab8c85
Parents: c47c03d
Author: Arseni Bulatski <an...@gmail.com>
Authored: Fri Jan 26 12:14:56 2018 +0300
Committer: Arseni Bulatski <an...@gmail.com>
Committed: Fri Jan 26 12:14:56 2018 +0300
----------------------------------------------------------------------
.../src/main/resources/cayenne-checkstyle.xml | 82 ------
.../src/main/resources/cayenne-pmd.xml | 295 -------------------
build-tools/pom.xml | 32 --
cayenne-checkstyle.xml | 82 ++++++
.../main/java/org/apache/cayenne/di/Key.java | 2 +-
.../di/spi/DefaultAdhocObjectFactory.java | 6 +-
.../apache/cayenne/di/spi/DefaultInjector.java | 4 +-
.../cayenne/lifecycle/id/EntityIdCoder.java | 2 +-
.../apache/cayenne/lifecycle/id/IdCoder.java | 2 +-
.../cayenne/lifecycle/id/StringIdQuery.java | 4 +-
.../configuration/osgi/OsgiModuleBuilder.java | 2 +-
cayenne-pmd.xml | 295 +++++++++++++++++++
...ompatibilityDataChannelDescriptorLoader.java | 2 +-
.../cayenne/project/FileProjectSaver.java | 2 +-
.../java/org/apache/cayenne/CayenneContext.java | 4 +-
pom.xml | 9 +-
16 files changed, 400 insertions(+), 425 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cayenne/blob/ea745fd6/build-tools/cayenne-checkers/src/main/resources/cayenne-checkstyle.xml
----------------------------------------------------------------------
diff --git a/build-tools/cayenne-checkers/src/main/resources/cayenne-checkstyle.xml b/build-tools/cayenne-checkers/src/main/resources/cayenne-checkstyle.xml
deleted file mode 100644
index 90587cb..0000000
--- a/build-tools/cayenne-checkers/src/main/resources/cayenne-checkstyle.xml
+++ /dev/null
@@ -1,82 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?><!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
- -->
-<!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.2//EN"
- "http://www.puppycrawl.com/dtds/configuration_1_2.dtd"><!-- Generated by Sonar -->
-<module name="Checker">
- <module name="SuppressionCommentFilter"/>
- <module name="TreeWalker">
- <module name="FileContentsHolder"/>
- <module name="CyclomaticComplexity">
- <property name="severity" value="error"/>
- <property name="max" value="15"/>
- </module>
- <module name="MethodLength">
- <property name="severity" value="warning"/>
- <property name="max" value="200"/>
- </module>
- <module name="IllegalCatch">
- <property name="severity" value="warning"/>
- </module>
-
- <module name="FallThrough">
- <property name="severity" value="warning"/>
- </module>
- <module name="EqualsHashCode">
- <property name="severity" value="warning"/>
- </module>
- <module name="MissingSwitchDefault">
- <property name="severity" value="warning"/>
- </module>
- <module name="ExecutableStatementCount">
- <property name="severity" value="error"/>
- </module>
- <module name="CovariantEquals">
- <property name="severity" value="warning"/>
- </module>
- <module name="ConstantName">
- <property name="severity" value="info"/>
- <property name="format" value="^([A-Z][A-Z0-9]*(_[A-Z0-9]+)*|logger|log)$"/>
- </module>
- <module name="IllegalThrows">
- <property name="severity" value="warning"/>
- </module>
- <module name="ArrayTypeStyle">
- <property name="severity" value="info"/>
- </module>
- <module name="EqualsAvoidNull">
- <property name="severity" value="warning"/>
- <property name="ignoreEqualsIgnoreCase" value="false"/>
- </module>
- <module name="AvoidNestedBlocks">
- <property name="severity" value="warning"/>
- </module>
- <module name="MissingDeprecated">
- <property name="severity" value="info"/>
- </module>
- <module name="DefaultComesLast">
- <property name="severity" value="warning"/>
- </module>
- <module name="BooleanExpressionComplexity">
- <property name="severity" value="warning"/>
- </module>
- <module name="EmptyBlock">
- <property name="severity" value="warning"/>
- </module>
- </module>
-</module>
http://git-wip-us.apache.org/repos/asf/cayenne/blob/ea745fd6/build-tools/cayenne-checkers/src/main/resources/cayenne-pmd.xml
----------------------------------------------------------------------
diff --git a/build-tools/cayenne-checkers/src/main/resources/cayenne-pmd.xml b/build-tools/cayenne-checkers/src/main/resources/cayenne-pmd.xml
deleted file mode 100644
index de950e7..0000000
--- a/build-tools/cayenne-checkers/src/main/resources/cayenne-pmd.xml
+++ /dev/null
@@ -1,295 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
- -->
-<ruleset>
-
- <rule ref="rulesets/java/optimizations.xml/AvoidArrayLoops">
- <priority>3</priority>
- </rule>
-
- <rule ref="rulesets/java/basic.xml/BooleanInstantiation">
- <priority>1</priority>
- </rule>
- <rule ref="rulesets/java/logging-java.xml/LoggerIsNotStaticFinal">
- <priority>3</priority>
- </rule>
- <rule ref="rulesets/java/design.xml/AbstractClassWithoutAbstractMethod">
- <priority>3</priority>
- </rule>
- <rule ref="rulesets/java/design.xml/AbstractClassWithoutAnyMethod">
- <priority>3</priority>
- </rule>
- <rule ref="rulesets/java/design.xml/AvoidProtectedFieldInFinalClass">
- <priority>3</priority>
- </rule>
- <rule ref="rulesets/java/strictexception.xml/AvoidThrowingRawExceptionTypes">
- <priority>3</priority>
- </rule>
- <rule ref="rulesets/java/codesize.xml/CyclomaticComplexity">
- <priority>2</priority>
- <properties>
- <property name="reportLevel" value="30" />
- </properties>
- </rule>
- <rule ref="rulesets/java/controversial.xml/DoNotCallGarbageCollectionExplicitly">
- <priority>3</priority>
- </rule>
- <rule ref="rulesets/java/empty.xml/EmptyCatchBlock">
- <priority>3</priority>
- </rule>
- <rule ref="rulesets/java/empty.xml/EmptyFinallyBlock">
- <priority>1</priority>
- </rule>
- <!--<rule ref="rulesets/java/empty.xml/EmptyIfStmt">-->
- <!--<priority>3</priority>-->
- <!--</rule>-->
- <rule ref="rulesets/java/codesize.xml/ExcessiveClassLength">
- <priority>3</priority>
- </rule>
- <rule ref="rulesets/java/codesize.xml/ExcessiveParameterList">
- <priority>3</priority>
- </rule>
- <rule ref="rulesets/java/migrating.xml/AvoidEnumAsIdentifier">
- <priority>3</priority>
- </rule>
- <rule ref="rulesets/java/strictexception.xml/AvoidCatchingNPE">
- <priority>3</priority>
- </rule>
- <!--<rule ref="rulesets/java/strictexception.xml/AvoidCatchingThrowable">-->
- <!--<priority>3</priority>-->
- <!--</rule>-->
- <rule ref="rulesets/java/basic.xml/AvoidDecimalLiteralsInBigDecimalConstructor">
- <priority>3</priority>
- </rule>
- <rule ref="rulesets/java/basic.xml/AvoidUsingHardCodedIP">
- <priority>3</priority>
- </rule>
- <rule ref="rulesets/java/basic.xml/BrokenNullCheck">
- <priority>1</priority>
- </rule>
- <rule ref="rulesets/java/basic.xml/ClassCastExceptionWithToArray">
- <priority>3</priority>
- </rule>
- <rule ref="rulesets/java/basic.xml/AvoidMultipleUnaryOperators">
- <priority>3</priority>
- </rule>
- <rule ref="rulesets/java/j2ee.xml/DoNotCallSystemExit">
- <priority>3</priority>
- </rule>
- <rule ref="rulesets/java/strictexception.xml/DoNotExtendJavaLangError">
- <priority>3</priority>
- </rule>
- <rule ref="rulesets/java/strictexception.xml/DoNotThrowExceptionInFinally">
- <priority>3</priority>
- </rule>
- <rule ref="rulesets/java/finalizers.xml/AvoidCallingFinalize">
- <priority>3</priority>
- </rule>
- <rule ref="rulesets/java/design.xml/AvoidDeeplyNestedIfStmts">
- <priority>3</priority>
- </rule>
- <rule ref="rulesets/java/strictexception.xml/AvoidThrowingNullPointerException">
- <priority>3</priority>
- </rule>
- <rule ref="rulesets/java/naming.xml/ClassNamingConventions">
- <priority>3</priority>
- </rule>
- <rule ref="rulesets/java/naming.xml/MethodNamingConventions">
- <priority>3</priority>
- </rule>
- <rule ref="rulesets/java/naming.xml/MethodWithSameNameAsEnclosingClass">
- <priority>3</priority>
- </rule>
- <rule ref="rulesets/java/naming.xml/ShortMethodName">
- <priority>3</priority>
- </rule>
- <rule ref="rulesets/java/braces.xml/WhileLoopsMustUseBraces">
- <priority>1</priority>
- </rule>
- <rule ref="rulesets/java/design.xml/AvoidInstanceofChecksInCatchClause">
- <priority>3</priority>
- </rule>
-
- <rule ref="rulesets/java/braces.xml/ForLoopsMustUseBraces">
- <priority>1</priority>
- </rule>
- <rule ref="rulesets/java/braces.xml/IfElseStmtsMustUseBraces">
- <priority>1</priority>
- </rule>
- <rule ref="rulesets/java/braces.xml/IfStmtsMustUseBraces">
- <priority>1</priority>
- </rule>
- <rule ref="rulesets/java/codesize.xml/TooManyMethods">
- <priority>3</priority>
- <properties>
- <property name="maxmethods" value="30" />
- </properties>
- </rule>
- <rule ref="rulesets/java/migrating.xml/ByteInstantiation">
- <priority>1</priority>
- </rule>
- <rule ref="rulesets/java/migrating.xml/LongInstantiation">
- <priority>1</priority>
- </rule>
- <rule ref="rulesets/java/migrating.xml/ShortInstantiation">
- <priority>1</priority>
- </rule>
- <rule ref="rulesets/java/empty.xml/EmptySynchronizedBlock">
- <priority>3</priority>
- </rule>
- <rule ref="rulesets/java/empty.xml/EmptyWhileStmt">
- <priority>3</priority>
- </rule>
- <!--<rule ref="rulesets/java/design.xml/EqualsNull">-->
- <!--<priority>3</priority>-->
- <!--</rule>-->
- <rule ref="rulesets/java/basic.xml/MisplacedNullCheck">
- <priority>1</priority>
- </rule>
- <!--<rule ref="rulesets/java/design.xml/MissingBreakInSwitch">-->
- <!--<priority>3</priority>-->
- <!--</rule>-->
- <rule ref="rulesets/java/basic.xml/UnconditionalIfStatement">
- <priority>1</priority>
- </rule>
- <rule ref="rulesets/java/j2ee.xml/UseProperClassLoader">
- <priority>1</priority>
- </rule>
- <rule ref="rulesets/java/unnecessary.xml/UselessOperationOnImmutable">
- <priority>1</priority>
- </rule>
- <rule ref="rulesets/java/logging-java.xml/MoreThanOneLogger">
- <priority>3</priority>
- </rule>
- <rule ref="rulesets/java/design.xml/AssignmentToNonFinalStatic">
- <priority>3</priority>
- </rule>
- <rule ref="rulesets/java/logging-java.xml/AvoidPrintStackTrace">
- <priority>1</priority>
- </rule>
- <rule ref="rulesets/java/strictexception.xml/AvoidRethrowingException">
- <priority>3</priority>
- </rule>
- <!--<rule ref="rulesets/java/design.xml/PreserveStackTrace">-->
- <!--<priority>1</priority>-->
- <!--</rule>-->
- <rule ref="rulesets/java/logging-java.xml/SystemPrintln">
- <priority>1</priority>
- </rule>
- <rule ref="rulesets/java/controversial.xml/AssignmentInOperand">
- <priority>3</priority>
- </rule>
- <rule ref="rulesets/java/optimizations.xml/AddEmptyString">
- <priority>1</priority>
- </rule>
- <rule ref="rulesets/java/basic.xml/OverrideBothEqualsAndHashcode">
- <priority>3</priority>
- </rule>
- <rule ref="rulesets/java/naming.xml/SuspiciousEqualsMethodName">
- <priority>3</priority>
- </rule>
- <rule ref="rulesets/java/sunsecure.xml/MethodReturnsInternalArray">
- <priority>3</priority>
- </rule>
- <rule ref="rulesets/java/clone.xml/ProperCloneImplementation">
- <priority>3</priority>
- </rule>
- <rule ref="rulesets/java/basic.xml/AvoidThreadGroup">
- <priority>3</priority>
- </rule>
- <rule ref="rulesets/java/strictexception.xml/AvoidCatchingGenericException">
- <priority>3</priority>
- </rule>
- <rule ref="rulesets/java/strictexception.xml/AvoidLosingExceptionInformation">
- <priority>3</priority>
- </rule>
- <rule ref="rulesets/java/design.xml/BadComparison">
- <priority>3</priority>
- </rule>
- <rule ref="rulesets/java/empty.xml/EmptyInitializer">
- <priority>3</priority>
- </rule>
- <!--<rule ref="rulesets/java/design.xml/CompareObjectsWithEquals">-->
- <!--<priority>3</priority>-->
- <!--</rule>-->
- <rule ref="rulesets/java/empty.xml/EmptyStatementNotInLoop">
- <priority>3</priority>
- </rule>
- <rule ref="rulesets/java/design.xml/EmptyMethodInAbstractClassShouldBeAbstract">
- <priority>3</priority>
- </rule>
- <rule ref="rulesets/java/empty.xml/EmptyTryBlock">
- <priority>3</priority>
- </rule>
- <rule ref="rulesets/java/strings.xml/StringToString">
- <priority>3</priority>
- </rule>
- <rule ref="rulesets/java/optimizations.xml/UseArrayListInsteadOfVector">
- <priority>3</priority>
- </rule>
- <rule ref="rulesets/java/clone.xml/CloneThrowsCloneNotSupportedException">
- <priority>3</priority>
- </rule>
- <rule ref="rulesets/java/design.xml/CloseResource">
- <priority>3</priority>
- </rule>
- <rule ref="rulesets/java/basic.xml/DoubleCheckedLocking">
- <priority>3</priority>
- </rule>
- <rule ref="rulesets/java/basic.xml/AvoidUsingOctalValues">
- <priority>3</priority>
- </rule>
- <rule ref="rulesets/java/design.xml/DefaultLabelNotLastInSwitchStmt">
- <priority>3</priority>
- </rule>
- <rule ref="rulesets/java/empty.xml/EmptySwitchStatements">
- <priority>3</priority>
- </rule>
- <rule ref="rulesets/java/empty.xml/EmptyStaticInitializer">
- <priority>3</priority>
- </rule>
- <rule ref="rulesets/java/finalizers.xml/EmptyFinalizer">
- <priority>3</priority>
- </rule>
- <rule ref="rulesets/java/strictexception.xml/ExceptionAsFlowControl">
- <priority>3</priority>
- </rule>
- <rule ref="rulesets/java/finalizers.xml/FinalizeOnlyCallsSuperFinalize">
- <priority>3</priority>
- </rule>
- <rule ref="rulesets/java/finalizers.xml/FinalizeDoesNotCallSuperFinalize">
- <priority>3</priority>
- </rule>
- <rule ref="rulesets/java/finalizers.xml/FinalizeOverloaded">
- <priority>3</priority>
- </rule>
- <rule ref="rulesets/java/finalizers.xml/FinalizeShouldBeProtected">
- <priority>3</priority>
- </rule>
- <rule ref="rulesets/java/strings.xml/InefficientEmptyStringCheck">
- <priority>3</priority>
- </rule>
- <rule ref="rulesets/java/basic.xml/ReturnFromFinallyBlock">
- <priority>3</priority>
- </rule>
- <rule ref="rulesets/java/strictexception.xml/AvoidThrowingNewInstanceOfSameException">
- <priority>3</priority>
- </rule>
-</ruleset>
-
http://git-wip-us.apache.org/repos/asf/cayenne/blob/ea745fd6/build-tools/pom.xml
----------------------------------------------------------------------
diff --git a/build-tools/pom.xml b/build-tools/pom.xml
index ddba56e..f0dfa0e 100644
--- a/build-tools/pom.xml
+++ b/build-tools/pom.xml
@@ -57,37 +57,5 @@
</plugin>
</plugins>
</build>
- <profiles>
- <profile>
- <id>code-quality</id>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-checkstyle-plugin</artifactId>
- <executions>
- <execution>
- <configuration>
- <skip>true</skip>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-pmd-plugin</artifactId>
- <executions>
- <execution>
- <configuration>
- <skip>true</skip>
- </configuration>
-
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
- </profiles>
</project>
http://git-wip-us.apache.org/repos/asf/cayenne/blob/ea745fd6/cayenne-checkstyle.xml
----------------------------------------------------------------------
diff --git a/cayenne-checkstyle.xml b/cayenne-checkstyle.xml
new file mode 100644
index 0000000..90587cb
--- /dev/null
+++ b/cayenne-checkstyle.xml
@@ -0,0 +1,82 @@
+<?xml version="1.0" encoding="UTF-8"?><!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ -->
+<!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.2//EN"
+ "http://www.puppycrawl.com/dtds/configuration_1_2.dtd"><!-- Generated by Sonar -->
+<module name="Checker">
+ <module name="SuppressionCommentFilter"/>
+ <module name="TreeWalker">
+ <module name="FileContentsHolder"/>
+ <module name="CyclomaticComplexity">
+ <property name="severity" value="error"/>
+ <property name="max" value="15"/>
+ </module>
+ <module name="MethodLength">
+ <property name="severity" value="warning"/>
+ <property name="max" value="200"/>
+ </module>
+ <module name="IllegalCatch">
+ <property name="severity" value="warning"/>
+ </module>
+
+ <module name="FallThrough">
+ <property name="severity" value="warning"/>
+ </module>
+ <module name="EqualsHashCode">
+ <property name="severity" value="warning"/>
+ </module>
+ <module name="MissingSwitchDefault">
+ <property name="severity" value="warning"/>
+ </module>
+ <module name="ExecutableStatementCount">
+ <property name="severity" value="error"/>
+ </module>
+ <module name="CovariantEquals">
+ <property name="severity" value="warning"/>
+ </module>
+ <module name="ConstantName">
+ <property name="severity" value="info"/>
+ <property name="format" value="^([A-Z][A-Z0-9]*(_[A-Z0-9]+)*|logger|log)$"/>
+ </module>
+ <module name="IllegalThrows">
+ <property name="severity" value="warning"/>
+ </module>
+ <module name="ArrayTypeStyle">
+ <property name="severity" value="info"/>
+ </module>
+ <module name="EqualsAvoidNull">
+ <property name="severity" value="warning"/>
+ <property name="ignoreEqualsIgnoreCase" value="false"/>
+ </module>
+ <module name="AvoidNestedBlocks">
+ <property name="severity" value="warning"/>
+ </module>
+ <module name="MissingDeprecated">
+ <property name="severity" value="info"/>
+ </module>
+ <module name="DefaultComesLast">
+ <property name="severity" value="warning"/>
+ </module>
+ <module name="BooleanExpressionComplexity">
+ <property name="severity" value="warning"/>
+ </module>
+ <module name="EmptyBlock">
+ <property name="severity" value="warning"/>
+ </module>
+ </module>
+</module>
http://git-wip-us.apache.org/repos/asf/cayenne/blob/ea745fd6/cayenne-di/src/main/java/org/apache/cayenne/di/Key.java
----------------------------------------------------------------------
diff --git a/cayenne-di/src/main/java/org/apache/cayenne/di/Key.java b/cayenne-di/src/main/java/org/apache/cayenne/di/Key.java
index 47c9f1d..d3c35df 100644
--- a/cayenne-di/src/main/java/org/apache/cayenne/di/Key.java
+++ b/cayenne-di/src/main/java/org/apache/cayenne/di/Key.java
@@ -81,7 +81,7 @@ public class Key<T> {
protected Key(TypeLiteral<T> type, String bindingName) {
if (type == null) {
- throw new IllegalArgumentException("Null key type");
+ throw new NullPointerException("Null key type");
}
this.typeLiteral = type;
http://git-wip-us.apache.org/repos/asf/cayenne/blob/ea745fd6/cayenne-di/src/main/java/org/apache/cayenne/di/spi/DefaultAdhocObjectFactory.java
----------------------------------------------------------------------
diff --git a/cayenne-di/src/main/java/org/apache/cayenne/di/spi/DefaultAdhocObjectFactory.java b/cayenne-di/src/main/java/org/apache/cayenne/di/spi/DefaultAdhocObjectFactory.java
index 241b6b6..ab2728d 100644
--- a/cayenne-di/src/main/java/org/apache/cayenne/di/spi/DefaultAdhocObjectFactory.java
+++ b/cayenne-di/src/main/java/org/apache/cayenne/di/spi/DefaultAdhocObjectFactory.java
@@ -50,11 +50,11 @@ public class DefaultAdhocObjectFactory implements AdhocObjectFactory {
public <T> T newInstance(Class<? super T> superType, String className) {
if (superType == null) {
- throw new IllegalArgumentException("Null superType");
+ throw new NullPointerException("Null superType");
}
if (className == null) {
- throw new IllegalArgumentException("Null className");
+ throw new NullPointerException("Null className");
}
Class<T> type = (Class<T>) getJavaClass(className);
@@ -82,7 +82,7 @@ public class DefaultAdhocObjectFactory implements AdhocObjectFactory {
// is there a better way to get array class from string name?
if (className == null) {
- throw new IllegalArgumentException("Null class name");
+ throw new NullPointerException("Null class name");
}
ClassLoader classLoader = classLoaderManager.getClassLoader(className.replace('.', '/'));
http://git-wip-us.apache.org/repos/asf/cayenne/blob/ea745fd6/cayenne-di/src/main/java/org/apache/cayenne/di/spi/DefaultInjector.java
----------------------------------------------------------------------
diff --git a/cayenne-di/src/main/java/org/apache/cayenne/di/spi/DefaultInjector.java b/cayenne-di/src/main/java/org/apache/cayenne/di/spi/DefaultInjector.java
index e9dfdb4..a998cf4 100644
--- a/cayenne-di/src/main/java/org/apache/cayenne/di/spi/DefaultInjector.java
+++ b/cayenne-di/src/main/java/org/apache/cayenne/di/spi/DefaultInjector.java
@@ -80,7 +80,7 @@ public class DefaultInjector implements Injector {
<T> Binding<T> getBinding(Key<T> key) throws DIRuntimeException {
if (key == null) {
- throw new IllegalArgumentException("Null key");
+ throw new NullPointerException("Null key");
}
// may return null - this is intentionally allowed in this non-public method
@@ -148,7 +148,7 @@ public class DefaultInjector implements Injector {
public <T> Provider<T> getProvider(Key<T> key) throws DIRuntimeException {
if (key == null) {
- throw new IllegalArgumentException("Null key");
+ throw new NullPointerException("Null key");
}
@SuppressWarnings("unchecked")
http://git-wip-us.apache.org/repos/asf/cayenne/blob/ea745fd6/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/id/EntityIdCoder.java
----------------------------------------------------------------------
diff --git a/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/id/EntityIdCoder.java b/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/id/EntityIdCoder.java
index d0a6227..092aa27 100644
--- a/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/id/EntityIdCoder.java
+++ b/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/id/EntityIdCoder.java
@@ -216,7 +216,7 @@ public class EntityIdCoder {
private Converter create(Class<?> type) {
if (type == null) {
- throw new IllegalArgumentException("Null type");
+ throw new NullPointerException("Null type");
}
if (Long.class.isAssignableFrom(type)) {
http://git-wip-us.apache.org/repos/asf/cayenne/blob/ea745fd6/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/id/IdCoder.java
----------------------------------------------------------------------
diff --git a/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/id/IdCoder.java b/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/id/IdCoder.java
index bad72f6..696a2b4 100644
--- a/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/id/IdCoder.java
+++ b/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/id/IdCoder.java
@@ -63,7 +63,7 @@ public class IdCoder {
public String getStringId(Persistent object) {
if (object == null) {
- throw new IllegalArgumentException("Null object");
+ throw new NullPointerException("Null object");
}
ObjectId id = object.getObjectId();
http://git-wip-us.apache.org/repos/asf/cayenne/blob/ea745fd6/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/id/StringIdQuery.java
----------------------------------------------------------------------
diff --git a/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/id/StringIdQuery.java b/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/id/StringIdQuery.java
index d319f09..89646d2 100644
--- a/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/id/StringIdQuery.java
+++ b/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/id/StringIdQuery.java
@@ -62,7 +62,7 @@ public class StringIdQuery implements Query {
private static Collection<String> toCollection(String... stringIds) {
if (stringIds == null) {
- throw new IllegalArgumentException("Null stringIds");
+ throw new NullPointerException("Null stringIds");
}
return Arrays.asList(stringIds);
@@ -88,7 +88,7 @@ public class StringIdQuery implements Query {
public void addStringIds(String... ids) {
if (ids == null) {
- throw new IllegalArgumentException("Null ids");
+ throw new NullPointerException("Null ids");
}
boolean changed = false;
http://git-wip-us.apache.org/repos/asf/cayenne/blob/ea745fd6/cayenne-osgi/src/main/java/org/apache/cayenne/configuration/osgi/OsgiModuleBuilder.java
----------------------------------------------------------------------
diff --git a/cayenne-osgi/src/main/java/org/apache/cayenne/configuration/osgi/OsgiModuleBuilder.java b/cayenne-osgi/src/main/java/org/apache/cayenne/configuration/osgi/OsgiModuleBuilder.java
index 6214452..481f220 100644
--- a/cayenne-osgi/src/main/java/org/apache/cayenne/configuration/osgi/OsgiModuleBuilder.java
+++ b/cayenne-osgi/src/main/java/org/apache/cayenne/configuration/osgi/OsgiModuleBuilder.java
@@ -34,7 +34,7 @@ public class OsgiModuleBuilder {
public static OsgiModuleBuilder forProject(Class<?> typeFromProjectBundle) {
if (typeFromProjectBundle == null) {
- throw new IllegalArgumentException("Null 'typeFromProjectBundle'");
+ throw new NullPointerException("Null 'typeFromProjectBundle'");
}
return new OsgiModuleBuilder(typeFromProjectBundle);
http://git-wip-us.apache.org/repos/asf/cayenne/blob/ea745fd6/cayenne-pmd.xml
----------------------------------------------------------------------
diff --git a/cayenne-pmd.xml b/cayenne-pmd.xml
new file mode 100644
index 0000000..de950e7
--- /dev/null
+++ b/cayenne-pmd.xml
@@ -0,0 +1,295 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ -->
+<ruleset>
+
+ <rule ref="rulesets/java/optimizations.xml/AvoidArrayLoops">
+ <priority>3</priority>
+ </rule>
+
+ <rule ref="rulesets/java/basic.xml/BooleanInstantiation">
+ <priority>1</priority>
+ </rule>
+ <rule ref="rulesets/java/logging-java.xml/LoggerIsNotStaticFinal">
+ <priority>3</priority>
+ </rule>
+ <rule ref="rulesets/java/design.xml/AbstractClassWithoutAbstractMethod">
+ <priority>3</priority>
+ </rule>
+ <rule ref="rulesets/java/design.xml/AbstractClassWithoutAnyMethod">
+ <priority>3</priority>
+ </rule>
+ <rule ref="rulesets/java/design.xml/AvoidProtectedFieldInFinalClass">
+ <priority>3</priority>
+ </rule>
+ <rule ref="rulesets/java/strictexception.xml/AvoidThrowingRawExceptionTypes">
+ <priority>3</priority>
+ </rule>
+ <rule ref="rulesets/java/codesize.xml/CyclomaticComplexity">
+ <priority>2</priority>
+ <properties>
+ <property name="reportLevel" value="30" />
+ </properties>
+ </rule>
+ <rule ref="rulesets/java/controversial.xml/DoNotCallGarbageCollectionExplicitly">
+ <priority>3</priority>
+ </rule>
+ <rule ref="rulesets/java/empty.xml/EmptyCatchBlock">
+ <priority>3</priority>
+ </rule>
+ <rule ref="rulesets/java/empty.xml/EmptyFinallyBlock">
+ <priority>1</priority>
+ </rule>
+ <!--<rule ref="rulesets/java/empty.xml/EmptyIfStmt">-->
+ <!--<priority>3</priority>-->
+ <!--</rule>-->
+ <rule ref="rulesets/java/codesize.xml/ExcessiveClassLength">
+ <priority>3</priority>
+ </rule>
+ <rule ref="rulesets/java/codesize.xml/ExcessiveParameterList">
+ <priority>3</priority>
+ </rule>
+ <rule ref="rulesets/java/migrating.xml/AvoidEnumAsIdentifier">
+ <priority>3</priority>
+ </rule>
+ <rule ref="rulesets/java/strictexception.xml/AvoidCatchingNPE">
+ <priority>3</priority>
+ </rule>
+ <!--<rule ref="rulesets/java/strictexception.xml/AvoidCatchingThrowable">-->
+ <!--<priority>3</priority>-->
+ <!--</rule>-->
+ <rule ref="rulesets/java/basic.xml/AvoidDecimalLiteralsInBigDecimalConstructor">
+ <priority>3</priority>
+ </rule>
+ <rule ref="rulesets/java/basic.xml/AvoidUsingHardCodedIP">
+ <priority>3</priority>
+ </rule>
+ <rule ref="rulesets/java/basic.xml/BrokenNullCheck">
+ <priority>1</priority>
+ </rule>
+ <rule ref="rulesets/java/basic.xml/ClassCastExceptionWithToArray">
+ <priority>3</priority>
+ </rule>
+ <rule ref="rulesets/java/basic.xml/AvoidMultipleUnaryOperators">
+ <priority>3</priority>
+ </rule>
+ <rule ref="rulesets/java/j2ee.xml/DoNotCallSystemExit">
+ <priority>3</priority>
+ </rule>
+ <rule ref="rulesets/java/strictexception.xml/DoNotExtendJavaLangError">
+ <priority>3</priority>
+ </rule>
+ <rule ref="rulesets/java/strictexception.xml/DoNotThrowExceptionInFinally">
+ <priority>3</priority>
+ </rule>
+ <rule ref="rulesets/java/finalizers.xml/AvoidCallingFinalize">
+ <priority>3</priority>
+ </rule>
+ <rule ref="rulesets/java/design.xml/AvoidDeeplyNestedIfStmts">
+ <priority>3</priority>
+ </rule>
+ <rule ref="rulesets/java/strictexception.xml/AvoidThrowingNullPointerException">
+ <priority>3</priority>
+ </rule>
+ <rule ref="rulesets/java/naming.xml/ClassNamingConventions">
+ <priority>3</priority>
+ </rule>
+ <rule ref="rulesets/java/naming.xml/MethodNamingConventions">
+ <priority>3</priority>
+ </rule>
+ <rule ref="rulesets/java/naming.xml/MethodWithSameNameAsEnclosingClass">
+ <priority>3</priority>
+ </rule>
+ <rule ref="rulesets/java/naming.xml/ShortMethodName">
+ <priority>3</priority>
+ </rule>
+ <rule ref="rulesets/java/braces.xml/WhileLoopsMustUseBraces">
+ <priority>1</priority>
+ </rule>
+ <rule ref="rulesets/java/design.xml/AvoidInstanceofChecksInCatchClause">
+ <priority>3</priority>
+ </rule>
+
+ <rule ref="rulesets/java/braces.xml/ForLoopsMustUseBraces">
+ <priority>1</priority>
+ </rule>
+ <rule ref="rulesets/java/braces.xml/IfElseStmtsMustUseBraces">
+ <priority>1</priority>
+ </rule>
+ <rule ref="rulesets/java/braces.xml/IfStmtsMustUseBraces">
+ <priority>1</priority>
+ </rule>
+ <rule ref="rulesets/java/codesize.xml/TooManyMethods">
+ <priority>3</priority>
+ <properties>
+ <property name="maxmethods" value="30" />
+ </properties>
+ </rule>
+ <rule ref="rulesets/java/migrating.xml/ByteInstantiation">
+ <priority>1</priority>
+ </rule>
+ <rule ref="rulesets/java/migrating.xml/LongInstantiation">
+ <priority>1</priority>
+ </rule>
+ <rule ref="rulesets/java/migrating.xml/ShortInstantiation">
+ <priority>1</priority>
+ </rule>
+ <rule ref="rulesets/java/empty.xml/EmptySynchronizedBlock">
+ <priority>3</priority>
+ </rule>
+ <rule ref="rulesets/java/empty.xml/EmptyWhileStmt">
+ <priority>3</priority>
+ </rule>
+ <!--<rule ref="rulesets/java/design.xml/EqualsNull">-->
+ <!--<priority>3</priority>-->
+ <!--</rule>-->
+ <rule ref="rulesets/java/basic.xml/MisplacedNullCheck">
+ <priority>1</priority>
+ </rule>
+ <!--<rule ref="rulesets/java/design.xml/MissingBreakInSwitch">-->
+ <!--<priority>3</priority>-->
+ <!--</rule>-->
+ <rule ref="rulesets/java/basic.xml/UnconditionalIfStatement">
+ <priority>1</priority>
+ </rule>
+ <rule ref="rulesets/java/j2ee.xml/UseProperClassLoader">
+ <priority>1</priority>
+ </rule>
+ <rule ref="rulesets/java/unnecessary.xml/UselessOperationOnImmutable">
+ <priority>1</priority>
+ </rule>
+ <rule ref="rulesets/java/logging-java.xml/MoreThanOneLogger">
+ <priority>3</priority>
+ </rule>
+ <rule ref="rulesets/java/design.xml/AssignmentToNonFinalStatic">
+ <priority>3</priority>
+ </rule>
+ <rule ref="rulesets/java/logging-java.xml/AvoidPrintStackTrace">
+ <priority>1</priority>
+ </rule>
+ <rule ref="rulesets/java/strictexception.xml/AvoidRethrowingException">
+ <priority>3</priority>
+ </rule>
+ <!--<rule ref="rulesets/java/design.xml/PreserveStackTrace">-->
+ <!--<priority>1</priority>-->
+ <!--</rule>-->
+ <rule ref="rulesets/java/logging-java.xml/SystemPrintln">
+ <priority>1</priority>
+ </rule>
+ <rule ref="rulesets/java/controversial.xml/AssignmentInOperand">
+ <priority>3</priority>
+ </rule>
+ <rule ref="rulesets/java/optimizations.xml/AddEmptyString">
+ <priority>1</priority>
+ </rule>
+ <rule ref="rulesets/java/basic.xml/OverrideBothEqualsAndHashcode">
+ <priority>3</priority>
+ </rule>
+ <rule ref="rulesets/java/naming.xml/SuspiciousEqualsMethodName">
+ <priority>3</priority>
+ </rule>
+ <rule ref="rulesets/java/sunsecure.xml/MethodReturnsInternalArray">
+ <priority>3</priority>
+ </rule>
+ <rule ref="rulesets/java/clone.xml/ProperCloneImplementation">
+ <priority>3</priority>
+ </rule>
+ <rule ref="rulesets/java/basic.xml/AvoidThreadGroup">
+ <priority>3</priority>
+ </rule>
+ <rule ref="rulesets/java/strictexception.xml/AvoidCatchingGenericException">
+ <priority>3</priority>
+ </rule>
+ <rule ref="rulesets/java/strictexception.xml/AvoidLosingExceptionInformation">
+ <priority>3</priority>
+ </rule>
+ <rule ref="rulesets/java/design.xml/BadComparison">
+ <priority>3</priority>
+ </rule>
+ <rule ref="rulesets/java/empty.xml/EmptyInitializer">
+ <priority>3</priority>
+ </rule>
+ <!--<rule ref="rulesets/java/design.xml/CompareObjectsWithEquals">-->
+ <!--<priority>3</priority>-->
+ <!--</rule>-->
+ <rule ref="rulesets/java/empty.xml/EmptyStatementNotInLoop">
+ <priority>3</priority>
+ </rule>
+ <rule ref="rulesets/java/design.xml/EmptyMethodInAbstractClassShouldBeAbstract">
+ <priority>3</priority>
+ </rule>
+ <rule ref="rulesets/java/empty.xml/EmptyTryBlock">
+ <priority>3</priority>
+ </rule>
+ <rule ref="rulesets/java/strings.xml/StringToString">
+ <priority>3</priority>
+ </rule>
+ <rule ref="rulesets/java/optimizations.xml/UseArrayListInsteadOfVector">
+ <priority>3</priority>
+ </rule>
+ <rule ref="rulesets/java/clone.xml/CloneThrowsCloneNotSupportedException">
+ <priority>3</priority>
+ </rule>
+ <rule ref="rulesets/java/design.xml/CloseResource">
+ <priority>3</priority>
+ </rule>
+ <rule ref="rulesets/java/basic.xml/DoubleCheckedLocking">
+ <priority>3</priority>
+ </rule>
+ <rule ref="rulesets/java/basic.xml/AvoidUsingOctalValues">
+ <priority>3</priority>
+ </rule>
+ <rule ref="rulesets/java/design.xml/DefaultLabelNotLastInSwitchStmt">
+ <priority>3</priority>
+ </rule>
+ <rule ref="rulesets/java/empty.xml/EmptySwitchStatements">
+ <priority>3</priority>
+ </rule>
+ <rule ref="rulesets/java/empty.xml/EmptyStaticInitializer">
+ <priority>3</priority>
+ </rule>
+ <rule ref="rulesets/java/finalizers.xml/EmptyFinalizer">
+ <priority>3</priority>
+ </rule>
+ <rule ref="rulesets/java/strictexception.xml/ExceptionAsFlowControl">
+ <priority>3</priority>
+ </rule>
+ <rule ref="rulesets/java/finalizers.xml/FinalizeOnlyCallsSuperFinalize">
+ <priority>3</priority>
+ </rule>
+ <rule ref="rulesets/java/finalizers.xml/FinalizeDoesNotCallSuperFinalize">
+ <priority>3</priority>
+ </rule>
+ <rule ref="rulesets/java/finalizers.xml/FinalizeOverloaded">
+ <priority>3</priority>
+ </rule>
+ <rule ref="rulesets/java/finalizers.xml/FinalizeShouldBeProtected">
+ <priority>3</priority>
+ </rule>
+ <rule ref="rulesets/java/strings.xml/InefficientEmptyStringCheck">
+ <priority>3</priority>
+ </rule>
+ <rule ref="rulesets/java/basic.xml/ReturnFromFinallyBlock">
+ <priority>3</priority>
+ </rule>
+ <rule ref="rulesets/java/strictexception.xml/AvoidThrowingNewInstanceOfSameException">
+ <priority>3</priority>
+ </rule>
+</ruleset>
+
http://git-wip-us.apache.org/repos/asf/cayenne/blob/ea745fd6/cayenne-project-compatibility/src/main/java/org/apache/cayenne/configuration/xml/CompatibilityDataChannelDescriptorLoader.java
----------------------------------------------------------------------
diff --git a/cayenne-project-compatibility/src/main/java/org/apache/cayenne/configuration/xml/CompatibilityDataChannelDescriptorLoader.java b/cayenne-project-compatibility/src/main/java/org/apache/cayenne/configuration/xml/CompatibilityDataChannelDescriptorLoader.java
index bbe7f1b..85dd6d5 100644
--- a/cayenne-project-compatibility/src/main/java/org/apache/cayenne/configuration/xml/CompatibilityDataChannelDescriptorLoader.java
+++ b/cayenne-project-compatibility/src/main/java/org/apache/cayenne/configuration/xml/CompatibilityDataChannelDescriptorLoader.java
@@ -63,7 +63,7 @@ public class CompatibilityDataChannelDescriptorLoader extends XMLDataChannelDesc
@Override
public ConfigurationTree<DataChannelDescriptor> load(Resource configurationResource) throws ConfigurationException {
if (configurationResource == null) {
- throw new IllegalArgumentException("Null configurationResource");
+ throw new NullPointerException("Null configurationResource");
}
if(!(upgradeServiceProvider.get() instanceof CompatibilityUpgradeService)) {
http://git-wip-us.apache.org/repos/asf/cayenne/blob/ea745fd6/cayenne-project/src/main/java/org/apache/cayenne/project/FileProjectSaver.java
----------------------------------------------------------------------
diff --git a/cayenne-project/src/main/java/org/apache/cayenne/project/FileProjectSaver.java b/cayenne-project/src/main/java/org/apache/cayenne/project/FileProjectSaver.java
index e45ca89..0d6af44 100644
--- a/cayenne-project/src/main/java/org/apache/cayenne/project/FileProjectSaver.java
+++ b/cayenne-project/src/main/java/org/apache/cayenne/project/FileProjectSaver.java
@@ -88,7 +88,7 @@ public class FileProjectSaver implements ProjectSaver {
@Override
public void saveAs(Project project, Resource baseDirectory) {
if (baseDirectory == null) {
- throw new IllegalArgumentException("Null 'baseDirectory'");
+ throw new NullPointerException("Null 'baseDirectory'");
}
save(project, baseDirectory, false);
}
http://git-wip-us.apache.org/repos/asf/cayenne/blob/ea745fd6/cayenne-rop-server/src/main/java/org/apache/cayenne/CayenneContext.java
----------------------------------------------------------------------
diff --git a/cayenne-rop-server/src/main/java/org/apache/cayenne/CayenneContext.java b/cayenne-rop-server/src/main/java/org/apache/cayenne/CayenneContext.java
index c8b3620..3f111db 100644
--- a/cayenne-rop-server/src/main/java/org/apache/cayenne/CayenneContext.java
+++ b/cayenne-rop-server/src/main/java/org/apache/cayenne/CayenneContext.java
@@ -240,7 +240,7 @@ public class CayenneContext extends BaseContext {
@Override
public <T> T newObject(Class<T> persistentClass) {
if (persistentClass == null) {
- throw new IllegalArgumentException("Persistent class can't be null.");
+ throw new NullPointerException("Persistent class can't be null.");
}
ObjEntity entity = getEntityResolver().getObjEntity(persistentClass);
@@ -262,7 +262,7 @@ public class CayenneContext extends BaseContext {
@Override
public void registerNewObject(Object object) {
if (object == null) {
- throw new IllegalArgumentException("An attempt to register null object.");
+ throw new NullPointerException("An attempt to register null object.");
}
ObjEntity entity = getEntityResolver().getObjEntity(object.getClass());
http://git-wip-us.apache.org/repos/asf/cayenne/blob/ea745fd6/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index d53e068..453dda8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -77,7 +77,8 @@
<module>tutorials</module>
<module>docs</module>
<module>assembly</module>
- </modules>
+ <module>cayenne-module-parent</module>
+ </modules>
<issueManagement>
<system>jira</system>
<url>https://issues.apache.org/jira/browse/CAY</url>
@@ -741,6 +742,10 @@
<version>3.8</version>
</plugin>
<plugin>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <version>3.0.0</version>
+ </plugin>
+ <plugin>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.4.1</version>
</plugin>
@@ -959,6 +964,7 @@
<id>code-quality</id>
<build>
+ <pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@@ -1037,6 +1043,7 @@
<version>2.0</version>
</plugin>
</plugins>
+ </pluginManagement>
</build>
<reporting>