Skip to content

Commit 3c9bcb4

Browse files
Refactor: Replace .size() == 0 or .length() > 0 etc checks with .isEmpty()
1 parent 6efee97 commit 3c9bcb4

22 files changed

+34
-34
lines changed

src/sqlancer/clickhouse/ast/constant/ClickHouseStringConstant.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public String toString() {
3232

3333
@Override
3434
public boolean asBooleanNotNull() {
35-
return value.length() > 0;
35+
return !value.isEmpty();
3636
}
3737

3838
@Override

src/sqlancer/cnosdb/CnosDBLoggableFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ protected Loggable createLoggable(String input, String suffix) {
1919
if (!input.endsWith(";")) {
2020
completeString += ";";
2121
}
22-
if (suffix != null && suffix.length() != 0) {
22+
if (suffix != null && !suffix.isEmpty()) {
2323
completeString += suffix;
2424
}
2525
return new LoggedString(completeString);

src/sqlancer/cnosdb/CnosDBToStringVisitor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ public void visit(CnosDBSelect s) {
137137
sb.append(" WHERE ");
138138
visit(s.getWhereClause());
139139
}
140-
if (s.getGroupByExpressions().size() > 0) {
140+
if (!s.getGroupByExpressions().isEmpty()) {
141141
sb.append(" GROUP BY ");
142142
visit(s.getGroupByExpressions());
143143
}

src/sqlancer/cockroachdb/gen/CockroachDBExpressionGenerator.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ public String generateUnoptimizedQueryString(CockroachDBSelect select, Cockroach
457457

458458
@Override
459459
public List<CockroachDBExpression> generateFetchColumns(boolean shouldCreateDummy) {
460-
if (shouldCreateDummy || columns.size() == 0) {
460+
if (shouldCreateDummy || columns.isEmpty()) {
461461
return List.of(new CockroachDBColumnReference(new CockroachDBColumn("*", null, false, false)));
462462
}
463463
return Randomly.nonEmptySubset(columns).stream().map(c -> new CockroachDBColumnReference(c))
@@ -541,7 +541,7 @@ boolean mutateWhere(CockroachDBSelect select) {
541541
}
542542

543543
boolean mutateGroupBy(CockroachDBSelect select) {
544-
boolean increase = select.getGroupByExpressions().size() > 0;
544+
boolean increase = !select.getGroupByExpressions().isEmpty();
545545
if (increase) {
546546
select.clearGroupByExpressions();
547547
} else {
@@ -551,7 +551,7 @@ boolean mutateGroupBy(CockroachDBSelect select) {
551551
}
552552

553553
boolean mutateHaving(CockroachDBSelect select) {
554-
if (select.getGroupByExpressions().size() == 0) {
554+
if (select.getGroupByExpressions().isEmpty()) {
555555
select.setGroupByExpressions(select.getFetchColumns());
556556
select.setHavingClause(generateExpression(CockroachDBDataType.BOOL.get()));
557557
return false;

src/sqlancer/cockroachdb/oracle/CockroachDBCERTOracle.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ protected boolean mutateWhere() {
177177

178178
@Override
179179
protected boolean mutateGroupBy() {
180-
boolean increase = select.getGroupByExpressions().size() > 0;
180+
boolean increase = !select.getGroupByExpressions().isEmpty();
181181
if (increase) {
182182
select.clearGroupByExpressions();
183183
} else {
@@ -188,7 +188,7 @@ protected boolean mutateGroupBy() {
188188

189189
@Override
190190
protected boolean mutateHaving() {
191-
if (select.getGroupByExpressions().size() == 0) {
191+
if (select.getGroupByExpressions().isEmpty()) {
192192
select.setGroupByExpressions(select.getFetchColumns());
193193
select.setHavingClause(gen.generateExpression(CockroachDBDataType.BOOL.get()));
194194
return false;

src/sqlancer/cockroachdb/oracle/tlp/CockroachDBTLPBase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public void check() throws SQLException {
5656

5757
List<CockroachDBExpression> generateFetchColumns() {
5858
List<CockroachDBExpression> columns = new ArrayList<>();
59-
if (Randomly.getBoolean() || targetTables.getColumns().size() == 0) {
59+
if (Randomly.getBoolean() || targetTables.getColumns().isEmpty()) {
6060
columns.add(new CockroachDBColumnReference(new CockroachDBColumn("*", null, false, false)));
6161
} else {
6262
columns.addAll(Randomly.nonEmptySubset(targetTables.getColumns()).stream()

src/sqlancer/common/log/SQLLoggableFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ protected Loggable createLoggable(String input, String suffix) {
1616
}
1717
completeString = completeString.replace("\n", "\\n");
1818
completeString = completeString.replace("\r", "\\r");
19-
if (suffix != null && suffix.length() != 0) {
19+
if (suffix != null && !suffix.isEmpty()) {
2020
completeString += suffix;
2121
}
2222
return new LoggedString(completeString);

src/sqlancer/doris/gen/DorisDropViewGenerator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ private DorisDropViewGenerator() {
1111
}
1212

1313
public static SQLQueryAdapter dropView(DorisGlobalState globalState) {
14-
if (globalState.getSchema().getTables(t -> t.isView()).size() == 0) {
14+
if (globalState.getSchema().getTables(t -> t.isView()).isEmpty()) {
1515
throw new IgnoreMeException();
1616
}
1717
StringBuilder sb = new StringBuilder("DROP VIEW ");

src/sqlancer/mariadb/ast/MariaDBStringVisitor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public void visit(MariaDBSelectStatement s) {
5454
sb.append(" WHERE ");
5555
visit(s.getWhereCondition());
5656
}
57-
if (s.getGroupBys().size() != 0) {
57+
if (!s.getGroupBys().isEmpty()) {
5858
sb.append(" GROUP BY ");
5959
for (i = 0; i < s.getGroupBys().size(); i++) {
6060
if (i != 0) {

src/sqlancer/materialize/MaterializeToStringVisitor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ public void visit(MaterializeSelect s) {
139139
sb.append(" WHERE ");
140140
visit(s.getWhereClause());
141141
}
142-
if (s.getGroupByExpressions().size() > 0) {
142+
if (!s.getGroupByExpressions().isEmpty()) {
143143
sb.append(" GROUP BY ");
144144
visit(s.getGroupByExpressions());
145145
}

0 commit comments

Comments
 (0)