Skip to content

Commit

Permalink
java inspection pass
Browse files Browse the repository at this point in the history
  • Loading branch information
mck1117 committed Nov 26, 2023
1 parent abce347 commit ddc5400
Show file tree
Hide file tree
Showing 14 changed files with 17 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,17 +105,12 @@ public static void assertNull(String msg, Object value) {
}

public static EngineChart nextChart(CommandQueue commandQueue) {
long start = System.currentTimeMillis();
EngineChart chart = EngineChartParser.unpackToMap(getNextWaveChart(commandQueue));
// FileLog.MAIN.logLine("AUTOTEST nextChart() in " + (System.currentTimeMillis() - start));
return chart;
return EngineChartParser.unpackToMap(getNextWaveChart(commandQueue));
}

static String getNextWaveChart(CommandQueue commandQueue) {
IoUtil.sendBlockingCommand(Fields.CMD_RESET_ENGINE_SNIFFER, commandQueue);
String result = getEngineChart(commandQueue);
// FileLog.MAIN.logLine("current chart: " + result);
return result;
return getEngineChart(commandQueue);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,9 @@ public static String niceToString(Number value) {

public static String niceToString(Number value, int precision) {
// not enum field
Number number = value;
if (number instanceof Float)
return niceToString(number.floatValue(), precision);
return number.toString();
if (value instanceof Float)
return niceToString(value.floatValue(), precision);
return value.toString();
}

public static String niceToString(double value, int precision) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public static String runUtil(String fileName) throws IOException {
continue;
line = line.substring(ANALOG_CHART.length());

String p[] = line.split(",");
String[] p = line.split(",");
line = p[0];

aa.add(currentRpm, line);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public static SerialAutoChecker.AutoDetectResult autoDetectSerial(Function<Seria
if (rusEfiAddress != null) {
return getSignatureFromPorts(callback, new String[] {rusEfiAddress});
}
String[] serialPorts = getPortNames();
String[] serialPorts = LinkManager.getCommPorts();
if (serialPorts.length == 0) {
log.error("No serial ports detected");
return new SerialAutoChecker.AutoDetectResult(null, null);
Expand Down Expand Up @@ -93,13 +93,6 @@ public String toString() {
return autoDetectResult;
}

private static String[] getPortNames() {
// long now = System.currentTimeMillis();
String[] portNames = LinkManager.getCommPorts();
// log.info("Took " + (System.currentTimeMillis() - now));
return portNames;
}

@Nullable
public static SerialAutoChecker.AutoDetectResult autoDetectPort(JFrame parent) {
SerialAutoChecker.AutoDetectResult autoDetectedPort = autoDetectSerial(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public static void main(String[] args) throws IOException {

for (int i = 0; i < 3; i++) {
// warm-up cycles just for fun
String signature = BinaryProtocol.getSignature(tsStream);
BinaryProtocol.getSignature(tsStream);
}


Expand All @@ -32,7 +32,7 @@ public static void main(String[] args) throws IOException {
long startMs = System.currentTimeMillis();
for (int i = 0; i < count; i++) {
// warm-up cycles just for fun
String signature = BinaryProtocol.getSignature(tsStream);
BinaryProtocol.getSignature(tsStream);
}
long time = System.currentTimeMillis() - startMs;
double timePerCommand = 1.0 * time / count;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ public static IoStream connectToLocalhost(int controllerPort) {
}

public static BinaryProtocolServer createVirtualController(int controllerPort, ConfigurationImage controllerImage, BinaryProtocolServer.Context context) throws InterruptedException {
CountDownLatch controllerCreated = new CountDownLatch(1);
try {
return createVirtualController(controllerImage, controllerPort, context);
} catch (IOException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public void add(int rpm, String line) {
count ++;
rpmAtPrevChart = rpm;

String v[] = line.split("\\|");
String[] v = line.split("\\|");
System.out.println("rpm " + rpm + ": " + v.length + " values");

List<AngleEvent> current = new ArrayList<>();
Expand Down Expand Up @@ -102,7 +102,7 @@ public void printReport(Appendable stream) throws IOException {
for (Map.Entry<Integer, List<AngleEvent>> e : angleData.entrySet()) {
int k = e.getKey();
List<AngleEvent> v = e.getValue();
double values[] = new double[v.size()];
double[] values = new double[v.size()];
for (int i = 0; i < v.size(); i++)
values[i] = v.get(i).getAngle();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Fixed-size array backed buffer
*/
public class CyclicBuffer implements DataBuffer {
private final double values[];
private final double[] values;

private int size = 0;
private int pointer = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ public static List<UpDown> parse(String report) {
continue;
}

String upString[] = array[index].split("_");
String downString[] = array[index + 2].split("_");
String[] upString = array[index].split("_");
String[] downString = array[index + 2].split("_");
try {
int upTime = Integer.parseInt(array[index + 1]);
int downTime = Integer.parseInt(array[index + 3]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,6 @@ public static boolean fomeEcuHasOpenblt(String port) {
return false;
}

IncomingDataBuffer idb = stream.getDataBuffer();
stream.sendPacket(new byte[]{(byte) Fields.TS_QUERY_BOOTLOADER});

byte[] response = stream.getDataBuffer().getPacket(500, "fomeEcuHasOpenblt");
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.rusefi.core.ui;
package com.rusefi.ui;

import javax.swing.*;
import java.awt.*;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public Dimension getPreferredSize() {
content.add(scrollPane, BorderLayout.CENTER);

JOptionPane.showConfirmDialog(findActiveFrame(), content, CONSOLE_VERSION + ": Exception Occurred", JOptionPane.DEFAULT_OPTION);
log.info("handleException: " + baos.toString());
log.info("handleException: " + baos);
}

private static Frame findActiveFrame() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,10 @@ public String getContent() {

@NotNull
static String wrapSwitchStatement(StringBuilder switchBody) {
String fullSwitch = switchBody.length() == 0 ? "" :
return switchBody.length() == 0 ? "" :
("\tint hash = djb2lowerCase(name);\n" +

"\tswitch(hash) {\n" + switchBody + "\t}\n");
return fullSwitch;
}

@NotNull
Expand Down

0 comments on commit ddc5400

Please sign in to comment.