Skip to content

Commit

Permalink
More Sonar complaints fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
fathzer committed Sep 2, 2024
1 parent 1088673 commit 0c6fd20
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,8 @@ public class ConstantTableModel extends AbstractTableModel {

public ConstantTableModel(Collection<Constant> collection) {
this.constants = new ArrayList<>(collection);
Collections.sort(this.constants, new Comparator<Constant>() {
public int compare(Constant c1, Constant c2) {
return c1.getName().compareTo(c2.getName());
}
});
final Comparator<Constant> cmp = (c1, c2) -> c1.getName().compareTo(c2.getName());
Collections.sort(this.constants, cmp);
}

public int getColumnCount() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public void testExtended() {
ExtendedDoubleEvaluator evaluator = new ExtendedDoubleEvaluator();
// Test that all this stuff is ok
String expression = "sqrt(abs(-2))^2";
assertEquals(2, evaluator.evaluate(expression), 0.00001);;
assertEquals(2, evaluator.evaluate(expression), 0.00001);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ protected Iterator<String> tokenize(String expression) {
if (supportsScientificNotation) {
// There's a trap with scientific number notation (1E+50 for example):
// + is considered as an operator. We'll make a basic work around...
final List<String> tokens = new ArrayList<String>();
final List<String> tokens = new ArrayList<>();
final Iterator<String> rawTokens = super.tokenize(expression);
while (rawTokens.hasNext()) {
tokens.add(rawTokens.next());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ public class Parameters {
* <br>Function argument separator is set to ','.
*/
public Parameters() {
this.operators = new ArrayList<Operator>();
this.functions = new ArrayList<Function>();
this.constants = new ArrayList<Constant>();
this.translations = new HashMap<String, String>();
this.expressionBrackets = new ArrayList<BracketPair>();
this.functionBrackets = new ArrayList<BracketPair>();
this.operators = new ArrayList<>();
this.functions = new ArrayList<>();
this.constants = new ArrayList<>();
this.translations = new HashMap<>();
this.expressionBrackets = new ArrayList<>();
this.functionBrackets = new ArrayList<>();
setFunctionArgumentSeparator(',');
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ private DoubleEvaluator buildEvaluator() {
params.addExpressionBracket(BracketPair.PARENTHESES);
params.addExpressionBracket(BracketPair.BRACKETS);
params.addFunctionBracket(BracketPair.ANGLES);
DoubleEvaluator eval = new DoubleEvaluator(params);
return eval;
return new DoubleEvaluator(params);
}

@Test (expected=IllegalArgumentException.class)
Expand Down

0 comments on commit 0c6fd20

Please sign in to comment.