From: Frederic Suter Date: Mon, 15 May 2017 06:43:41 +0000 (+0200) Subject: please sonar X-Git-Tag: v3.16~274^2~15 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/adc715244ef6399b393a0f30e2598c9a3ed74725 please sonar --- diff --git a/examples/java/app/bittorrent/Peer.java b/examples/java/app/bittorrent/Peer.java index 0bdc770232..3a2e19eb85 100644 --- a/examples/java/app/bittorrent/Peer.java +++ b/examples/java/app/bittorrent/Peer.java @@ -624,10 +624,9 @@ public class Peer extends Process { } private String getStatus() { - String s = ""; - for (int i = 0; i < Common.FILE_PIECES; i++) { - s = s + bitfield[i]; - } - return s; + StringBuilder s = new StringBuilder(""); + for (int i = 0; i < Common.FILE_PIECES; i++) + s.append(bitfield[i]); + return s.toString(); } } diff --git a/examples/java/dht/kademlia/Answer.java b/examples/java/dht/kademlia/Answer.java index 1421529b86..a18bc2af9d 100644 --- a/examples/java/dht/kademlia/Answer.java +++ b/examples/java/dht/kademlia/Answer.java @@ -16,7 +16,7 @@ public class Answer { public Answer(int destinationId) { this.destinationId = destinationId; - nodes = new ArrayList(); + nodes = new ArrayList<>(); } int getDestinationId() { diff --git a/examples/java/dht/kademlia/RoutingTable.java b/examples/java/dht/kademlia/RoutingTable.java index 9dc08f8df1..c5f88b2438 100644 --- a/examples/java/dht/kademlia/RoutingTable.java +++ b/examples/java/dht/kademlia/RoutingTable.java @@ -18,7 +18,7 @@ public class RoutingTable { public RoutingTable(int id) { this.id = id; - buckets = new Vector(); + buckets = new Vector<>(); for (int i = 0; i < Common.IDENTIFIER_SIZE + 1; i++) { buckets.add(new Bucket(i)); } @@ -102,12 +102,12 @@ public class RoutingTable { @Override public String toString() { - String string = "RoutingTable [ id=" + id + " " ; + StringBuilder string = new StringBuilder("RoutingTable [ id=" + id + " "); for (int i = 0; i < buckets.size(); i++) { if (buckets.get(i).size() > 0) { - string += buckets.get(i) + " "; + string.append(buckets.get(i) + " "); } } - return string; + return string.toString(); } }