Skip to content

Commit dac9d8d

Browse files
committed
Merge pull request #212 from georgekankava/staging/string-literals-should-not-be-duplicated-fix-2
squid:S1192 - String literals should not be duplicated
2 parents 5dabcb1 + ac0ee9a commit dac9d8d

File tree

4 files changed

+29
-22
lines changed

4 files changed

+29
-22
lines changed

src/main/java/net/sf/jsqlparser/util/AddAliasesVisitor.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
*/
3838
public class AddAliasesVisitor implements SelectVisitor, SelectItemVisitor {
3939

40+
private static final String NOT_SUPPORTED_YET = "Not supported yet.";
4041
private List<String> aliases = new LinkedList<String>();
4142
private boolean firstRun = true;
4243
private int counter = 0;
@@ -65,7 +66,7 @@ public void visit(SetOperationList setOpList) {
6566

6667
@Override
6768
public void visit(AllTableColumns allTableColumns) {
68-
throw new UnsupportedOperationException("Not supported yet.");
69+
throw new UnsupportedOperationException(NOT_SUPPORTED_YET);
6970
}
7071

7172
@Override
@@ -110,11 +111,11 @@ public void setPrefix(String prefix) {
110111

111112
@Override
112113
public void visit(WithItem withItem) {
113-
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
114+
throw new UnsupportedOperationException(NOT_SUPPORTED_YET); //To change body of generated methods, choose Tools | Templates.
114115
}
115116

116117
@Override
117118
public void visit(AllColumns allColumns) {
118-
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
119+
throw new UnsupportedOperationException(NOT_SUPPORTED_YET); //To change body of generated methods, choose Tools | Templates.
119120
}
120121
}

src/main/java/net/sf/jsqlparser/util/SelectUtils.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import java.util.ArrayList;
2525
import java.util.Arrays;
2626
import java.util.List;
27+
2728
import net.sf.jsqlparser.JSQLParserException;
2829
import net.sf.jsqlparser.expression.Expression;
2930
import net.sf.jsqlparser.parser.CCJSqlParserUtil;
@@ -46,6 +47,8 @@
4647
*/
4748
public final class SelectUtils {
4849

50+
private static final String NOT_SUPPORTED_YET = "Not supported yet.";
51+
4952
private SelectUtils() {
5053
}
5154

@@ -113,12 +116,12 @@ public void visit(PlainSelect plainSelect) {
113116

114117
@Override
115118
public void visit(SetOperationList setOpList) {
116-
throw new UnsupportedOperationException("Not supported yet.");
119+
throw new UnsupportedOperationException(NOT_SUPPORTED_YET);
117120
}
118121

119122
@Override
120123
public void visit(WithItem withItem) {
121-
throw new UnsupportedOperationException("Not supported yet.");
124+
throw new UnsupportedOperationException(NOT_SUPPORTED_YET);
122125
}
123126
});
124127
}
@@ -145,7 +148,7 @@ public static Join addJoin(Select select, final Table table, final Expression on
145148
joins.add(join);
146149
return join;
147150
}
148-
throw new UnsupportedOperationException("Not supported yet.");
151+
throw new UnsupportedOperationException(NOT_SUPPORTED_YET);
149152
}
150153

151154
/**
@@ -163,12 +166,12 @@ public void visit(PlainSelect plainSelect) {
163166

164167
@Override
165168
public void visit(SetOperationList setOpList) {
166-
throw new UnsupportedOperationException("Not supported yet.");
169+
throw new UnsupportedOperationException(NOT_SUPPORTED_YET);
167170
}
168171

169172
@Override
170173
public void visit(WithItem withItem) {
171-
throw new UnsupportedOperationException("Not supported yet.");
174+
throw new UnsupportedOperationException(NOT_SUPPORTED_YET);
172175
}
173176
});
174177
}

src/main/java/net/sf/jsqlparser/util/TablesNamesFinder.java

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636

3737
import java.util.ArrayList;
3838
import java.util.List;
39+
3940
import net.sf.jsqlparser.statement.SetStatement;
4041
import net.sf.jsqlparser.statement.StatementVisitor;
4142
import net.sf.jsqlparser.statement.Statements;
@@ -53,7 +54,8 @@
5354
*/
5455
public class TablesNamesFinder implements SelectVisitor, FromItemVisitor, ExpressionVisitor, ItemsListVisitor, SelectItemVisitor, StatementVisitor {
5556

56-
private List<String> tables;
57+
private static final String NOT_SUPPORTED_YET = "Not supported yet.";
58+
private List<String> tables;
5759
/**
5860
* There are special names, that are not table names but are parsed as
5961
* tables. These names are collected here and are not included in the tables
@@ -573,17 +575,17 @@ public void visit(Replace replace) {
573575

574576
@Override
575577
public void visit(Drop drop) {
576-
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
578+
throw new UnsupportedOperationException(NOT_SUPPORTED_YET); //To change body of generated methods, choose Tools | Templates.
577579
}
578580

579581
@Override
580582
public void visit(Truncate truncate) {
581-
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
583+
throw new UnsupportedOperationException(NOT_SUPPORTED_YET); //To change body of generated methods, choose Tools | Templates.
582584
}
583585

584586
@Override
585587
public void visit(CreateIndex createIndex) {
586-
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
588+
throw new UnsupportedOperationException(NOT_SUPPORTED_YET); //To change body of generated methods, choose Tools | Templates.
587589
}
588590

589591
@Override
@@ -596,27 +598,27 @@ public void visit(CreateTable create) {
596598

597599
@Override
598600
public void visit(CreateView createView) {
599-
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
601+
throw new UnsupportedOperationException(NOT_SUPPORTED_YET); //To change body of generated methods, choose Tools | Templates.
600602
}
601603

602604
@Override
603605
public void visit(Alter alter) {
604-
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
606+
throw new UnsupportedOperationException(NOT_SUPPORTED_YET); //To change body of generated methods, choose Tools | Templates.
605607
}
606608

607609
@Override
608610
public void visit(Statements stmts) {
609-
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
611+
throw new UnsupportedOperationException(NOT_SUPPORTED_YET); //To change body of generated methods, choose Tools | Templates.
610612
}
611613

612614
@Override
613615
public void visit(Execute execute) {
614-
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
616+
throw new UnsupportedOperationException(NOT_SUPPORTED_YET); //To change body of generated methods, choose Tools | Templates.
615617
}
616618

617619
@Override
618620
public void visit(SetStatement set) {
619-
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
621+
throw new UnsupportedOperationException(NOT_SUPPORTED_YET); //To change body of generated methods, choose Tools | Templates.
620622
}
621623

622624
@Override
@@ -633,7 +635,7 @@ public void visit(HexValue hexValue) {
633635

634636
@Override
635637
public void visit(Merge merge) {
636-
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
638+
throw new UnsupportedOperationException(NOT_SUPPORTED_YET); //To change body of generated methods, choose Tools | Templates.
637639
}
638640

639641
@Override

src/main/java/net/sf/jsqlparser/util/deparser/ExpressionDeParser.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@
3838
*/
3939
public class ExpressionDeParser implements ExpressionVisitor, ItemsListVisitor {
4040

41-
private StringBuilder buffer;
41+
private static final String NOT = " NOT ";
42+
private StringBuilder buffer;
4243
private SelectVisitor selectVisitor;
4344
private boolean useBracketsInExprList = true;
4445

@@ -119,7 +120,7 @@ public void visit(HexValue hexValue) {
119120

120121
public void visitOldOracleJoinBinaryExpression(OldOracleJoinBinaryExpression expression, String operator) {
121122
if (expression.isNot()) {
122-
buffer.append(" NOT ");
123+
buffer.append(NOT);
123124
}
124125
expression.getLeftExpression().accept(this);
125126
if (expression.getOldOracleJoinSyntax() == EqualsTo.ORACLE_JOIN_RIGHT) {
@@ -250,7 +251,7 @@ public void visit(OrExpression orExpression) {
250251
@Override
251252
public void visit(Parenthesis parenthesis) {
252253
if (parenthesis.isNot()) {
253-
buffer.append(" NOT ");
254+
buffer.append(NOT);
254255
}
255256

256257
buffer.append("(");
@@ -273,7 +274,7 @@ public void visit(Subtraction subtraction) {
273274

274275
private void visitBinaryExpression(BinaryExpression binaryExpression, String operator) {
275276
if (binaryExpression.isNot()) {
276-
buffer.append(" NOT ");
277+
buffer.append(NOT);
277278
}
278279
binaryExpression.getLeftExpression().accept(this);
279280
buffer.append(operator);

0 commit comments

Comments
 (0)