Skip to content

Commit

Permalink
[#163] Fix code analysis issues
Browse files Browse the repository at this point in the history
  • Loading branch information
susanw1 committed Sep 8, 2024
1 parent 081ea62 commit 8828f8b
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ public ZscriptCommandNode<?> next() {
}
};
}
return new Iterator<ZscriptCommandNode<?>>() {
Iterator<CommandSequenceNode> children = getChildren().iterator();
return new Iterator<>() {
final Iterator<CommandSequenceNode> children = getChildren().iterator();
Iterator<ZscriptCommandNode<?>> childIter = null;

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ enum NotificationActionType {
private final ZscriptNotificationSource source;
private final NotificationActionType type;

public ZscriptNotificationAction(ZscriptNotificationSource source, NotificationActionType type) {
ZscriptNotificationAction(ZscriptNotificationSource source, NotificationActionType type) {
this.source = source;
this.type = type;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,16 +139,13 @@ public void setNotificationComplete(final boolean b) {
}

public AsyncActionNotifier getAsyncActionNotifier() {
return new AsyncActionNotifier() {
@Override
public void notifyNeedsAction() {
switch (state) {
case NOTIFICATION_INCOMPLETE:
state = NotificationSourceState.NOTIFICATION_NEEDS_ACTION;
break;
default:
throw new IllegalStateException("Invalid state transition");
}
return () -> {
switch (state) {
case NOTIFICATION_INCOMPLETE:
state = NotificationSourceState.NOTIFICATION_NEEDS_ACTION;
break;
default:
throw new IllegalStateException("Invalid state transition");
}
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public interface ContextView {

/**
* Allows a background/async command component to signal that the command's code needs scheduling to move it along.
*
* <p/>
* Example, an interrupt-driven serial writer might call {@link AsyncActionNotifier#notifyNeedsAction()} in its interrupt handler to indicate that the data was all sent
* correctly. The command will be progressed next time Zscript is given execution time.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ private void sendNormalMarkerPrefix(SequenceOutStream out) {
} else if (marker == Tokenizer.CMD_END_CLOSE_PAREN) {
out.writeCloseParen();
} else if (marker == Tokenizer.NORMAL_SEQUENCE_END) {
// no action required
} else {
throw new IllegalStateException("Unknown marker");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package net.zscript.javareceiver.demoRun;

import java.io.IOException;
import java.io.PrintStream;

import net.zscript.javareceiver.core.OutputStreamOutStream;

public class ZscriptPrintingOutStream extends OutputStreamOutStream<PrintStream> {
public ZscriptPrintingOutStream() throws IOException {
public ZscriptPrintingOutStream() {
super(System.out);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ private StringChannel(TokenBuffer buffer, String input, SequenceOutStream out) {
this.input = input.getBytes(StandardCharsets.UTF_8);
}

@SuppressWarnings("StatementWithEmptyBody")
@Override
public void moveAlong() {
while (index < input.length && in.offer(input[index++])) {
Expand Down
5 changes: 3 additions & 2 deletions util/misc/src/main/java/net/zscript/util/ByteString.java
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,8 @@ public ByteStringBuilder append(ByteAppendable... appendables) {
* @param objects zero or more Appendables
* @return this builder, to facilitate chaining
*/
public <T> ByteStringBuilder append(ByteAppender<? super T> appender, T... objects) {
@SafeVarargs
public final <T> ByteStringBuilder append(ByteAppender<? super T> appender, T... objects) {
return append(appender, Arrays.asList(objects));
}

Expand Down Expand Up @@ -519,7 +520,7 @@ public ByteStringBuilder appendNumeric16KeepZero(int value) {

/**
* Exposes this Builder as an Appendable to make it easy to append to other ByteStrings.
*
* <p/>
* Note: The bytes appended will be those accumulated at the time the ByteAppendable is used, including any added since this method was called. It isn't a frozen snapshot.
*
* @return an Appendable adapter that can write this Builder to another Builder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

/**
* Little utility class that gives expandable byte array capability without the hassle of ByteArrayOutputStream. Used by ByteString to buffer bytes.
*
* <p/>
* Visible for testing.
*/
final class ExpandableByteBuffer {
Expand Down

0 comments on commit 8828f8b

Please sign in to comment.