Skip to content

Commit

Permalink
Multiple code improvements - squid:SwitchLastCaseIsDefaultCheck, squi…
Browse files Browse the repository at this point in the history
…d:S1197, squid:S1118
  • Loading branch information
George Kankava committed Mar 28, 2016
1 parent 704633f commit 1f0e856
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 4 deletions.
2 changes: 2 additions & 0 deletions jansi/src/main/java/org/fusesource/jansi/AnsiConsole.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ public class AnsiConsole {

private static int installed;

private AnsiConsole() {}

public static OutputStream wrapOutputStream(final OutputStream stream) {
return wrapOutputStream(stream, STDOUT_FILENO);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public AnsiOutputStream(OutputStream os) {
}

private final static int MAX_ESCAPE_SEQUENCE_LENGTH=100;
private byte buffer[] = new byte[MAX_ESCAPE_SEQUENCE_LENGTH];
private byte[] buffer = new byte[MAX_ESCAPE_SEQUENCE_LENGTH];
private int pos=0;
private int startOfValue;
private final ArrayList<Object> options = new ArrayList<Object>();
Expand Down Expand Up @@ -112,6 +112,8 @@ public void write(int data) throws IOException {
reset( processEscapeCommand(options, data) );
}
break;
default:
break;

case LOOKING_FOR_INT_ARG_END:
buffer[pos++] = (byte)data;
Expand Down
2 changes: 2 additions & 0 deletions jansi/src/main/java/org/fusesource/jansi/AnsiRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ public class AnsiRenderer

public static final String CODE_LIST_SEPARATOR = ",";

private AnsiRenderer() {}

static public String render(final String input) throws IllegalArgumentException {
StringBuffer buff = new StringBuffer();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void close() throws IOException {
super.close();
}

private static final String ANSI_COLOR_MAP[] = { "black", "red",
private static final String[] ANSI_COLOR_MAP = { "black", "red",
"green", "yellow", "blue", "magenta", "cyan", "white", };

private static final byte[] BYTES_QUOT = "&quot;".getBytes();
Expand Down Expand Up @@ -114,6 +114,8 @@ protected void processSetAttribute(int attribute) throws IOException {
break;
case ATTRIBUTE_NEGATIVE_Off:
break;
default:
break;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public final class WindowsAnsiOutputStream extends AnsiOutputStream {
private static final short BACKGROUND_CYAN = (short) (BACKGROUND_BLUE|BACKGROUND_GREEN);
private static final short BACKGROUND_WHITE = (short) (BACKGROUND_RED|BACKGROUND_GREEN|BACKGROUND_BLUE);

private static final short ANSI_FOREGROUND_COLOR_MAP[] = {
private static final short[] ANSI_FOREGROUND_COLOR_MAP = {
FOREGROUND_BLACK,
FOREGROUND_RED,
FOREGROUND_GREEN,
Expand All @@ -75,7 +75,7 @@ public final class WindowsAnsiOutputStream extends AnsiOutputStream {
FOREGROUND_WHITE,
};

private static final short ANSI_BACKGROUND_COLOR_MAP[] = {
private static final short[] ANSI_BACKGROUND_COLOR_MAP = {
BACKGROUND_BLACK,
BACKGROUND_RED,
BACKGROUND_GREEN,
Expand Down Expand Up @@ -163,6 +163,9 @@ protected void processEraseScreen(int eraseOption) throws IOException {
(info.size.x - info.cursorPosition.x);
FillConsoleOutputAttribute(console, originalColors, lengthToEnd, info.cursorPosition.copy(), written);
FillConsoleOutputCharacterW(console, ' ', lengthToEnd, info.cursorPosition.copy(), written);
break;
default:
break;
}
}

Expand All @@ -187,6 +190,9 @@ protected void processEraseLine(int eraseOption) throws IOException {
int lengthToLastCol = info.size.x - info.cursorPosition.x;
FillConsoleOutputAttribute(console, originalColors, lengthToLastCol, info.cursorPosition.copy(), written);
FillConsoleOutputCharacterW(console, ' ', lengthToLastCol, info.cursorPosition.copy(), written);
break;
default:
break;
}
}

Expand Down Expand Up @@ -295,6 +301,8 @@ protected void processSetAttribute(int attribute) throws IOException {
negative = false;
applyAttribute();
break;
default:
break;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
*/
public class AnsiConsoleExample {

private AnsiConsoleExample() {}

public static void main(String[] args) throws IOException {
String file = "src/test/resources/jansi.ans";
if( args.length>0 )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
*/
public class AnsiConsoleExample2 {

private AnsiConsoleExample2() {}

public static void main(String[] args) throws IOException {
String file = "src/test/resources/jansi.ans";
if( args.length>0 )
Expand Down

0 comments on commit 1f0e856

Please sign in to comment.