Skip to content

Commit abff28f

Browse files
author
Simon Stone
committed
[FAB-16655] Warnings as errors for Java chaincode docs
Enable warnings as errors using -Xwerror, enable all linting checks with -Xdoclint:all, and fix all the resulting errors. Signed-off-by: Simon Stone <[email protected]> Change-Id: Iac41065811edef7ba734c8ab40c39fd04ee0c0ee
1 parent 50e75bf commit abff28f

File tree

10 files changed

+33
-28
lines changed

10 files changed

+33
-28
lines changed

fabric-chaincode-example-sacc-jars/src/main/java/org/hyperledger/fabric/example/SimpleAsset.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ public class SimpleAsset implements ContractInterface {
1919
* or to migrate data.
2020
*
2121
* @param ctx {@link Context} to operate proposal and ledger
22-
* @return response
22+
* @param key key
23+
* @param value value
2324
*/
2425
@Transaction
2526
public void init(Context ctx, String key, String value) {
@@ -30,7 +31,7 @@ public void init(Context ctx, String key, String value) {
3031
* get returns the value of the specified asset key
3132
*
3233
* @param ctx {@link Context} to operate proposal and ledger
33-
* @param args key
34+
* @param key key
3435
* @return value
3536
*/
3637
@Transaction
@@ -47,7 +48,8 @@ public String get(Context ctx, String key) {
4748
* it will override the value with the new one
4849
*
4950
* @param ctx {@link Context} to operate proposal and ledger
50-
* @param args key and value
51+
* @param key key
52+
* @param value value
5153
* @return value
5254
*/
5355
@Transaction

fabric-chaincode-shim/build.gradle

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ task licenseCheck {
170170

171171

172172
javadoc {
173-
failOnError = false
173+
failOnError = true
174174
excludes = ['org/hyperledger/fabric/contract/ContextFactory.java',
175175
'org/hyperledger/fabric/contract/ContractRouter.java',
176176
'org/hyperledger/fabric/contract/ContractRuntimeException.java',
@@ -188,7 +188,8 @@ javadoc {
188188

189189
if (JavaVersion.current().isJava8Compatible()) {
190190
project.tasks.withType(Javadoc) {
191-
options.addStringOption('Xdoclint:none', '-quiet')
191+
options.addStringOption('Xdoclint:all', '-quiet')
192+
options.addStringOption('Xwerror', '-quiet')
192193
}
193194
}
194195

fabric-chaincode-shim/src/main/java/org/hyperledger/fabric/contract/ContractInterface.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
* The sequence of calls is
2828
*
2929
* <pre>
30-
* createContext() -> beforeTransaction() -> the transaction function -> afterTransaction()
30+
* createContext() -&gt; beforeTransaction() -&gt; the transaction function -&gt; afterTransaction()
3131
* </pre>
3232
* <p>
3333
* If any of these functions throws an exception it is considered an error case,
@@ -46,8 +46,6 @@
4646
* {@link #afterTransaction(Context, Object)} or between separate transaction functions when
4747
* called directory, then a subclass of the
4848
* {@link Context} should be provided.
49-
* <p>
50-
*
5149
*/
5250
public interface ContractInterface {
5351

fabric-chaincode-shim/src/main/java/org/hyperledger/fabric/shim/Chaincode.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,16 @@ public interface Chaincode {
1818
/**
1919
* Called during an instantiate transaction after the container has been
2020
* established, allowing the chaincode to initialize its internal data.
21+
* @param stub the chaincode stub
22+
* @return the chaincode response
2123
*/
2224
public Response init(ChaincodeStub stub);
2325

2426
/**
2527
* Called for every Invoke transaction. The chaincode may change its state
2628
* variables.
29+
* @param stub the chaincode stub
30+
* @return the chaincode response
2731
*/
2832
public Response invoke(ChaincodeStub stub);
2933

fabric-chaincode-shim/src/main/java/org/hyperledger/fabric/shim/ChaincodeStub.java

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -199,10 +199,10 @@ public interface ChaincodeStub {
199199
* unbounded range query on start or end.
200200
* This call is only supported in a read only transaction.
201201
*
202-
* @param startKey
203-
* @param endKey
204-
* @param pageSize
205-
* @param bookmark
202+
* @param startKey the start key
203+
* @param endKey the end key
204+
* @param pageSize the page size
205+
* @param bookmark the bookmark
206206
* @return QueryIterator
207207
*/
208208
QueryResultsIteratorWithMetadata<KeyValue> getStateByRangeWithPagination(String startKey, String endKey, int pageSize, String bookmark);
@@ -215,8 +215,6 @@ public interface ChaincodeStub {
215215
* If a full composite key is specified, it will not match itself, resulting
216216
* in no keys being returned.
217217
* <p>
218-
*
219-
* <p>
220218
* This method takes responsibility to correctly parse the {@link CompositeKey} from a String
221219
* and behaves exactly as {@link ChaincodeStub#getStateByPartialCompositeKey(CompositeKey)}.
222220
* </p>
@@ -273,9 +271,9 @@ public interface ChaincodeStub {
273271
* can be used as a value to the bookmark argument. Otherwise, an empty string must be passed as bookmark. <p>
274272
* This call is only supported in a read only transaction.
275273
*
276-
* @param compositeKey
277-
* @param pageSize
278-
* @param bookmark
274+
* @param compositeKey the composite key
275+
* @param pageSize the page size
276+
* @param bookmark the bookmark
279277
* @return QueryIterator
280278
*/
281279
QueryResultsIteratorWithMetadata<KeyValue> getStateByPartialCompositeKeyWithPagination(CompositeKey compositeKey, int pageSize, String bookmark);
@@ -326,9 +324,9 @@ public interface ChaincodeStub {
326324
* can be used as a value to the bookmark argument. Otherwise, an empty string must be passed as bookmark. <p>
327325
* This call is only supported in a read only transaction.
328326
*
329-
* @param query
330-
* @param pageSize
331-
* @param bookmark
327+
* @param query the query
328+
* @param pageSize the page size
329+
* @param bookmark the bookmark
332330
* @return QueryIterator
333331
*/
334332
QueryResultsIteratorWithMetadata<KeyValue> getQueryResultWithPagination(String query, int pageSize, String bookmark);
@@ -365,7 +363,7 @@ public interface ChaincodeStub {
365363
/**
366364
* @param collection name of the collection
367365
* @param key name of the value
368-
* @return
366+
* @return the private data hash
369367
*/
370368
byte[] getPrivateDataHash(String collection, String key);
371369

fabric-chaincode-shim/src/main/java/org/hyperledger/fabric/shim/ext/sbe/StateBasedEndorsement.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
*/
1818
public interface StateBasedEndorsement {
1919
/**
20-
* The endorsement policy as bytes
20+
* Get the endorsement policy as bytes
21+
* @return the endorsement policy as bytes
2122
*/
2223
byte[] policy();
2324

@@ -29,15 +30,15 @@ public interface StateBasedEndorsement {
2930
* likely going to be the PEER role, while the MEMBER role is the suited
3031
* one if it does not.
3132
*
32-
* @param roleType
33-
* @param organizations
33+
* @param roleType the MSP role type
34+
* @param organizations the list of organizations
3435
*/
3536
void addOrgs(RoleType roleType, String... organizations);
3637

3738
/**
3839
* deletes the specified channel orgs from the existing key-level endorsement
3940
* policy for this KVS key.
40-
* @param organizations
41+
* @param organizations the list of organizations
4142
*/
4243
void delOrgs(String... organizations);
4344

fabric-chaincode-shim/src/main/java/org/hyperledger/fabric/shim/ext/sbe/impl/StateBasedEndorsementFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public static synchronized StateBasedEndorsementFactory getInstance() {
2323
* Constructs a state-based endorsement policy from a given
2424
* serialized EP byte array. If the byte array is empty, a new EP is created.
2525
*
26-
* @param ep
26+
* @param ep serialized endorsement policy
2727
* @return New StateBasedEndorsement instance
2828
*/
2929
public StateBasedEndorsement newStateBasedEndorsement(byte[] ep) {

fabric-chaincode-shim/src/main/java/org/hyperledger/fabric/shim/ledger/CompositeKey.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ public static CompositeKey parseCompositeKey(String compositeKey) {
6464
* is the namespace for compositeKey). This helps in avoding simple/composite
6565
* key collisions.
6666
*
67+
* @param keys the list of simple keys
6768
* @throws CompositeKeyFormatException if First character of the key
6869
*/
6970
public static void validateSimpleKeys(String... keys) {

fabric-chaincode-shim/src/main/java/org/hyperledger/fabric/shim/ledger/QueryResultsIterator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
/**
1010
* QueryResultsIterator allows a chaincode to iterate over a set of key/value pairs returned by range, execute and history queries.
1111
*
12-
* @param <T>
12+
* @param <T> the type of elements returned by the iterator
1313
*/
1414
public interface QueryResultsIterator<T> extends Iterable<T>, AutoCloseable {
1515
}

fabric-chaincode-shim/src/main/java/org/hyperledger/fabric/shim/ledger/QueryResultsIteratorWithMetadata.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* QueryResultsIteratorWithMetadata allows a chaincode to iterate over a set of key/value pairs returned by range, execute and history queries.
1313
* In addition, it store {@link org.hyperledger.fabric.protos.peer.ChaincodeShim.QueryResponseMetadata}, returned by pagination range queries
1414
*
15-
* @param <T>
15+
* @param <T> the type of elements returned by the iterator
1616
*/
1717
public interface QueryResultsIteratorWithMetadata<T> extends Iterable<T>, AutoCloseable {
1818
ChaincodeShim.QueryResponseMetadata getMetadata();

0 commit comments

Comments
 (0)