Skip to content

Commit 6007835

Browse files
committed
code cleanup suggested by IntelliJ
also includes one bug fix for setting a byte value into a byte array for BASIC programs
1 parent 20a0eef commit 6007835

24 files changed

Lines changed: 33 additions & 48 deletions

src/main/java/com/scriptbasic/api/BasicFunction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
* properly function.
3434
* <p>
3535
* The different versions of ScriptBasic may provide different
36-
* functionalities for the methods registered as functions. When a method
36+
* functionality for the methods registered as functions. When a method
3737
* needs a specific interface version the interpreter may alter its
3838
* behavior.
3939
* <p>

src/main/java/com/scriptbasic/api/ScriptBasic.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,9 @@ default FunctionBuilder function(final String methodName) {
8787
*
8888
* @param input the input to set
8989
*/
90-
@Deprecated()
9190
void setInput(Reader input);
9291

9392
default ScriptBasic input(final Reader input) {
94-
//noinspection deprecation
9593
setInput(input);
9694
return this;
9795
}
@@ -110,11 +108,9 @@ default ScriptBasic input(final Reader input) {
110108
*
111109
* @param output parameter
112110
*/
113-
@Deprecated()
114111
void setOutput(Writer output);
115112

116113
default ScriptBasic output(final Writer output) {
117-
//noinspection deprecation
118114
setOutput(output);
119115
return this;
120116
}
@@ -133,11 +129,9 @@ default ScriptBasic output(final Writer output) {
133129
*
134130
* @param error the error output
135131
*/
136-
@Deprecated()
137132
void setErrorOutput(Writer error);
138133

139134
default ScriptBasic error(final Writer error) {
140-
//noinspection deprecation
141135
setErrorOutput(error);
142136
return this;
143137
}
@@ -443,7 +437,6 @@ private VariableBuilder(final String name, final ScriptBasic scriptBasic) {
443437
}
444438

445439
public ScriptBasic is(final Object value) throws ScriptBasicException {
446-
//noinspection deprecation
447440
scriptBasic.setVariable(name, value);
448441
return scriptBasic;
449442
}

src/main/java/com/scriptbasic/context/ContextBuilder.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public static Context from(final Context existing, final Reader reader, final Re
5353
return ctx;
5454
}
5555

56-
public static Context from(final String string) throws AnalysisException {
56+
public static Context from(final String string) {
5757
return from(null, string);
5858
}
5959

@@ -71,7 +71,7 @@ public static Context from(final Context existing, final Reader reader) {
7171
return from(existing, hReader);
7272
}
7373

74-
public static Context from(final SourceReader sourceReader, final Reader input, final Writer output, final Writer error) throws AnalysisException {
74+
public static Context from(final SourceReader sourceReader, final Reader input, final Writer output, final Writer error) {
7575
return from(null, sourceReader, input, output, error);
7676
}
7777

src/main/java/com/scriptbasic/executors/BasicMethodRegistry.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public Method getJavaMethod(final Class<?> klass, final String alias) {
3333
final var item = getRegistryItem(klass, alias);
3434
if (item == null) {
3535
method = null;
36-
} else {//TODO check why ntelliJ analysis says that this is always null
36+
} else {//TODO check why IntelliJ analysis says that this is always null
3737
if (item.method == null) {
3838
final Class<?>[] args = new Class[item.args.length + 1];
3939
args[0] = Interpreter.class;

src/main/java/com/scriptbasic/executors/commands/CommandCase.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,11 @@ public boolean matchCase(Interpreter interpreter, RightValue selectExpressionVal
8383
/**
8484
* List of case conditions to be evaluated
8585
*/
86-
private List<CaseCondition> expressionList = new ArrayList<>();
86+
private final List<CaseCondition> expressionList = new ArrayList<>();
8787
private CommandEndSelect commandEndSelect;
8888

8989
@Override
90-
public void execute(Interpreter interpreter) throws ScriptBasicException {
90+
public void execute(Interpreter interpreter) {
9191

9292
// Check if other case already applied
9393
Boolean caseApplied = (Boolean) interpreter.getMap().get(CommandSelect.CASE_APPLIED);

src/main/java/com/scriptbasic/executors/commands/CommandEndSelect.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public class CommandEndSelect
88
{
99

1010
@Override
11-
public void execute(Interpreter interpreter) throws ScriptBasicException {
11+
public void execute(Interpreter interpreter) {
1212
// do nothing
1313
}
1414

src/main/java/com/scriptbasic/executors/commands/CommandSelect.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public class CommandSelect extends AbstractCommandSelectPart {
2121
/**
2222
* List of possible cases
2323
*/
24-
private List<CommandCase> cases = new ArrayList<>();
24+
private final List<CommandCase> cases = new ArrayList<>();
2525

2626
public void setExpression(final Expression expression) {
2727
this.expression = expression;

src/main/java/com/scriptbasic/executors/operators/AbstractBinaryFullCircuitNumericOperator.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ protected abstract RightValue operateOnDoubleDouble(Double a, Double b)
1111
;
1212

1313
protected abstract RightValue operateOnDoubleLong(Double a, Long b)
14-
throws BasicRuntimeException;
14+
;
1515

1616
protected abstract RightValue operateOnLongDouble(Long a, Double b)
17-
throws BasicRuntimeException;
17+
;
1818

1919
protected abstract RightValue operateOnLongLong(Long a, Long b)
20-
throws BasicRuntimeException;
20+
;
2121

2222
protected RightValue operateOnValues(final RightValue leftOperand,
2323
final RightValue rightOperand) throws BasicRuntimeException {

src/main/java/com/scriptbasic/executors/operators/AmpersandOperator.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import com.scriptbasic.api.ScriptBasicException;
44
import com.scriptbasic.executors.rightvalues.BasicStringValue;
5-
import com.scriptbasic.interfaces.BasicRuntimeException;
65
import com.scriptbasic.spi.RightValue;
76

87
/**
@@ -24,8 +23,7 @@ protected RightValue evaluateOn(RightValue leftOperand, RightValue rightOperand)
2423
addOperand(sb, leftOperand);
2524
addOperand(sb, rightOperand);
2625

27-
BasicStringValue result = new BasicStringValue(sb.toString());
28-
return result;
26+
return new BasicStringValue(sb.toString());
2927
}
3028

3129
static private void addOperand(StringBuilder stringBuilder, RightValue operand) throws ScriptBasicException {

src/main/java/com/scriptbasic/executors/operators/JavaObjectFieldAccessOperator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ private static Object getArrayElement(final Object[] array, final Integer index)
4747
+ " < 0 as array index");
4848
}
4949
if (index >= array.length) {
50-
throw new BasicRuntimeException("Cann not use index" + index
50+
throw new BasicRuntimeException("Cannot use index" + index
5151
+ " > max index" + (array.length - 1) + " ");
5252
}
5353
return array[index];

0 commit comments

Comments
 (0)