Skip to content
This repository was archived by the owner on Apr 22, 2025. It is now read-only.

Commit 13337b6

Browse files
bestbeforetodaycr22rc
authored andcommitted
[FAB-4258] Fix compile warnings for redundant code
Also fix checkstyle errors in modified files. Update Eclipse .classpath for Maven POM changes. Update checkstyle configuration to allow suppression. Fix compile warnings in test code. Change-Id: I91b5cf5e6f3085431d490b8d821d72a5dba50c57 Signed-off-by: Mark S. Lewis <Mark_Lewis@uk.ibm.com> Signed-off-by: rickr <cr22rc@gmail.com>
1 parent 8f1fe23 commit 13337b6

File tree

89 files changed

+608
-895
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+608
-895
lines changed

.project

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,15 @@
1515
<arguments>
1616
</arguments>
1717
</buildCommand>
18+
<buildCommand>
19+
<name>net.sf.eclipsecs.core.CheckstyleBuilder</name>
20+
<arguments>
21+
</arguments>
22+
</buildCommand>
1823
</buildSpec>
1924
<natures>
2025
<nature>org.eclipse.jdt.core.javanature</nature>
2126
<nature>org.eclipse.m2e.core.maven2Nature</nature>
27+
<nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
2228
</natures>
2329
</projectDescription>

checkstyle-config.xml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,23 @@
4646
<property name="message" value="Line has trailing spaces."/>
4747
</module>
4848

49+
<module name="SuppressionCommentFilter">
50+
<property name="offCommentFormat" value="CHECKSTYLE.OFF\: ([\w\|]+)"/>
51+
<property name="onCommentFormat" value="CHECKSTYLE.ON\: ([\w\|]+)"/>
52+
<property name="checkFormat" value="$1"/>
53+
</module>
54+
4955
<module name="TreeWalker">
5056

57+
<!-- Required for SuppressionCommentFilter module -->
58+
<module name="FileContentsHolder"/>
59+
5160
<!-- Checks for Naming Conventions. -->
5261
<!-- See http://checkstyle.sf.net/config_naming.html -->
5362
<module name="ConstantName">
5463
<property name="format"
5564
value="^log(ger)?|config|[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$"/>
56-
<property
57-
name="applyToPrivate" value="false"/>
65+
<property name="applyToPrivate" value="false"/>
5866
</module>
5967
<module name="LocalFinalVariableName"/>
6068
<module name="LocalVariableName"/>

pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -305,9 +305,9 @@
305305
</executions>
306306
<configuration>
307307
<consoleOutput>false</consoleOutput>
308-
<logViolationsToConsole>false</logViolationsToConsole>
309-
<failOnViolation>false</failOnViolation>
310-
<failsOnError>false</failsOnError>
308+
<logViolationsToConsole>true</logViolationsToConsole>
309+
<failOnViolation>true</failOnViolation>
310+
<failsOnError>true</failsOnError>
311311
<sourceDirectory>${project.build.sourceDirectory}</sourceDirectory>
312312
<configLocation>checkstyle-config.xml</configLocation>
313313
</configuration>

src/main/java/org/hyperledger/fabric/sdk/BlockEvent.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,27 +18,23 @@
1818
import java.util.List;
1919

2020
import com.google.protobuf.InvalidProtocolBufferException;
21-
import org.apache.commons.logging.Log;
22-
import org.apache.commons.logging.LogFactory;
2321
import org.hyperledger.fabric.protos.common.Common.Block;
22+
import org.hyperledger.fabric.protos.peer.PeerEvents.Event;
2423
import org.hyperledger.fabric.sdk.exception.InvalidProtocolBufferRuntimeException;
2524

26-
import static org.hyperledger.fabric.protos.peer.PeerEvents.Event;
27-
2825
/**
2926
* A wrapper for the Block returned in an Event
3027
*
3128
* @see Block
3229
*/
3330
public class BlockEvent extends BlockInfo {
34-
private static final Log logger = LogFactory.getLog(BlockEvent.class);
31+
// private static final Log logger = LogFactory.getLog(BlockEvent.class);
3532

3633
/**
37-
* Get eventhub that received the event
34+
* Get the Event Hub that received the event.
3835
*
39-
* @return eventhub that received the event
36+
* @return an Event Hub.
4037
*/
41-
4238
public EventHub getEventHub() {
4339
return eventHub;
4440
}

src/main/java/org/hyperledger/fabric/sdk/BlockInfo.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,14 +118,12 @@ public int getEnvelopCount() {
118118
public class EnvelopeInfo {
119119
private final EnvelopeDeserializer envelopeDeserializer;
120120
HeaderDeserializer headerDeserializer;
121-
private final int blockIndex;
122121

123122
//private final EnvelopeDeserializer envelopeDeserializer;
124123

125124
EnvelopeInfo(EnvelopeDeserializer envelopeDeserializer, int blockIndex) {
126125
this.envelopeDeserializer = envelopeDeserializer;
127126
headerDeserializer = envelopeDeserializer.getPayload().getHeader();
128-
this.blockIndex = blockIndex;
129127
headerDeserializer.getChannelHeader().getType();
130128
}
131129

@@ -198,7 +196,7 @@ public EnvelopeInfo getEnvelopeInfo(int blockIndex) throws InvalidProtocolBuffer
198196
return ret;
199197

200198
} catch (InvalidProtocolBufferRuntimeException e) {
201-
throw (InvalidProtocolBufferException) e.getCause();
199+
throw e.getCause();
202200
}
203201

204202
}

src/main/java/org/hyperledger/fabric/sdk/BlockListener.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
66
* You may obtain a copy of the License at
7-
* http://www.apache.org/licenses/LICENSE-2.0
7+
* http://www.apache.org/licenses/LICENSE-2.0
88
* Unless required by applicable law or agreed to in writing, software
99
* distributed under the License is distributed on an "AS IS" BASIS,
1010
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

src/main/java/org/hyperledger/fabric/sdk/ChaincodeEndorsementPolicy.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ private static SignaturePolicy parsePolicy(IndexedHashMap<String, MSPPrincipal>
9595
throw new ChaincodeEndorsementPolicyParseException(format("%s expected to have list but found %s.", key, String.valueOf(vo)));
9696
}
9797

98-
@SuppressWarnings ("unchecked") final List<Map<?, ?>> voList = (List<Map<?, ?>>) vo;
98+
@SuppressWarnings("unchecked") final List<Map<?, ?>> voList = (List<Map<?, ?>>) vo;
9999

100100
if (voList.size() < matchNo) {
101101

src/main/java/org/hyperledger/fabric/sdk/ChaincodeLanguage.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
66
* You may obtain a copy of the License at
7-
* http://www.apache.org/licenses/LICENSE-2.0
7+
* http://www.apache.org/licenses/LICENSE-2.0
88
* Unless required by applicable law or agreed to in writing, software
99
* distributed under the License is distributed on an "AS IS" BASIS,
1010
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -15,6 +15,6 @@
1515
package org.hyperledger.fabric.sdk;
1616

1717
public enum ChaincodeLanguage {
18-
GO_LANG,
19-
JAVA
18+
GO_LANG,
19+
JAVA
2020
}

src/main/java/org/hyperledger/fabric/sdk/ChaincodeResponse.java

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
66
* You may obtain a copy of the License at
7-
* http://www.apache.org/licenses/LICENSE-2.0
7+
* http://www.apache.org/licenses/LICENSE-2.0
88
* Unless required by applicable law or agreed to in writing, software
99
* distributed under the License is distributed on an "AS IS" BASIS,
1010
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -31,33 +31,31 @@ public int getStatus() {
3131
}
3232
}
3333

34-
private Status status = Status.UNDEFINED;
35-
private String message = null;
36-
private String transactionID = null;
37-
private String chaincodeID = null;
34+
private final Status status;
35+
private final String message;
36+
private final String transactionID;
3837

3938
public ChaincodeResponse(String transactionID, String chaincodeID, Status status, String message) {
4039
this.status = status;
4140
this.message = message;
4241
this.transactionID = transactionID;
43-
this.chaincodeID = chaincodeID;
4442
}
4543

4644
public ChaincodeResponse(String transactionID, String chaincodeID, int istatus, String message) {
4745

4846
switch (istatus) {
49-
case 200:
50-
this.status = Status.SUCCESS;
51-
break;
52-
case 500:
53-
this.status = Status.FAILURE;
54-
break;
55-
56-
47+
case 200:
48+
this.status = Status.SUCCESS;
49+
break;
50+
case 500:
51+
this.status = Status.FAILURE;
52+
break;
53+
default:
54+
this.status = Status.UNDEFINED;
55+
break;
5756
}
5857
this.message = message;
5958
this.transactionID = transactionID;
60-
this.chaincodeID = chaincodeID;
6159
}
6260

6361
/**

0 commit comments

Comments
 (0)