Skip to content

Commit

Permalink
[FAB-4258] Fix compile warnings for redundant code
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
bestbeforetoday authored and cr22rc committed Jun 8, 2017
1 parent 8f1fe23 commit 13337b6
Show file tree
Hide file tree
Showing 89 changed files with 608 additions and 895 deletions.
6 changes: 6 additions & 0 deletions .project
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,15 @@
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>net.sf.eclipsecs.core.CheckstyleBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
</natures>
</projectDescription>
12 changes: 10 additions & 2 deletions checkstyle-config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,23 @@
<property name="message" value="Line has trailing spaces."/>
</module>

<module name="SuppressionCommentFilter">
<property name="offCommentFormat" value="CHECKSTYLE.OFF\: ([\w\|]+)"/>
<property name="onCommentFormat" value="CHECKSTYLE.ON\: ([\w\|]+)"/>
<property name="checkFormat" value="$1"/>
</module>

<module name="TreeWalker">

<!-- Required for SuppressionCommentFilter module -->
<module name="FileContentsHolder"/>

<!-- Checks for Naming Conventions. -->
<!-- See http://checkstyle.sf.net/config_naming.html -->
<module name="ConstantName">
<property name="format"
value="^log(ger)?|config|[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$"/>
<property
name="applyToPrivate" value="false"/>
<property name="applyToPrivate" value="false"/>
</module>
<module name="LocalFinalVariableName"/>
<module name="LocalVariableName"/>
Expand Down
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -305,9 +305,9 @@
</executions>
<configuration>
<consoleOutput>false</consoleOutput>
<logViolationsToConsole>false</logViolationsToConsole>
<failOnViolation>false</failOnViolation>
<failsOnError>false</failsOnError>
<logViolationsToConsole>true</logViolationsToConsole>
<failOnViolation>true</failOnViolation>
<failsOnError>true</failsOnError>
<sourceDirectory>${project.build.sourceDirectory}</sourceDirectory>
<configLocation>checkstyle-config.xml</configLocation>
</configuration>
Expand Down
12 changes: 4 additions & 8 deletions src/main/java/org/hyperledger/fabric/sdk/BlockEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,23 @@
import java.util.List;

import com.google.protobuf.InvalidProtocolBufferException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hyperledger.fabric.protos.common.Common.Block;
import org.hyperledger.fabric.protos.peer.PeerEvents.Event;
import org.hyperledger.fabric.sdk.exception.InvalidProtocolBufferRuntimeException;

import static org.hyperledger.fabric.protos.peer.PeerEvents.Event;

/**
* A wrapper for the Block returned in an Event
*
* @see Block
*/
public class BlockEvent extends BlockInfo {
private static final Log logger = LogFactory.getLog(BlockEvent.class);
// private static final Log logger = LogFactory.getLog(BlockEvent.class);

/**
* Get eventhub that received the event
* Get the Event Hub that received the event.
*
* @return eventhub that received the event
* @return an Event Hub.
*/

public EventHub getEventHub() {
return eventHub;
}
Expand Down
4 changes: 1 addition & 3 deletions src/main/java/org/hyperledger/fabric/sdk/BlockInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,12 @@ public int getEnvelopCount() {
public class EnvelopeInfo {
private final EnvelopeDeserializer envelopeDeserializer;
HeaderDeserializer headerDeserializer;
private final int blockIndex;

//private final EnvelopeDeserializer envelopeDeserializer;

EnvelopeInfo(EnvelopeDeserializer envelopeDeserializer, int blockIndex) {
this.envelopeDeserializer = envelopeDeserializer;
headerDeserializer = envelopeDeserializer.getPayload().getHeader();
this.blockIndex = blockIndex;
headerDeserializer.getChannelHeader().getType();
}

Expand Down Expand Up @@ -198,7 +196,7 @@ public EnvelopeInfo getEnvelopeInfo(int blockIndex) throws InvalidProtocolBuffer
return ret;

} catch (InvalidProtocolBufferRuntimeException e) {
throw (InvalidProtocolBufferException) e.getCause();
throw e.getCause();
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Licensed 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
* 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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ private static SignaturePolicy parsePolicy(IndexedHashMap<String, MSPPrincipal>
throw new ChaincodeEndorsementPolicyParseException(format("%s expected to have list but found %s.", key, String.valueOf(vo)));
}

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

if (voList.size() < matchNo) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Licensed 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
* 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.
Expand All @@ -15,6 +15,6 @@
package org.hyperledger.fabric.sdk;

public enum ChaincodeLanguage {
GO_LANG,
JAVA
GO_LANG,
JAVA
}
28 changes: 13 additions & 15 deletions src/main/java/org/hyperledger/fabric/sdk/ChaincodeResponse.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Licensed 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
* 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.
Expand All @@ -31,33 +31,31 @@ public int getStatus() {
}
}

private Status status = Status.UNDEFINED;
private String message = null;
private String transactionID = null;
private String chaincodeID = null;
private final Status status;
private final String message;
private final String transactionID;

public ChaincodeResponse(String transactionID, String chaincodeID, Status status, String message) {
this.status = status;
this.message = message;
this.transactionID = transactionID;
this.chaincodeID = chaincodeID;
}

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

switch (istatus) {
case 200:
this.status = Status.SUCCESS;
break;
case 500:
this.status = Status.FAILURE;
break;


case 200:
this.status = Status.SUCCESS;
break;
case 500:
this.status = Status.FAILURE;
break;
default:
this.status = Status.UNDEFINED;
break;
}
this.message = message;
this.transactionID = transactionID;
this.chaincodeID = chaincodeID;
}

/**
Expand Down
Loading

0 comments on commit 13337b6

Please sign in to comment.