Skip to content

Commit 537bd16

Browse files
author
Vincent Potucek
committed
[PoC] Add error-prone.picnic.tech featuring RedundantStringConversion
1 parent fb0518c commit 537bd16

File tree

68 files changed

+349
-148
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+349
-148
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,8 @@ jobs:
172172
fi
173173
- name: Verify license file
174174
run: python committer-tools/verify_license.py --skip-build
175+
- name: rewriteDryRun
176+
run: ./gradlew --build-cache rewriteDryRun
175177

176178
test:
177179
needs: [configure, validate, load-catalog]

build.gradle

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,14 @@ plugins {
4040
id "com.github.spotbugs" version '6.2.3' apply false
4141
id 'org.scoverage' version '8.0.3' apply false
4242
id 'com.gradleup.shadow' version '8.3.6' apply false
43-
id 'com.diffplug.spotless' version "6.25.0"
43+
id 'com.diffplug.spotless' version "8.0.0"
44+
id 'org.openrewrite.rewrite' version '7.17.0' apply false
45+
id 'net.ltgt.errorprone' version '4.3.0' apply false
46+
}
47+
48+
apply from: rootProject.file('gradle/rewrite.gradle')
49+
allprojects {
50+
apply from: rootProject.file('gradle/error-prone.gradle')
4451
}
4552

4653
ext {
@@ -855,6 +862,7 @@ subprojects {
855862
targetExclude('**/generated/**/*.java','**/generated-test/**/*.java')
856863
importOrder('kafka', 'org.apache.kafka', 'com', 'net', 'org', 'java', 'javax', '', '\\#')
857864
removeUnusedImports()
865+
// forbidWildcardImports()
858866
}
859867
}
860868
}

clients/src/main/java/org/apache/kafka/clients/consumer/internals/AbstractStickyAssignor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ private boolean isSticky() {
387387
if (hasCycles(topicMovementPairs)) {
388388
log.error("Stickiness is violated for topic {}"
389389
+ "\nPartition movements for this topic occurred among the following consumer pairs:"
390-
+ "\n{}", topicMovements.getKey(), topicMovements.getValue().toString());
390+
+ "\n{}", topicMovements.getKey(), topicMovements.getValue());
391391
return false;
392392
}
393393
}

clients/src/main/java/org/apache/kafka/clients/producer/RecordMetadata.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,6 @@ public int partition() {
119119

120120
@Override
121121
public String toString() {
122-
return topicPartition.toString() + "@" + offset;
122+
return topicPartition + "@" + offset;
123123
}
124124
}

clients/src/main/java/org/apache/kafka/common/metrics/Metrics.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ public MetricName metricInstance(MetricNameTemplate template, Map<String, String
661661

662662
if (!runtimeTagKeys.equals(templateTagKeys)) {
663663
throw new IllegalArgumentException("For '" + template.name() + "', runtime-defined metric tags do not match the tags in the template. "
664-
+ "Runtime = " + runtimeTagKeys + " Template = " + templateTagKeys.toString());
664+
+ "Runtime = " + runtimeTagKeys + " Template = " + templateTagKeys);
665665
}
666666

667667
return this.metricName(template.name(), template.group(), template.description(), tags);

clients/src/main/java/org/apache/kafka/common/metrics/internals/IntGaugeSuite.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ public void increment(K key) {
167167
synchronized (this) {
168168
if (closed) {
169169
log.warn("{}: Attempted to increment {}, but the GaugeSuite was closed.",
170-
suiteName, key.toString());
170+
suiteName, key);
171171
return;
172172
}
173173
StoredIntGauge gauge = gauges.get(key);
@@ -181,7 +181,7 @@ public void increment(K key) {
181181
if (gauges.size() == maxEntries) {
182182
if (removable.isEmpty()) {
183183
log.debug("{}: Attempted to increment {}, but there are already {} entries.",
184-
suiteName, key.toString(), maxEntries);
184+
suiteName, key, maxEntries);
185185
return;
186186
}
187187
Iterator<K> iter = removable.iterator();
@@ -191,13 +191,13 @@ public void increment(K key) {
191191
gauges.remove(keyToRemove);
192192
pending.push(new PendingMetricsChange(metricNameToRemove, null));
193193
log.trace("{}: Removing the metric {}, which has a value of 0.",
194-
suiteName, keyToRemove.toString());
194+
suiteName, keyToRemove);
195195
}
196196
MetricName metricNameToAdd = metricNameCalculator.apply(key);
197197
gauge = new StoredIntGauge(metricNameToAdd);
198198
gauges.put(key, gauge);
199199
pending.push(new PendingMetricsChange(metricNameToAdd, gauge));
200-
log.trace("{}: Adding a new metric {}.", suiteName, key.toString());
200+
log.trace("{}: Adding a new metric {}.", suiteName, key);
201201
}
202202
// Drop the object monitor and perform any pending metrics additions or removals.
203203
performPendingMetricsOperations();
@@ -236,17 +236,17 @@ private void performPendingMetricsOperations() {
236236
public synchronized void decrement(K key) {
237237
if (closed) {
238238
log.warn("{}: Attempted to decrement {}, but the gauge suite was closed.",
239-
suiteName, key.toString());
239+
suiteName, key);
240240
return;
241241
}
242242
StoredIntGauge gauge = gauges.get(key);
243243
if (gauge == null) {
244244
log.debug("{}: Attempted to decrement {}, but no such metric was registered.",
245-
suiteName, key.toString());
245+
suiteName, key);
246246
} else {
247247
int cur = gauge.decrement();
248248
log.trace("{}: Removed a reference to {}. {} reference(s) remaining.",
249-
suiteName, key.toString(), cur);
249+
suiteName, key, cur);
250250
if (cur <= 0) {
251251
removable.add(key);
252252
}

clients/src/main/java/org/apache/kafka/common/protocol/MessageUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public static String deepToString(Iterator<?> iter) {
5757
while (iter.hasNext()) {
5858
Object object = iter.next();
5959
bld.append(prefix);
60-
bld.append(object.toString());
60+
bld.append(object);
6161
prefix = ", ";
6262
}
6363
bld.append("]");

clients/src/main/java/org/apache/kafka/common/protocol/types/Schema.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ public String toString() {
181181
StringBuilder b = new StringBuilder();
182182
b.append('{');
183183
for (int i = 0; i < this.fields.length; i++) {
184-
b.append(this.fields[i].toString());
184+
b.append(this.fields[i]);
185185
if (i < this.fields.length - 1)
186186
b.append(',');
187187
}

clients/src/main/java/org/apache/kafka/common/protocol/types/TaggedFields.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ public String toString() {
138138
for (Map.Entry<Integer, Field> field : fields.entrySet()) {
139139
bld.append(prefix);
140140
prefix = ", ";
141-
bld.append(field.getKey()).append(" -> ").append(field.getValue().toString());
141+
bld.append(field.getKey()).append(" -> ").append(field.getValue());
142142
}
143143
bld.append(")");
144144
return bld.toString();

clients/src/main/java/org/apache/kafka/common/security/plain/internals/PlainSaslServer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ public SaslServer createSaslServer(String mechanism, String protocol, String ser
182182
throws SaslException {
183183

184184
if (!PLAIN_MECHANISM.equals(mechanism))
185-
throw new SaslException(String.format("Mechanism \'%s\' is not supported. Only PLAIN is supported.", mechanism));
185+
throw new SaslException(String.format("Mechanism '%s' is not supported. Only PLAIN is supported.", mechanism));
186186

187187
return new PlainSaslServer(cbh);
188188
}

0 commit comments

Comments
 (0)