Skip to content

Commit 7bc7ce1

Browse files
committed
more cleanup
1 parent 5e5a143 commit 7bc7ce1

13 files changed

Lines changed: 37 additions & 54 deletions

File tree

.checkstyle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22

3-
<fileset-config file-format-version="1.2.0" simple-config="true" sync-formatter="false">
4-
<fileset name="all" enabled="true" check-config-name="Google Checks" local="false">
5-
<file-match-pattern match-pattern="." include-pattern="true"/>
3+
<fileset-config file-format-version="1.2.0" simple-config="false" sync-formatter="false">
4+
<fileset name="Java source files" enabled="true" check-config-name="Google Checks" local="false">
5+
<file-match-pattern match-pattern=".*\.java" include-pattern="true"/>
66
</fileset>
77
</fileset-config>

pmd.xml

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
44
name="pmd"
55
xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 http://pmd.sourceforge.net/ruleset_2_0_0.xsd">
6-
<description>PMD Plugin preferences rule set</description>
6+
<description>PMD Plugin preferences rule set</description>
7+
<exclude-pattern>.*/test/.*</exclude-pattern>
78
<rule ref="rulesets/java/design.xml/AbstractClassWithoutAbstractMethod"/>
89
<rule ref="rulesets/java/design.xml/AbstractClassWithoutAnyMethod"/>
910
<rule ref="rulesets/java/optimizations.xml/AddEmptyString"/>
@@ -27,7 +28,6 @@
2728
<rule ref="rulesets/java/migrating.xml/AvoidEnumAsIdentifier"/>
2829
<rule ref="rulesets/java/controversial.xml/AvoidFinalLocalVariable"/>
2930
<rule ref="rulesets/java/design.xml/AvoidInstanceofChecksInCatchClause"/>
30-
<rule ref="rulesets/java/optimizations.xml/AvoidInstantiatingObjectsInLoops"/>
3131
<rule ref="rulesets/java/strictexception.xml/AvoidLosingExceptionInformation"/>
3232
<rule ref="rulesets/java/basic.xml/AvoidMultipleUnaryOperators"/>
3333
<rule ref="rulesets/java/controversial.xml/AvoidPrefixingMethodParameters"/>
@@ -69,23 +69,11 @@
6969
<rule ref="rulesets/java/basic.xml/CollapsibleIfStatements"/>
7070
<rule ref="rulesets/vm/basic.xml/CollapsibleIfStatements"/>
7171
<rule ref="rulesets/java/comments.xml/CommentContent"/>
72-
<rule ref="rulesets/java/comments.xml/CommentSize">
73-
<properties>
74-
<property name="maxLineLength" value="100"/>
75-
</properties>
76-
</rule>
7772
<rule ref="rulesets/java/design.xml/CompareObjectsWithEquals"/>
7873
<rule ref="rulesets/java/strings.xml/ConsecutiveAppendsShouldReuse"/>
7974
<rule ref="rulesets/java/strings.xml/ConsecutiveLiteralAppends"/>
8075
<rule ref="rulesets/ecmascript/basic.xml/ConsistentReturn"/>
8176
<rule ref="rulesets/java/design.xml/ConstructorCallsOverridableMethod"/>
82-
<rule ref="rulesets/java/coupling.xml/CouplingBetweenObjects"/>
83-
<rule ref="rulesets/plsql/codesize.xml/CyclomaticComplexity">
84-
<properties>
85-
<property name="reportLevel" value="14"/>
86-
</properties>
87-
</rule>
88-
<rule ref="rulesets/java/codesize.xml/CyclomaticComplexity"/>
8977
<rule ref="rulesets/java/design.xml/DefaultLabelNotLastInSwitchStmt"/>
9078
<rule ref="rulesets/java/controversial.xml/DoNotCallGarbageCollectionExplicitly"/>
9179
<rule ref="rulesets/java/j2ee.xml/DoNotCallSystemExit"/>
@@ -103,6 +91,11 @@
10391
<rule ref="rulesets/jsp/basic.xml/DuplicateJspImports"/>
10492
<rule ref="rulesets/java/finalizers.xml/EmptyFinalizer"/>
10593
<rule ref="rulesets/java/empty.xml/EmptyFinallyBlock"/>
94+
<rule ref="rulesets/java/empty.xml/EmptyCatchBlock">
95+
<properties>
96+
<property name="allowCommentedBlocks" value="true"/>
97+
</properties>
98+
</rule>
10699
<rule ref="rulesets/vm/basic.xml/EmptyForeachStmt"/>
107100
<rule ref="rulesets/java/empty.xml/EmptyIfStmt"/>
108101
<rule ref="rulesets/vm/basic.xml/EmptyIfStmt"/>
@@ -127,7 +120,6 @@
127120
<rule ref="rulesets/plsql/codesize.xml/ExcessivePackageSpecificationLength"/>
128121
<rule ref="rulesets/plsql/codesize.xml/ExcessiveParameterList"/>
129122
<rule ref="rulesets/java/codesize.xml/ExcessiveParameterList"/>
130-
<rule ref="rulesets/java/codesize.xml/ExcessivePublicCount"/>
131123
<rule ref="rulesets/vm/basic.xml/ExcessiveTemplateLength"/>
132124
<rule ref="rulesets/plsql/codesize.xml/ExcessiveTypeLength"/>
133125
<rule ref="rulesets/java/basic.xml/ExtendsObject"/>
@@ -165,7 +157,6 @@
165157
<rule ref="rulesets/java/junit.xml/JUnitSpelling"/>
166158
<rule ref="rulesets/java/junit.xml/JUnitStaticSuite"/>
167159
<rule ref="rulesets/java/junit.xml/JUnitTestsShouldIncludeAssert"/>
168-
<rule ref="rulesets/java/migrating.xml/JUnitUseExpected"/>
169160
<rule ref="rulesets/jsp/basic.xml/JspEncoding"/>
170161
<rule ref="rulesets/java/basic.xml/JumbledIncrementer"/>
171162
<rule ref="rulesets/java/j2ee.xml/LocalHomeNamingConvention"/>
@@ -185,10 +176,7 @@
185176
<rule ref="rulesets/java/javabeans.xml/MissingSerialVersionUID"/>
186177
<rule ref="rulesets/java/design.xml/MissingStaticMethodInNonInstantiatableClass"/>
187178
<rule ref="rulesets/xml/basic.xml/MistypedCDATASection"/>
188-
<rule ref="rulesets/java/codesize.xml/ModifiedCyclomaticComplexity"/>
189179
<rule ref="rulesets/java/logging-java.xml/MoreThanOneLogger"/>
190-
<rule ref="rulesets/plsql/codesize.xml/NPathComplexity"/>
191-
<rule ref="rulesets/java/codesize.xml/NPathComplexity"/>
192180
<rule ref="rulesets/java/codesize.xml/NcssConstructorCount"/>
193181
<rule ref="rulesets/plsql/codesize.xml/NcssMethodCount"/>
194182
<rule ref="rulesets/java/codesize.xml/NcssMethodCount"/>
@@ -233,7 +221,6 @@
233221
</properties>
234222
</rule>
235223
<rule ref="rulesets/java/migrating.xml/ShortInstantiation"/>
236-
<rule ref="rulesets/java/naming.xml/ShortMethodName"/>
237224
<rule ref="rulesets/java/strictexception.xml/SignatureDeclareThrowsException"/>
238225
<rule ref="rulesets/java/design.xml/SimpleDateFormatNeedsLocale"/>
239226
<rule ref="rulesets/java/junit.xml/SimplifyBooleanAssertion"/>
@@ -243,7 +230,6 @@
243230
<rule ref="rulesets/java/optimizations.xml/SimplifyStartsWith"/>
244231
<rule ref="rulesets/java/design.xml/SingularField"/>
245232
<rule ref="rulesets/java/j2ee.xml/StaticEJBFieldShouldBeFinal"/>
246-
<rule ref="rulesets/java/codesize.xml/StdCyclomaticComplexity"/>
247233
<rule ref="rulesets/java/strings.xml/StringBufferInstantiationWithChar"/>
248234
<rule ref="rulesets/java/strings.xml/StringInstantiation"/>
249235
<rule ref="rulesets/java/strings.xml/StringToString"/>
@@ -306,9 +292,7 @@
306292
<rule ref="rulesets/java/optimizations.xml/UseStringBufferForStringAppends"/>
307293
<rule ref="rulesets/java/strings.xml/UseStringBufferLength"/>
308294
<rule ref="rulesets/java/design.xml/UseUtilityClass"/>
309-
<rule ref="rulesets/java/design.xml/UseVarargs"/>
310295
<rule ref="rulesets/java/basic.xml/UselessOperationOnImmutable"/>
311-
<rule ref="rulesets/java/basic.xml/UselessOverridingMethod"/>
312296
<rule ref="rulesets/java/basic.xml/UselessParentheses"/>
313297
<rule ref="rulesets/java/strings.xml/UselessStringValueOf"/>
314298
<rule ref="rulesets/java/braces.xml/WhileLoopsMustUseBraces"/>

src/main/java/com/google/gcloud/ExceptionHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ private static Method getCallableMethod(Class<?> clazz) {
215215
return getCallableMethod(clazz.getSuperclass());
216216
} catch (SecurityException e) {
217217
// This should never happen
218-
throw new RuntimeException("Unexpected exception", e);
218+
throw new IllegalStateException("Unexpected exception", e);
219219
}
220220
}
221221

src/main/java/com/google/gcloud/datastore/BatchWriter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,15 @@ public interface BatchWriter extends DatastoreWriter {
4545
* @throws DatastoreServiceException if batch is no longer active
4646
*/
4747
@Override
48-
public void delete(Key... key);
48+
void delete(Key... key);
4949

5050
/**
5151
* {@inheritDoc}
5252
* This operation will also remove from this batch any prior writes for the same entities.
5353
* @throws DatastoreServiceException if batch is no longer active
5454
*/
5555
@Override
56-
public void put(Entity... entity);
56+
void put(Entity... entity);
5757

5858
/**
5959
* Submit the batch to the Datastore.

src/main/java/com/google/gcloud/datastore/BatchWriterImpl.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@
88
import java.util.LinkedHashMap;
99
import java.util.LinkedHashSet;
1010
import java.util.Map;
11+
import java.util.Set;
1112

1213
class BatchWriterImpl implements BatchWriter {
1314

14-
private final LinkedHashMap<Key, Entity> toAdd = new LinkedHashMap<>();
15-
private final LinkedHashMap<Key, Entity> toUpdate = new LinkedHashMap<>();
16-
private final LinkedHashMap<Key, Entity> toPut = new LinkedHashMap<>();
17-
private final LinkedHashSet<Key> toDelete = new LinkedHashSet<>();
15+
private final Map<Key, Entity> toAdd = new LinkedHashMap<>();
16+
private final Map<Key, Entity> toUpdate = new LinkedHashMap<>();
17+
private final Map<Key, Entity> toPut = new LinkedHashMap<>();
18+
private final Set<Key> toDelete = new LinkedHashSet<>();
1819
private final boolean force;
1920
protected final DatastoreServiceImpl datastore;
2021

src/main/java/com/google/gcloud/datastore/DatastoreServiceException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ static DatastoreServiceException translateAndThrow(DatastoreException exception)
118118
JSONObject error = json.getJSONObject("error").getJSONArray("errors").getJSONObject(0);
119119
reason = error.getString("reason");
120120
message = error.getString("message");
121-
} catch (JSONException ex) {
121+
} catch (JSONException ignore) {
122122
// ignore - will be converted to unknown
123123
}
124124
}

src/main/java/com/google/gcloud/datastore/GqlQuery.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,8 @@ public static final class Builder<V> {
146146
private String namespace;
147147
private String queryString;
148148
private boolean allowLiteral;
149-
private Map<String, Binding> namedBindings = new TreeMap<>();
150-
private List<Binding> positionalBindings = new LinkedList<>();
149+
private final Map<String, Binding> namedBindings = new TreeMap<>();
150+
private final List<Binding> positionalBindings = new LinkedList<>();
151151

152152
Builder(Type<V> type, String query) {
153153
this.type = checkNotNull(type);

src/main/java/com/google/gcloud/datastore/Key.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,24 +114,24 @@ public String toUrlSafe() {
114114
try {
115115
return URLEncoder.encode(toString(), UTF_8.name());
116116
} catch (UnsupportedEncodingException e) {
117-
throw new RuntimeException("Unxpeced encoding exception", e);
117+
throw new IllegalStateException("Unxpeced encoding exception", e);
118118
}
119119
}
120120

121121
/**
122122
* Create a {@code Key} given its URL safe encoded form.
123123
*
124-
* @throws RuntimeException when decoding fails
124+
* @throws IllegalArgumentException when decoding fails
125125
*/
126126
public static Key fromUrlSafe(String urlSafe) {
127127
try {
128128
String utf8Str = URLDecoder.decode(urlSafe, UTF_8.name());
129129
DatastoreV1.Key keyPb = DatastoreV1.Key.parseFrom(ByteString.copyFromUtf8(utf8Str));
130130
return fromPb(keyPb);
131131
} catch (UnsupportedEncodingException e) {
132-
throw new RuntimeException("Unxpeced decoding exception", e);
132+
throw new IllegalStateException("Unxpeced decoding exception", e);
133133
} catch (InvalidProtocolBufferException e) {
134-
throw new RuntimeException("Could not parse key", e);
134+
throw new IllegalArgumentException("Could not parse key", e);
135135
}
136136
}
137137

src/main/java/com/google/gcloud/datastore/PartialKey.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ static PartialKey fromPb(DatastoreV1.Key keyPb) {
6565
}
6666
}
6767
List<DatastoreV1.Key.PathElement> pathElementsPb = keyPb.getPathElementList();
68-
Preconditions.checkArgument(pathElementsPb.size() > 0, "Path must not be empty");
68+
Preconditions.checkArgument(!pathElementsPb.isEmpty(), "Path must not be empty");
6969
ImmutableList.Builder<PathElement> pathBuilder = ImmutableList.builder();
7070
for (DatastoreV1.Key.PathElement pathElementPb : pathElementsPb) {
7171
pathBuilder.add(PathElement.fromPb(pathElementPb));

src/main/java/com/google/gcloud/datastore/Serializable.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ public String toString() {
2020
return toPb().toString();
2121
}
2222

23-
private void writeObject(ObjectOutputStream out) throws IOException {
24-
out.defaultWriteObject();
25-
out.writeObject(toPb().toByteArray());
23+
private void writeObject(ObjectOutputStream output) throws IOException {
24+
output.defaultWriteObject();
25+
output.writeObject(toPb().toByteArray());
2626
}
2727

28-
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
29-
in.defaultReadObject();
30-
bytesPb = (byte[]) in.readObject();
28+
private void readObject(ObjectInputStream input) throws IOException, ClassNotFoundException {
29+
input.defaultReadObject();
30+
bytesPb = (byte[]) input.readObject();
3131
}
3232

3333
protected Object readResolve() throws ObjectStreamException {

0 commit comments

Comments
 (0)