[tor-commits] [collector/master] Resolve checkstyle complaints.
karsten at torproject.org
karsten at torproject.org
Fri Jan 6 19:16:55 UTC 2017
commit 71ce5c8ba4e68fff587d129441a0265b3bc32e66
Author: Karsten Loesing <karsten.loesing at gmx.net>
Date: Fri Jan 6 12:03:13 2017 +0100
Resolve checkstyle complaints.
Fixes #21143.
---
src/main/java/org/torproject/collector/Main.java | 7 ++++---
.../collector/bridgedescs/BridgeDescriptorParser.java | 4 ++--
.../collector/bridgedescs/BridgeSnapshotReader.java | 3 ++-
.../org/torproject/collector/conf/Configuration.java | 3 ++-
.../org/torproject/collector/cron/CollecTorMain.java | 6 ++++--
.../torproject/collector/relaydescs/ArchiveWriter.java | 3 ++-
.../relaydescs/RelayDescriptorDownloader.java | 16 ++++++++--------
.../collector/torperf/TorperfDownloader.java | 4 ++--
.../torproject/collector/sync/SyncPersistenceTest.java | 18 +++++++++++-------
9 files changed, 37 insertions(+), 27 deletions(-)
diff --git a/src/main/java/org/torproject/collector/Main.java b/src/main/java/org/torproject/collector/Main.java
index 289cf30..0feeec9 100644
--- a/src/main/java/org/torproject/collector/Main.java
+++ b/src/main/java/org/torproject/collector/Main.java
@@ -42,7 +42,8 @@ public class Main {
/** All possible main classes.
* If a new CollecTorMain class is available, just add it to this map.
*/
- static final Map<Key, Class<? extends CollecTorMain>> collecTorMains = new HashMap<>();
+ static final Map<Key, Class<? extends CollecTorMain>> collecTorMains =
+ new HashMap<>();
static { // add a new main class here
collecTorMains.put(Key.BridgedescsActivated, SanitizedBridgesWriter.class);
@@ -91,8 +92,8 @@ public class Main {
private static void writeDefaultConfig(Path confPath) {
try {
- Files.copy(Main.class.getClassLoader().getResource(CONF_FILE).openStream(),
- confPath, StandardCopyOption.REPLACE_EXISTING);
+ Files.copy(Main.class.getClassLoader().getResource(CONF_FILE)
+ .openStream(), confPath, StandardCopyOption.REPLACE_EXISTING);
printUsage("Could not find config file. In the default "
+ "configuration, we are not configured to read data from any "
+ "data source or write data to any data sink. You need to "
diff --git a/src/main/java/org/torproject/collector/bridgedescs/BridgeDescriptorParser.java b/src/main/java/org/torproject/collector/bridgedescs/BridgeDescriptorParser.java
index 64b1ebd..7c83884 100644
--- a/src/main/java/org/torproject/collector/bridgedescs/BridgeDescriptorParser.java
+++ b/src/main/java/org/torproject/collector/bridgedescs/BridgeDescriptorParser.java
@@ -31,8 +31,8 @@ public class BridgeDescriptorParser {
/** Parses the first line of the given descriptor data to determine the
* descriptor type and passes it to the sanitized bridges writer. */
- public void parse(byte[] allData, String dateTime, String authorityFingerprint)
- throws ConfigurationException {
+ public void parse(byte[] allData, String dateTime,
+ String authorityFingerprint) throws ConfigurationException {
try {
BufferedReader br = new BufferedReader(new StringReader(
new String(allData, "US-ASCII")));
diff --git a/src/main/java/org/torproject/collector/bridgedescs/BridgeSnapshotReader.java b/src/main/java/org/torproject/collector/bridgedescs/BridgeSnapshotReader.java
index 2a9b568..9d8b06a 100644
--- a/src/main/java/org/torproject/collector/bridgedescs/BridgeSnapshotReader.java
+++ b/src/main/java/org/torproject/collector/bridgedescs/BridgeSnapshotReader.java
@@ -37,7 +37,8 @@ public class BridgeSnapshotReader {
* Reads the half-hourly snapshots of bridge descriptors from Bifroest.
*/
public BridgeSnapshotReader(BridgeDescriptorParser bdp,
- File bridgeDirectoriesDir, File statsDirectory) throws ConfigurationException {
+ File bridgeDirectoriesDir, File statsDirectory)
+ throws ConfigurationException {
if (bdp == null || bridgeDirectoriesDir == null
|| statsDirectory == null) {
diff --git a/src/main/java/org/torproject/collector/conf/Configuration.java b/src/main/java/org/torproject/collector/conf/Configuration.java
index b63a00c..d194a94 100644
--- a/src/main/java/org/torproject/collector/conf/Configuration.java
+++ b/src/main/java/org/torproject/collector/conf/Configuration.java
@@ -256,7 +256,8 @@ public class Configuration extends Observable implements Cloneable {
* Returns a {@code SourceType} as List, e.g.
* {@code sourcetypeproperty = Remote, Sync}.
*/
- public Set<SourceType> getSourceTypeSet(Key key) throws ConfigurationException {
+ public Set<SourceType> getSourceTypeSet(Key key)
+ throws ConfigurationException {
Set<SourceType> res = null;
try {
checkClass(key, SourceType[].class);
diff --git a/src/main/java/org/torproject/collector/cron/CollecTorMain.java b/src/main/java/org/torproject/collector/cron/CollecTorMain.java
index c9c931f..8581310 100644
--- a/src/main/java/org/torproject/collector/cron/CollecTorMain.java
+++ b/src/main/java/org/torproject/collector/cron/CollecTorMain.java
@@ -78,7 +78,8 @@ public abstract class CollecTorMain extends SyncManager
logger.info("Finished sync-run of module {} of CollecTor.", module());
}
} catch (Throwable th) { // Catching all (cf. above).
- logger.error("Sync-run of {} module failed: {}", module(), th.getMessage(), th);
+ logger.error("Sync-run of {} module failed: {}", module(),
+ th.getMessage(), th);
}
}
@@ -90,7 +91,8 @@ public abstract class CollecTorMain extends SyncManager
private boolean isSyncOnly() throws ConfigurationException {
String key = this.syncMarker() + SOURCES;
- return this.isSync() && config.getSourceTypeSet(Key.valueOf(key)).size() == 1;
+ return this.isSync()
+ && config.getSourceTypeSet(Key.valueOf(key)).size() == 1;
}
/** Wrapper for <code>run</code>. */
diff --git a/src/main/java/org/torproject/collector/relaydescs/ArchiveWriter.java b/src/main/java/org/torproject/collector/relaydescs/ArchiveWriter.java
index 20d0663..f4ed1e8 100644
--- a/src/main/java/org/torproject/collector/relaydescs/ArchiveWriter.java
+++ b/src/main/java/org/torproject/collector/relaydescs/ArchiveWriter.java
@@ -671,7 +671,8 @@ public class ArchiveWriter extends CollecTorMain {
dayDirectoryFileFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
File tarballFile = Paths.get(this.outputDirectory, MICRODESC,
yearMonthDirectoryFormat.format(validAfter), CONSENSUS_MICRODESC,
- dayDirectoryFileFormat.format(validAfter) + "-consensus-microdesc").toFile();
+ dayDirectoryFileFormat.format(validAfter)
+ + "-consensus-microdesc").toFile();
boolean tarballFileExistedBefore = tarballFile.exists();
File rsyncFile = Paths.get(recentPathName, RELAY_DESCRIPTORS, MICRODESCS,
CONSENSUS_MICRODESC, tarballFile.getName()).toFile();
diff --git a/src/main/java/org/torproject/collector/relaydescs/RelayDescriptorDownloader.java b/src/main/java/org/torproject/collector/relaydescs/RelayDescriptorDownloader.java
index 841a63b..0d5dc6d 100644
--- a/src/main/java/org/torproject/collector/relaydescs/RelayDescriptorDownloader.java
+++ b/src/main/java/org/torproject/collector/relaydescs/RelayDescriptorDownloader.java
@@ -53,7 +53,8 @@ public class RelayDescriptorDownloader {
* - "consensus-microdesc,<validafter>,<parsed>",
* - "vote,<validafter>,<fingerprint>,<parsed>",
* - "server,<published>,<relayid>,<descid>,<parsed>",
- * - "extra,<published>,<relayid>,<descid>,<parsed>", or
+ * - "extra,<published>,<relayid>,<descid>,<parsed>",
+ * or
* - "micro,<validafter>,<relayid>,<descid>,<parsed>".
* </p>
*/
@@ -69,9 +70,9 @@ public class RelayDescriptorDownloader {
/**
* Map from base64 microdescriptor digests to keys in missingDescriptors
- * ("micro,<validafter>,<relayid>,<descid>"). We need this map, because
- * we can't learn <validafter> or <relayid> from parsing
- * microdescriptors, but we need to know <validafter> to store
+ * ("micro,<validafter>,<relayid>,<descid>"). We need this
+ * map, because we can't learn <validafter> or <relayid> from
+ * parsing microdescriptors, but we need to know <validafter> to store
* microdescriptors to disk and both <validafter> and <relayid> to
* remove microdescriptors from the missing list. There are potentially
* many matching keys in missingDescriptors for the same microdescriptor
@@ -508,10 +509,9 @@ public class RelayDescriptorDownloader {
}
/**
- * We have parsed a microdesc consensus. Take this microdesc consensus
- * off the missing list and add the <code>microdescriptors</code> which
- * are in the format "<validafter>,<relayid>,<descid>" to that
- * list.
+ * We have parsed a microdesc consensus. Take this microdesc consensus off the
+ * missing list and add the <code>microdescriptors</code> which are in the
+ * format "<validafter>,<relayid>,<descid>" to that list.
*/
public void haveParsedMicrodescConsensus(String validAfter,
Set<String> microdescriptors) {
diff --git a/src/main/java/org/torproject/collector/torperf/TorperfDownloader.java b/src/main/java/org/torproject/collector/torperf/TorperfDownloader.java
index 8b5df05..db18267 100644
--- a/src/main/java/org/torproject/collector/torperf/TorperfDownloader.java
+++ b/src/main/java/org/torproject/collector/torperf/TorperfDownloader.java
@@ -65,8 +65,8 @@ public class TorperfDownloader extends CollecTorMain {
this.torperfFilesLines = config.getStringArray(Key.TorperfFilesLines);
this.torperfOutputDirectory
= new File(config.getPath(Key.OutputPath).toString(), TORPERF);
- this.torperfLastMergedFile = new File(config.getPath(Key.StatsPath).toFile(),
- "torperf-last-merged");
+ this.torperfLastMergedFile =
+ new File(config.getPath(Key.StatsPath).toFile(), "torperf-last-merged");
if (!this.torperfOutputDirectory.exists()) {
this.torperfOutputDirectory.mkdirs();
}
diff --git a/src/test/java/org/torproject/collector/sync/SyncPersistenceTest.java b/src/test/java/org/torproject/collector/sync/SyncPersistenceTest.java
index 665f2ea..755ada8 100644
--- a/src/test/java/org/torproject/collector/sync/SyncPersistenceTest.java
+++ b/src/test/java/org/torproject/collector/sync/SyncPersistenceTest.java
@@ -38,7 +38,7 @@ public class SyncPersistenceTest {
return Arrays.asList(new Object[][] {
{"exit-lists/2016-09-20-13-02-00", // expected recent path
- new String[]{"exit-lists/2016/09/20/2016-09-20-13-02-00"}, // expected out path
+ new String[]{"exit-lists/2016/09/20/2016-09-20-13-02-00"}, // exp. out
"2016-09-20-13-02-00", // test-filename in src/test/resources
Integer.valueOf(1), // expected recent count of descs files
Integer.valueOf(1)}, // expected output count of descs files
@@ -70,7 +70,8 @@ public class SyncPersistenceTest {
Integer.valueOf(10)},
{"relay-descriptors/consensuses/2016-09-20-13-00-00-consensus",
- new String[]{"relay-descriptors/consensus/2016/09/20/2016-09-20-13-00-00-consensus"},
+ new String[]{"relay-descriptors/consensus/2016/09/20/"
+ + "2016-09-20-13-00-00-consensus"},
"2016-09-20-13-00-00-consensus",
Integer.valueOf(1),
Integer.valueOf(1)},
@@ -86,7 +87,8 @@ public class SyncPersistenceTest {
{"relay-descriptors/votes/2016-10-01-16-00-00-vote"
+ "-0232AF901C31A04EE9848595AF9BB7620D4C5B2E"
+ "-FEE63B4AB7CE5A6BDD09E9A5C4F01BD61EB7E4F1",
- new String[]{"relay-descriptors/vote/2016/10/01/2016-10-01-16-00-00-vote"
+ new String[]{"relay-descriptors/vote/2016/10/01/"
+ + "2016-10-01-16-00-00-vote"
+ "-0232AF901C31A04EE9848595AF9BB7620D4C5B2E"
+ "-FEE63B4AB7CE5A6BDD09E9A5C4F01BD61EB7E4F1"},
"2016-10-01-16-00-00-vote-0232AF901C31A04EE9848595AF9BB7620D4C5B2E-"
@@ -97,7 +99,8 @@ public class SyncPersistenceTest {
{"relay-descriptors/votes/2016-09-20-13-00-00-vote-"
+ "49015F787433103580E3B66A1707A00E60F2D15B"
+ "-60ADC6BEC262AE921A1037D54C8A3976367DBE87",
- new String[]{"relay-descriptors/vote/2016/09/20/2016-09-20-13-00-00-vote-"
+ new String[]{"relay-descriptors/vote/2016/09/20/"
+ + "2016-09-20-13-00-00-vote-"
+ "49015F787433103580E3B66A1707A00E60F2D15B"
+ "-60ADC6BEC262AE921A1037D54C8A3976367DBE87"},
"2016-09-20-13-00-00-vote-49015F787433103580E3B66A1707A00E60F2D15B"
@@ -234,8 +237,8 @@ public class SyncPersistenceTest {
makeTemporaryFolders();
DescriptorParser dp = DescriptorSourceFactory.createDescriptorParser();
SyncPersistence persist = new SyncPersistence(conf);
- persist.storeDescs(dp.parseDescriptors(bytesFromResource(), filename), filename,
- 1475694377000L);
+ persist.storeDescs(dp.parseDescriptors(bytesFromResource(), filename),
+ filename, 1475694377000L);
List<File> recentList = new ArrayList<>();
List<File> outputList = new ArrayList<>();
Files.walkFileTree(output.toPath(), new FileCollector(outputList));
@@ -268,7 +271,8 @@ public class SyncPersistenceTest {
assertEquals(expContent.size(), content.size());
int contentSize = content.size();
for (String line : expContent) {
- assertTrue("Couln't remove " + line + " from " + recentList.get(0), content.remove(line));
+ assertTrue("Couln't remove " + line + " from " + recentList.get(0),
+ content.remove(line));
assertEquals(--contentSize, content.size());
}
assertTrue("Lines left over: " + content, content.isEmpty());
More information about the tor-commits
mailing list