[tor-commits] [collector/release] Inline redundant local variables.

karsten at torproject.org karsten at torproject.org
Mon Oct 15 14:39:13 UTC 2018


commit 7c44c114e47603df5e643c67975568821ab6f7cb
Author: Karsten Loesing <karsten.loesing at gmx.net>
Date:   Tue Aug 21 14:10:41 2018 +0200

    Inline redundant local variables.
---
 .../metrics/collector/bridgedescs/BridgeSnapshotReader.java        | 5 ++---
 .../metrics/collector/bridgedescs/SanitizedBridgesWriter.java      | 7 ++-----
 .../org/torproject/metrics/collector/indexer/CreateIndexJson.java  | 6 ++----
 3 files changed, 6 insertions(+), 12 deletions(-)

diff --git a/src/main/java/org/torproject/metrics/collector/bridgedescs/BridgeSnapshotReader.java b/src/main/java/org/torproject/metrics/collector/bridgedescs/BridgeSnapshotReader.java
index 4f72b5a..f16122a 100644
--- a/src/main/java/org/torproject/metrics/collector/bridgedescs/BridgeSnapshotReader.java
+++ b/src/main/java/org/torproject/metrics/collector/bridgedescs/BridgeSnapshotReader.java
@@ -44,10 +44,9 @@ public class BridgeSnapshotReader {
     }
 
     SortedSet<String> parsed = new TreeSet<>();
-    File bdDir = bridgeDirectoriesDir;
     File pbdFile = new File(statsDirectory, "parsed-bridge-directories");
     boolean modified = false;
-    if (bdDir.exists()) {
+    if (bridgeDirectoriesDir.exists()) {
       if (pbdFile.exists()) {
         logger.debug("Reading file {}...", pbdFile.getAbsolutePath());
         try {
@@ -73,7 +72,7 @@ public class BridgeSnapshotReader {
       int parsedExtraInfoDescriptors = 0;
       int skippedExtraInfoDescriptors = 0;
       Stack<File> filesInInputDir = new Stack<>();
-      filesInInputDir.add(bdDir);
+      filesInInputDir.add(bridgeDirectoriesDir);
       while (!filesInInputDir.isEmpty()) {
         File pop = filesInInputDir.pop();
         if (pop.isDirectory()) {
diff --git a/src/main/java/org/torproject/metrics/collector/bridgedescs/SanitizedBridgesWriter.java b/src/main/java/org/torproject/metrics/collector/bridgedescs/SanitizedBridgesWriter.java
index d9a0322..921396c 100644
--- a/src/main/java/org/torproject/metrics/collector/bridgedescs/SanitizedBridgesWriter.java
+++ b/src/main/java/org/torproject/metrics/collector/bridgedescs/SanitizedBridgesWriter.java
@@ -274,11 +274,10 @@ public class SanitizedBridgesWriter extends CollecTorMain {
       byte[] secret = this.getSecretForMonth(month);
       System.arraycopy(secret, 0, hashInput, 24, 31);
       byte[] hashOutput = DigestUtils.sha256(hashInput);
-      String hashedAddress = "10."
+      return "10."
           + (((int) hashOutput[0] + 256) % 256) + "."
           + (((int) hashOutput[1] + 256) % 256) + "."
           + (((int) hashOutput[2] + 256) % 256);
-      return hashedAddress;
     } else {
       return "127.0.0.1";
     }
@@ -1090,9 +1089,7 @@ public class SanitizedBridgesWriter extends CollecTorMain {
               masterKeyEd25519, 0, masterKeyEd25519.length);
           String masterKeyEd25519Base64 = Base64.encodeBase64String(
               masterKeyEd25519);
-          String masterKeyEd25519Base64NoTrailingEqualSigns =
-              masterKeyEd25519Base64.replaceAll("=", "");
-          return masterKeyEd25519Base64NoTrailingEqualSigns;
+          return masterKeyEd25519Base64.replaceAll("=", "");
         }
         extensionStart += 4 + extensionLength;
       }
diff --git a/src/main/java/org/torproject/metrics/collector/indexer/CreateIndexJson.java b/src/main/java/org/torproject/metrics/collector/indexer/CreateIndexJson.java
index a018f8b..a40798e 100644
--- a/src/main/java/org/torproject/metrics/collector/indexer/CreateIndexJson.java
+++ b/src/main/java/org/torproject/metrics/collector/indexer/CreateIndexJson.java
@@ -146,16 +146,14 @@ public class CreateIndexJson extends CollecTorMain {
         }
       }
     }
-    DirectoryNode directoryNode = new DirectoryNode(
+    return new DirectoryNode(
         directory.getName(), fileNodes.isEmpty() ? null : fileNodes,
         directoryNodes.isEmpty() ? null : directoryNodes);
-    return directoryNode;
   }
 
   private FileNode indexFile(File file) {
-    FileNode fileNode = new FileNode(file.getName(), file.length(),
+    return new FileNode(file.getName(), file.length(),
         dateTimeFormat.format(file.lastModified()));
-    return fileNode;
   }
 
   private void writeIndex(IndexNode indexNode) throws Exception {





More information about the tor-commits mailing list