Skip to content

Commit d5d0283

Browse files
Excavator: Format Java files (#30)
1 parent 1cb2ce0 commit d5d0283

27 files changed

Lines changed: 856 additions & 896 deletions

build.gradle

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ buildscript {
1111
classpath 'com.palantir.gradle.idea-configuration:gradle-idea-configuration:0.8.0'
1212
classpath 'com.palantir.gradle.jdks:gradle-jdks:0.75.0'
1313
classpath 'com.palantir.gradle.jdkslatest:gradle-jdks-latest:0.26.0'
14-
classpath 'com.palantir.suppressible-error-prone:gradle-suppressible-error-prone:2.28.0'
14+
classpath 'com.palantir.javaformat:gradle-palantir-java-format:2.89.0'
15+
classpath 'com.palantir.suppressible-error-prone:gradle-suppressible-error-prone:2.31.0'
1516
classpath 'com.diffplug.spotless:spotless-plugin-gradle:8.1.0'
1617
}
1718
}
@@ -144,6 +145,7 @@ repositories {
144145

145146
allprojects {
146147
apply plugin: 'com.palantir.baseline-null-away'
148+
apply plugin: 'com.palantir.java-format'
147149
tasks.withType(JavaCompile) {
148150
}
149151

src/main/java/com/palantir/onb/BootRulesParser.java

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,7 @@ final String loadRulesFile(String filename) {
138138
@SuppressWarnings("for-rollout:NullAway")
139139
public BootRules loadRules(String fileData) {
140140
newRuleSet = new BootRules();
141-
handleJson =
142-
new JsonReader(new StringReader(fileData.replace("\\", "\\\\")));
141+
handleJson = new JsonReader(new StringReader(fileData.replace("\\", "\\\\")));
143142
try {
144143
while (handleJson.hasNext()) {
145144
JsonToken tempToken = handleJson.peek();
@@ -166,8 +165,8 @@ private boolean nameProcessor() throws IOException {
166165

167166
if ("compversion".equalsIgnoreCase(nextName)) {
168167
if (!checkVersionNumber(handleJson.nextString())) {
169-
logger.simpleReport("Failed to load rules file, rules seem to be "
170-
+ "from a unsupported version.", true);
168+
logger.simpleReport(
169+
"Failed to load rules file, rules seem to be " + "from a unsupported version.", true);
171170
return false;
172171
} else {
173172
return true;
@@ -228,9 +227,7 @@ private String fileLocParser(String tempLogFileLoc) {
228227
final int pos = newTempFileLoc.indexOf('\\');
229228
if (pos + 1 < newTempFileLoc.length()) {
230229
if (newTempFileLoc.charAt(pos + 1) == '\\') {
231-
newTempFileLoc = newTempFileLoc.substring(0, pos)
232-
+ newTempFileLoc.substring(
233-
pos + 1);
230+
newTempFileLoc = newTempFileLoc.substring(0, pos) + newTempFileLoc.substring(pos + 1);
234231
}
235232
}
236233
}
@@ -342,15 +339,13 @@ private boolean checkVersionNumber(String readVersion) {
342339
}
343340

344341
// The digit is not the same
345-
if (Integer.parseInt(readSplitVal[i]) < Integer.parseInt(
346-
supportedSplitVal[i])) {
342+
if (Integer.parseInt(readSplitVal[i]) < Integer.parseInt(supportedSplitVal[i])) {
347343
// Read number is smaller than supported
348344
return false;
349345
} else {
350346
// Read number is higher than supported, check against higher
351347
for (int k = 0; k < readSplitVal.length; k++) {
352-
if (Integer.parseInt(readSplitVal[k]) == Integer.parseInt(
353-
currentSplitVal[k])) {
348+
if (Integer.parseInt(readSplitVal[k]) == Integer.parseInt(currentSplitVal[k])) {
354349
continue;
355350
}
356351
// The digit is not the same

src/main/java/com/palantir/onb/Core.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ public final class Core {
3535

3636
public static final String ONB_VERSION = loadVersion();
3737

38-
private Core() {
39-
}
38+
private Core() {}
4039

4140
public static Manager getManager() {
4241
return manager;
@@ -105,7 +104,7 @@ public static void main(final String[] args) {
105104
}
106105
}
107106

108-
//CHECKSTYLE.OFF: CyclomaticComplexity
107+
// CHECKSTYLE.OFF: CyclomaticComplexity
109108
/**
110109
* Process the parameters the user has entered.
111110
* @param newLogger Logger to log errors
@@ -126,7 +125,7 @@ private static byte processArgs(Logging newLogger, String[] args) {
126125
case "-i" -> {
127126
if (argIterator.hasNext()) {
128127
if ("any".equalsIgnoreCase(argIterator.next())) {
129-
//this is so we know its set
128+
// this is so we know its set
130129
manager.overrideInterfaces(new String[0]);
131130
} else {
132131
String temp = argIterator.next();
@@ -220,7 +219,7 @@ private static byte processArgs(Logging newLogger, String[] args) {
220219
}
221220
return returnStatus;
222221
}
223-
//CHECKSTYLE:ON
222+
// CHECKSTYLE:ON
224223

225224
/**
226225
* Echo out the help information to the console.
@@ -248,7 +247,7 @@ private static void printHelp() {
248247
+ "\t-lc [level]\t- starts console logger on specified level\n"
249248
+ "\t-lf [level]\t- starts file logger on specified level\n" + "\t\n" + "\t\n"
250249
+ "Examples\n" + "\tonb.jar -i vmnet1,en0";
251-
//CHECKSTYLE.OFF: RegexpSinglelineJava
250+
// CHECKSTYLE.OFF: RegexpSinglelineJava
252251
System.out.println(output);
253252
}
254253

src/main/java/com/palantir/onb/GeneralTools.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@
2222
* Functions that are used multiple times.
2323
*/
2424
public final class GeneralTools {
25-
private GeneralTools() {
26-
}
25+
private GeneralTools() {}
2726

2827
/**
2928
* Convert from the relative filenames that the packet has in them, to a real system path.

src/main/java/com/palantir/onb/InterfaceData.java

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -29,27 +29,26 @@
2929
*/
3030
public final class InterfaceData {
3131

32-
private InterfaceData() {
33-
}
32+
private InterfaceData() {}
3433

3534
/**
3635
* Output list of interfaces to the console.
3736
*/
3837
static void printInterfaces() {
3938
try {
40-
final Enumeration<NetworkInterface> interfaces =
41-
NetworkInterface.getNetworkInterfaces();
39+
final Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces();
4240
while (interfaces.hasMoreElements()) {
4341
final NetworkInterface networkInterface = interfaces.nextElement();
44-
Manager.getManagerLogger().simpleReport(
45-
"Interface \"" + networkInterface.getDisplayName() + "\" - "
46-
+ networkInterface.getName() + " - Online:"
47-
+ networkInterface.isUp(), false);
48-
final List<InterfaceAddress> listingAddress =
49-
networkInterface.getInterfaceAddresses();
42+
Manager.getManagerLogger()
43+
.simpleReport(
44+
"Interface \"" + networkInterface.getDisplayName() + "\" - "
45+
+ networkInterface.getName() + " - Online:"
46+
+ networkInterface.isUp(),
47+
false);
48+
final List<InterfaceAddress> listingAddress = networkInterface.getInterfaceAddresses();
5049
for (final InterfaceAddress singleAddress : listingAddress) {
51-
Manager.getManagerLogger().simpleReport("\t" + singleAddress.getAddress().getHostAddress(),
52-
false);
50+
Manager.getManagerLogger()
51+
.simpleReport("\t" + singleAddress.getAddress().getHostAddress(), false);
5352
}
5453
}
5554
} catch (final SocketException e) {
@@ -64,8 +63,8 @@ static void printInterfaces() {
6463
*/
6564
public static boolean verifyNics(String intString) {
6665
if (intString.contains("-")) {
67-
Manager.getManagerLogger().simpleReport("It appears a option was given instead of "
68-
+ "a list of interfaces?", true);
66+
Manager.getManagerLogger()
67+
.simpleReport("It appears a option was given instead of " + "a list of interfaces?", true);
6968
return false;
7069
}
7170
final List<String> singleInterfaces = new ArrayList<>(Arrays.asList(intString.split(",")));
@@ -74,8 +73,7 @@ public static boolean verifyNics(String intString) {
7473
return false;
7574
}
7675
try {
77-
final Enumeration<NetworkInterface> interfaces =
78-
NetworkInterface.getNetworkInterfaces();
76+
final Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces();
7977
while (interfaces.hasMoreElements()) {
8078
final NetworkInterface networkInterface = interfaces.nextElement();
8179
singleInterfaces.remove(networkInterface.getName());
@@ -102,8 +100,7 @@ public static boolean verifyNics(String intString) {
102100
public static String[] getInterfaces() {
103101
List<String> ints = new ArrayList<>();
104102
try {
105-
final Enumeration<NetworkInterface> interfaces =
106-
NetworkInterface.getNetworkInterfaces();
103+
final Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces();
107104
while (interfaces.hasMoreElements()) {
108105
final NetworkInterface networkInterface = interfaces.nextElement();
109106
ints.add(networkInterface.getName());

src/main/java/com/palantir/onb/LogStandard.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,7 @@ public interface LogStandard {
3838

3939
void simpleReport(String allLevels, boolean reportingError);
4040

41-
void report(String level0,
42-
String level1,
43-
String level2,
44-
String level3,
45-
String level4,
46-
boolean reportingError);
41+
void report(String level0, String level1, String level2, String level3, String level4, boolean reportingError);
4742

4843
List<TimeStampedLog> getLogNDump();
4944

src/main/java/com/palantir/onb/Logging.java

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
* about packet and response 4 - Most verbose level of output 5 - Pcap File, currently disabled.
3737
*/
3838
public class Logging implements LogStandard {
39-
//CHECKSTYLE.OFF: RegexpSinglelineJava
39+
// CHECKSTYLE.OFF: RegexpSinglelineJava
4040
private int consoleLogLevel;
4141
private int fileLogLevel;
4242
private String fileLogSaveLoc = "log.txt";
@@ -159,7 +159,7 @@ public void simpleReport(String allLevels, boolean reportingError) {
159159
}
160160
}
161161

162-
//CHECKSTYLE.OFF: CyclomaticComplexity
162+
// CHECKSTYLE.OFF: CyclomaticComplexity
163163
/**
164164
* Report for each level.
165165
* @param level0 console lowest log, file disabled
@@ -171,12 +171,8 @@ public void simpleReport(String allLevels, boolean reportingError) {
171171
*/
172172
@Override
173173
@SuppressWarnings("JavaTimeDefaultTimeZone")
174-
public void report(String level0,
175-
String level1,
176-
String level2,
177-
String level3,
178-
String level4,
179-
boolean reportingError) {
174+
public void report(
175+
String level0, String level1, String level2, String level3, String level4, boolean reportingError) {
180176
String prefix = "";
181177
if (setDates) {
182178
final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss - ", Locale.ROOT);
@@ -277,7 +273,7 @@ public void report(String level0,
277273
System.err.println("Error writing log file");
278274
}
279275
}
280-
//CHECKSTYLE.ON
276+
// CHECKSTYLE.ON
281277

282278
/**
283279
* Write this log line to the log file.
@@ -286,9 +282,11 @@ public void report(String level0,
286282
*/
287283
@SuppressWarnings("JavaTimeDefaultTimeZone")
288284
private boolean writeLog(String passedText) {
289-
try (PrintWriter out =
290-
new PrintWriter(Files.newBufferedWriter(Paths.get(fileLogSaveLoc), StandardCharsets.UTF_8,
291-
StandardOpenOption.CREATE, StandardOpenOption.APPEND))) {
285+
try (PrintWriter out = new PrintWriter(Files.newBufferedWriter(
286+
Paths.get(fileLogSaveLoc),
287+
StandardCharsets.UTF_8,
288+
StandardOpenOption.CREATE,
289+
StandardOpenOption.APPEND))) {
292290
final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss - ", Locale.ROOT);
293291
final LocalDateTime date = LocalDateTime.now(ZoneId.systemDefault());
294292
out.println(formatter.format(date) + "\t" + passedText);

src/main/java/com/palantir/onb/Manager.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,10 @@ void combineRules() {
198198
}
199199

200200
if (overrides.getTftpSettingSet().getRootFs() != null
201-
&& overrides.getTftpSettingSet().getRootFs().equals(fileLoaded.getTftpSettingSet().getRootFs())) {
201+
&& overrides
202+
.getTftpSettingSet()
203+
.getRootFs()
204+
.equals(fileLoaded.getTftpSettingSet().getRootFs())) {
202205
fileLoaded.setTftpSettingSet(overrides.getTftpSettingSet());
203206
}
204207
}
@@ -253,7 +256,8 @@ public boolean startTftpWithLogger(LogStandard passedLogger) {
253256
public void startHttpWithLogger(LogStandard passedLogger) {
254257
if (fileLoaded.getTftpSettingSet().getRootFs() != null) {
255258
httpProcess = new ApacheHttp(
256-
fileLoaded.getTftpSettingSet().getRootFs(), fileLoaded.getHttpPort(),
259+
fileLoaded.getTftpSettingSet().getRootFs(),
260+
fileLoaded.getHttpPort(),
257261
fileLoaded.isAllowIsoExtracting());
258262
httpProcess.setLocalLogger(passedLogger);
259263
httpProcess.setLogger(0);
@@ -399,6 +403,7 @@ public boolean flipHttp() {
399403
return startHttp("Http - ");
400404
}
401405
}
406+
402407
private boolean startHttp(String name) {
403408
httpProcess.setStartPort(fileLoaded.getHttpPort());
404409
httpProcess.setFolderLoc(fileLoaded.getTftpSettingSet().getRootFs());

0 commit comments

Comments
 (0)