Skip to content

Commit 2eca496

Browse files
committed
Enable ErrorProne FormatStringShouldUsePlaceholders
1 parent 5e25a79 commit 2eca496

File tree

34 files changed

+69
-58
lines changed

34 files changed

+69
-58
lines changed

client/trino-client/src/test/java/io/trino/client/auth/external/TestExternalAuthenticator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ public ConcurrentRequestAssertion(List<Future<Request>> requests)
347347
exceptions.add(ex);
348348
}
349349
catch (ExecutionException ex) {
350-
checkState(ex.getCause() != null, "Missing cause on ExecutionException " + ex.getMessage());
350+
checkState(ex.getCause() != null, "Missing cause on ExecutionException %s", ex.getMessage());
351351

352352
exceptions.add(ex.getCause());
353353
}

client/trino-jdbc/src/test/java/io/trino/jdbc/TestJdbcPreparedStatement.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1495,14 +1495,14 @@ private BindAssertion assertBind(Binder binder, boolean explicitPrepare)
14951495
private Connection createConnection(boolean explicitPrepare)
14961496
throws SQLException
14971497
{
1498-
String url = format("jdbc:trino://%s?explicitPrepare=" + explicitPrepare, server.getAddress());
1498+
String url = format("jdbc:trino://%s?explicitPrepare=%s", server.getAddress(), explicitPrepare);
14991499
return DriverManager.getConnection(url, "test", null);
15001500
}
15011501

15021502
private Connection createConnection(String catalog, String schema, boolean explicitPrepare)
15031503
throws SQLException
15041504
{
1505-
String url = format("jdbc:trino://%s/%s/%s?explicitPrepare=" + explicitPrepare, server.getAddress(), catalog, schema);
1505+
String url = format("jdbc:trino://%s/%s/%s?explicitPrepare=%s", server.getAddress(), catalog, schema, explicitPrepare);
15061506
return DriverManager.getConnection(url, "test", null);
15071507
}
15081508

core/trino-main/src/main/java/io/trino/memory/KillTarget.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public QueryId getQuery()
6666

6767
public Set<TaskId> getTasks()
6868
{
69-
checkState(!tasks.isEmpty(), "tasks not set in KillTarget: " + this);
69+
checkState(!tasks.isEmpty(), "tasks not set in KillTarget: %s", this);
7070
return tasks;
7171
}
7272

core/trino-main/src/main/java/io/trino/operator/aggregation/state/StateCompiler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1098,7 +1098,7 @@ else if (annotation instanceof InitialBooleanValue initialValue) {
10981098

10991099
private static void checkInterface(Class<?> clazz, List<StateField> fields)
11001100
{
1101-
checkArgument(clazz.isInterface(), clazz.getName() + " is not an interface");
1101+
checkArgument(clazz.isInterface(), "%s is not an interface", clazz.getName());
11021102
Set<String> setters = new HashSet<>();
11031103
Set<String> getters = new HashSet<>();
11041104
Set<String> isGetters = new HashSet<>();

core/trino-main/src/main/java/io/trino/sql/analyzer/ExpressionAnalyzer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1349,7 +1349,7 @@ else if (isAggregation) {
13491349

13501350
if (node.getWindow().isPresent()) {
13511351
ResolvedWindow window = getResolvedWindow.apply(node);
1352-
checkState(window != null, "no resolved window for: " + node);
1352+
checkState(window != null, "no resolved window for: %s", node);
13531353

13541354
analyzeWindow(window, context.inWindow(), (Node) node.getWindow().get());
13551355
windowFunctions.add(NodeRef.of(node));
@@ -1710,7 +1710,7 @@ private void analyzeFrameRangeOffset(Expression offsetValue, FrameBound.Type bou
17101710
protected Type visitWindowOperation(WindowOperation node, Context context)
17111711
{
17121712
ResolvedWindow window = getResolvedWindow.apply(node);
1713-
checkState(window != null, "no resolved window for: " + node);
1713+
checkState(window != null, "no resolved window for: %s", node);
17141714

17151715
if (window.getFrame().isEmpty()) {
17161716
throw semanticException(INVALID_WINDOW_MEASURE, node, "Measure %s is not defined in the corresponding window", node.getName().getValue());

core/trino-main/src/main/java/io/trino/sql/analyzer/JsonPathAnalyzer.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ protected Type visitFilter(Filter node, Void context)
292292
Type predicateType = process(node.getPredicate());
293293

294294
requireNonNull(predicateType, "missing type of predicate expression");
295-
checkState(predicateType.equals(BOOLEAN), "invalid type of predicate expression: " + predicateType.getDisplayName());
295+
checkState(predicateType.equals(BOOLEAN), "invalid type of predicate expression: %s", predicateType.getDisplayName());
296296

297297
if (sourceType != null) {
298298
types.put(PathNodeRef.of(node), sourceType);
@@ -435,11 +435,11 @@ protected Type visitConjunctionPredicate(ConjunctionPredicate node, Void context
435435
{
436436
Type leftType = process(node.getLeft());
437437
requireNonNull(leftType, "missing type of predicate expression");
438-
checkState(leftType.equals(BOOLEAN), "invalid type of predicate expression: " + leftType.getDisplayName());
438+
checkState(leftType.equals(BOOLEAN), "invalid type of predicate expression: %s", leftType.getDisplayName());
439439

440440
Type rightType = process(node.getRight());
441441
requireNonNull(rightType, "missing type of predicate expression");
442-
checkState(rightType.equals(BOOLEAN), "invalid type of predicate expression: " + rightType.getDisplayName());
442+
checkState(rightType.equals(BOOLEAN), "invalid type of predicate expression: %s", rightType.getDisplayName());
443443

444444
types.put(PathNodeRef.of(node), BOOLEAN);
445445
return BOOLEAN;
@@ -450,11 +450,11 @@ protected Type visitDisjunctionPredicate(DisjunctionPredicate node, Void context
450450
{
451451
Type leftType = process(node.getLeft());
452452
requireNonNull(leftType, "missing type of predicate expression");
453-
checkState(leftType.equals(BOOLEAN), "invalid type of predicate expression: " + leftType.getDisplayName());
453+
checkState(leftType.equals(BOOLEAN), "invalid type of predicate expression: %s", leftType.getDisplayName());
454454

455455
Type rightType = process(node.getRight());
456456
requireNonNull(rightType, "missing type of predicate expression");
457-
checkState(rightType.equals(BOOLEAN), "invalid type of predicate expression: " + rightType.getDisplayName());
457+
checkState(rightType.equals(BOOLEAN), "invalid type of predicate expression: %s", rightType.getDisplayName());
458458

459459
types.put(PathNodeRef.of(node), BOOLEAN);
460460
return BOOLEAN;
@@ -483,7 +483,7 @@ protected Type visitNegationPredicate(NegationPredicate node, Void context)
483483
{
484484
Type predicateType = process(node.getPredicate());
485485
requireNonNull(predicateType, "missing type of predicate expression");
486-
checkState(predicateType.equals(BOOLEAN), "invalid type of predicate expression: " + predicateType.getDisplayName());
486+
checkState(predicateType.equals(BOOLEAN), "invalid type of predicate expression: %s", predicateType.getDisplayName());
487487

488488
types.put(PathNodeRef.of(node), BOOLEAN);
489489
return BOOLEAN;
@@ -503,7 +503,7 @@ protected Type visitIsUnknownPredicate(IsUnknownPredicate node, Void context)
503503
{
504504
Type predicateType = process(node.getPredicate());
505505
requireNonNull(predicateType, "missing type of predicate expression");
506-
checkState(predicateType.equals(BOOLEAN), "invalid type of predicate expression: " + predicateType.getDisplayName());
506+
checkState(predicateType.equals(BOOLEAN), "invalid type of predicate expression: %s", predicateType.getDisplayName());
507507

508508
types.put(PathNodeRef.of(node), BOOLEAN);
509509
return BOOLEAN;

core/trino-main/src/main/java/io/trino/sql/analyzer/StatementAnalyzer.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5874,7 +5874,7 @@ private void analyzeOffset(Offset node, Scope scope)
58745874
rowCount = ((LongLiteral) node.getRowCount()).getParsedValue();
58755875
}
58765876
else {
5877-
checkState(node.getRowCount() instanceof Parameter, "unexpected OFFSET rowCount: " + node.getRowCount().getClass().getSimpleName());
5877+
checkState(node.getRowCount() instanceof Parameter, "unexpected OFFSET rowCount: %s", node.getRowCount().getClass().getSimpleName());
58785878
OptionalLong providedValue = analyzeParameterAsRowCount((Parameter) node.getRowCount(), scope, "OFFSET");
58795879
rowCount = providedValue.orElse(0);
58805880
}
@@ -5908,7 +5908,7 @@ private boolean analyzeLimit(FetchFirst node, Scope scope)
59085908
rowCount = longLiteral.getParsedValue();
59095909
}
59105910
else {
5911-
checkState(count instanceof Parameter, "unexpected FETCH FIRST rowCount: " + count.getClass().getSimpleName());
5911+
checkState(count instanceof Parameter, "unexpected FETCH FIRST rowCount: %s", count.getClass().getSimpleName());
59125912
OptionalLong providedValue = analyzeParameterAsRowCount((Parameter) count, scope, "FETCH FIRST");
59135913
if (providedValue.isPresent()) {
59145914
rowCount = providedValue.getAsLong();
@@ -5933,7 +5933,7 @@ else if (node.getRowCount() instanceof LongLiteral) {
59335933
rowCount = OptionalLong.of(((LongLiteral) node.getRowCount()).getParsedValue());
59345934
}
59355935
else {
5936-
checkState(node.getRowCount() instanceof Parameter, "unexpected LIMIT rowCount: " + node.getRowCount().getClass().getSimpleName());
5936+
checkState(node.getRowCount() instanceof Parameter, "unexpected LIMIT rowCount: %s", node.getRowCount().getClass().getSimpleName());
59375937
rowCount = analyzeParameterAsRowCount((Parameter) node.getRowCount(), scope, "LIMIT");
59385938
}
59395939
rowCount.ifPresent(count -> {

core/trino-main/src/main/java/io/trino/sql/planner/LocalExecutionPlanner.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -847,7 +847,7 @@ public void setDriverInstanceCount(int driverInstanceCount)
847847
{
848848
checkArgument(driverInstanceCount > 0, "driverInstanceCount must be > 0");
849849
if (this.driverInstanceCount.isPresent()) {
850-
checkState(this.driverInstanceCount.getAsInt() == driverInstanceCount, "driverInstance count already set to " + this.driverInstanceCount.getAsInt());
850+
checkState(this.driverInstanceCount.getAsInt() == driverInstanceCount, "driverInstance count already set to %s", this.driverInstanceCount.getAsInt());
851851
}
852852
this.driverInstanceCount = OptionalInt.of(driverInstanceCount);
853853
}

core/trino-main/src/main/java/io/trino/sql/planner/QueryPlanner.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1967,7 +1967,7 @@ private PlanBuilder planWindowMeasures(Node node, PlanBuilder subPlan, List<Wind
19671967

19681968
for (WindowOperation windowMeasure : scopeAwareDistinct(subPlan, windowMeasures)) {
19691969
ResolvedWindow window = analysis.getWindow(windowMeasure);
1970-
checkState(window != null, "no resolved window for: " + windowMeasure);
1970+
checkState(window != null, "no resolved window for: %s", windowMeasure);
19711971

19721972
// pre-project inputs
19731973
ImmutableList.Builder<io.trino.sql.tree.Expression> inputsBuilder = ImmutableList.<io.trino.sql.tree.Expression>builder()

core/trino-main/src/main/java/io/trino/sql/planner/iterative/IterativeOptimizer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ private boolean exploreChildren(int group, Context context, Set<PlanNodeId> chan
256256

257257
PlanNode expression = context.memo.getNode(group);
258258
for (PlanNode child : expression.getSources()) {
259-
checkState(child instanceof GroupReference, "Expected child to be a group reference. Found: " + child.getClass().getName());
259+
checkState(child instanceof GroupReference, "Expected child to be a group reference. Found: %s", child.getClass().getName());
260260

261261
if (exploreGroup(((GroupReference) child).getGroupId(), context, changedPlanNodeIds)) {
262262
progress = true;

0 commit comments

Comments
 (0)