Skip to content

Commit c3a5c9c

Browse files
author
Vincent Potucek
committed
[openrewrite] StringRulesRecipes
1 parent 16f79da commit c3a5c9c

File tree

44 files changed

+175
-169
lines changed

Some content is hidden

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

44 files changed

+175
-169
lines changed

lib-extra/src/main/java/com/diffplug/spotless/extra/EquoBasedStepBuilder.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import java.util.Collection;
2525
import java.util.List;
2626
import java.util.Map;
27-
import java.util.Optional;
27+
import java.util.Objects;
2828
import java.util.Properties;
2929

3030
import javax.annotation.Nullable;
@@ -127,7 +127,7 @@ public FormatterStep build() {
127127
var roundtrippableState = new EquoStep(formatterVersion, settingProperties, settingXml, FileSignature.promise(settingsFiles), JarState.promise(() -> {
128128
P2QueryResult query;
129129
try {
130-
if (null != cacheDirectory) {
130+
if (cacheDirectory != null) {
131131
CacheLocations.override_p2data = cacheDirectory.toPath().resolve("dev/equo/p2-data").toFile();
132132
}
133133
query = createModelWithMirrors().query(P2ClientCache.PREFER_OFFLINE, P2QueryCache.ALLOW);
@@ -190,8 +190,8 @@ static class EquoStep implements Serializable {
190190
ImmutableMap<String, String> stepProperties) {
191191

192192
this.semanticVersion = semanticVersion;
193-
this.settingProperties = Optional.ofNullable(settingProperties).orElse(new ArrayList<>());
194-
this.settingXml = Optional.ofNullable(settingXml).orElse(new ArrayList<>());
193+
this.settingProperties = Objects.requireNonNullElse(settingProperties, new ArrayList<>());
194+
this.settingXml = Objects.requireNonNullElse(settingXml, new ArrayList<>());
195195
this.settingsPromise = settingsPromise;
196196
this.jarPromise = jarPromise;
197197
this.stepProperties = stepProperties;
@@ -218,8 +218,8 @@ public static class State implements Serializable {
218218
public State(String semanticVersion, JarState jarState, List<String> settingProperties, List<String> settingXml, FileSignature settingsFiles, ImmutableMap<String, String> stepProperties) {
219219
this.semanticVersion = semanticVersion;
220220
this.jarState = jarState;
221-
this.settingProperties = Optional.ofNullable(settingProperties).orElse(new ArrayList<>());
222-
this.settingXml = Optional.ofNullable(settingXml).orElse(new ArrayList<>());
221+
this.settingProperties = Objects.requireNonNullElse(settingProperties, new ArrayList<>());
222+
this.settingXml = Objects.requireNonNullElse(settingXml, new ArrayList<>());
223223
this.settingsFiles = settingsFiles;
224224
this.stepProperties = stepProperties;
225225
}

lib-extra/src/main/java/com/diffplug/spotless/extra/GitAttributesLineEndings.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -337,10 +337,10 @@ private LineEnding findDefaultLineEnding(Config config) {
337337
private static LineEnding fromEol(EOL eol) {
338338
// @formatter:off
339339
switch (eol) {
340-
case CRLF: return LineEnding.WINDOWS;
341-
case LF: return LineEnding.UNIX;
342-
case NATIVE: return LineEnding.PLATFORM_NATIVE;
343-
default: throw new IllegalArgumentException("Unknown eol " + eol);
340+
case CRLF: return LineEnding.WINDOWS;
341+
case LF: return LineEnding.UNIX;
342+
case NATIVE: return LineEnding.PLATFORM_NATIVE;
343+
default: throw new IllegalArgumentException("Unknown eol " + eol);
344344
}
345345
// @formatter:on
346346
}

lib-extra/src/main/java/com/diffplug/spotless/extra/cpp/EclipseCdtFormatterStep.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ private static FormatterFunc apply(EquoBasedStepBuilder.State state) throws Exce
7070
} catch (InvocationTargetException exceptionWrapper) {
7171
Throwable throwable = exceptionWrapper.getTargetException();
7272
Exception exception = throwable instanceof Exception e ? e : null;
73-
throw null == exception ? exceptionWrapper : exception;
73+
throw exception == null ? exceptionWrapper : exception;
7474
}
7575
});
7676
}

lib-extra/src/main/java/com/diffplug/spotless/extra/groovy/GrEclipseFormatterStep.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ private static FormatterFunc apply(EquoBasedStepBuilder.State state) throws Exce
9696
} catch (InvocationTargetException exceptionWrapper) {
9797
Throwable throwable = exceptionWrapper.getTargetException();
9898
Exception exception = throwable instanceof Exception e ? e : null;
99-
throw null == exception ? exceptionWrapper : exception;
99+
throw exception == null ? exceptionWrapper : exception;
100100
}
101101
});
102102
}

lib-extra/src/main/java/com/diffplug/spotless/extra/wtp/EclipseWtpFormatterStep.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ private static FormatterFunc applyWithoutFile(String className, EclipseBasedStep
6868
} catch (InvocationTargetException exceptionWrapper) {
6969
Throwable throwable = exceptionWrapper.getTargetException();
7070
Exception exception = throwable instanceof Exception e ? e : null;
71-
throw null == exception ? exceptionWrapper : exception;
71+
throw exception == null ? exceptionWrapper : exception;
7272
}
7373
};
7474
}
@@ -86,7 +86,7 @@ public String applyWithFile(String unix, File file) throws Exception {
8686
} catch (InvocationTargetException exceptionWrapper) {
8787
Throwable throwable = exceptionWrapper.getTargetException();
8888
Exception exception = throwable instanceof Exception e ? e : null;
89-
throw null == exception ? exceptionWrapper : exception;
89+
throw exception == null ? exceptionWrapper : exception;
9090
}
9191
}
9292
});

lib/src/compatKtLint0Dot48Dot0/java/com/diffplug/spotless/glue/ktlint/compat/KtLintCompat0Dot48Dot0Adapter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2023-2024 DiffPlug
2+
* Copyright 2023-2025 DiffPlug
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

lib/src/compatKtLint0Dot49Dot0/java/com/diffplug/spotless/glue/ktlint/compat/KtLintCompat0Dot49Dot0Adapter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2023-2024 DiffPlug
2+
* Copyright 2023-2025 DiffPlug
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -137,7 +137,7 @@ public String format(
137137
editorConfigOverride = EditorConfigOverride.Companion.getEMPTY_EDITOR_CONFIG_OVERRIDE();
138138
} else {
139139
editorConfigOverride = createEditorConfigOverride(allRuleProviders.stream().map(
140-
RuleProvider::createNewRuleInstance).collect(Collectors.toList()),
140+
RuleProvider::createNewRuleInstance).toList(),
141141
editorConfigOverrideMap);
142142
}
143143
EditorConfigDefaults editorConfig;

lib/src/compatKtLint0Dot50Dot0/java/com/diffplug/spotless/glue/ktlint/compat/KtLintCompat0Dot50Dot0Adapter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2023-2024 DiffPlug
2+
* Copyright 2023-2025 DiffPlug
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -99,7 +99,7 @@ public String format(
9999
editorConfigOverride = EditorConfigOverride.Companion.getEMPTY_EDITOR_CONFIG_OVERRIDE();
100100
} else {
101101
editorConfigOverride = createEditorConfigOverride(allRuleProviders.stream().map(
102-
RuleProvider::createNewRuleInstance).collect(Collectors.toList()),
102+
RuleProvider::createNewRuleInstance).toList(),
103103
editorConfigOverrideMap);
104104
}
105105
EditorConfigDefaults editorConfig;

lib/src/compatKtLint1Dot0Dot0/java/com/diffplug/spotless/glue/ktlint/compat/KtLintCompat1Dot0Dot0Adapter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2023-2024 DiffPlug
2+
* Copyright 2023-2025 DiffPlug
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -100,7 +100,7 @@ public String format(
100100
} else {
101101
editorConfigOverride = createEditorConfigOverride(
102102
editorConfig,
103-
allRuleProviders.stream().map(RuleProvider::createNewRuleInstance).collect(Collectors.toList()),
103+
allRuleProviders.stream().map(RuleProvider::createNewRuleInstance).toList(),
104104
editorConfigOverrideMap);
105105
}
106106

lib/src/diktat/java/com/diffplug/spotless/glue/diktat/DiktatFormatterFunc.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2021-2024 DiffPlug
2+
* Copyright 2021-2025 DiffPlug
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,7 +16,6 @@
1616
package com.diffplug.spotless.glue.diktat;
1717

1818
import java.io.File;
19-
import java.util.stream.Collectors;
2019

2120
import com.diffplug.spotless.FormatterFunc;
2221
import com.diffplug.spotless.Lint;
@@ -46,7 +45,7 @@ public String applyWithFile(String unix, File file) {
4645
try {
4746
return adapter.format(file, unix, isScript);
4847
} catch (DiktatReporting.LintException e) {
49-
throw Lint.shortcut(e.lints.stream().map(lint -> Lint.atLine(lint.line, lint.ruleId, lint.detail)).collect(Collectors.toList()));
48+
throw Lint.shortcut(e.lints.stream().map(lint -> Lint.atLine(lint.line, lint.ruleId, lint.detail)).toList());
5049
}
5150
}
5251
}

0 commit comments

Comments
 (0)