Skip to content

Commit cfdc42f

Browse files
committed
Add spring code formatting plugin to the build
Closes: gh-1185 Signed-off-by: Andrey Litvitski <[email protected]>
1 parent a2424b7 commit cfdc42f

File tree

586 files changed

+11535
-11185
lines changed

Some content is hidden

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

586 files changed

+11535
-11185
lines changed

pom.xml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@
6161
<antora-maven-plugin.version>1.0.0-alpha.5</antora-maven-plugin.version>
6262

6363
<!-- plugin versions -->
64+
<spring-javaformat-maven-plugin.version>0.0.43</spring-javaformat-maven-plugin.version>
65+
<disable.format.checks>false</disable.format.checks>
6466
<maven-compiler-plugin.version>3.14.0</maven-compiler-plugin.version>
6567
<maven-surefire-plugin.version>3.5.3</maven-surefire-plugin.version>
6668
<maven-failsafe-plugin.version>3.5.3</maven-failsafe-plugin.version>
@@ -86,6 +88,23 @@
8688

8789
<build>
8890
<plugins>
91+
<plugin>
92+
<groupId>io.spring.javaformat</groupId>
93+
<artifactId>spring-javaformat-maven-plugin</artifactId>
94+
<version>${spring-javaformat-maven-plugin.version}</version>
95+
<executions>
96+
<execution>
97+
<phase>validate</phase>
98+
<inherited>true</inherited>
99+
<configuration>
100+
<skip>${disable.format.checks}</skip>
101+
</configuration>
102+
<goals>
103+
<goal>validate</goal>
104+
</goals>
105+
</execution>
106+
</executions>
107+
</plugin>
89108
<plugin>
90109
<groupId>org.apache.maven.plugins</groupId>
91110
<artifactId>maven-compiler-plugin</artifactId>

spring-shell-autoconfigure/src/main/java/org/springframework/shell/boot/ApplicationRunnerAutoConfiguration.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,15 @@ public ApplicationReadyEventListener applicationReadyEventListener() {
4444
return new ApplicationReadyEventListener();
4545
}
4646

47-
static class ApplicationReadyEventListener implements ApplicationListener<ApplicationReadyEvent>{
47+
static class ApplicationReadyEventListener implements ApplicationListener<ApplicationReadyEvent> {
4848

4949
@Override
5050
public void onApplicationEvent(ApplicationReadyEvent event) {
5151
// request context close after application runners so that
5252
// shell exits in case that context is kept alive
5353
event.getApplicationContext().close();
5454
}
55+
5556
}
57+
5658
}

spring-shell-autoconfigure/src/main/java/org/springframework/shell/boot/CommandCatalogAutoConfiguration.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ public class CommandCatalogAutoConfiguration {
4444
@ConditionalOnMissingBean(CommandCatalog.class)
4545
public CommandCatalog commandCatalog(ObjectProvider<MethodTargetRegistrar> methodTargetRegistrars,
4646
ObjectProvider<CommandResolver> commandResolvers,
47-
ObjectProvider<CommandCatalogCustomizer> commandCatalogCustomizers,
48-
ShellContext shellContext) {
47+
ObjectProvider<CommandCatalogCustomizer> commandCatalogCustomizers, ShellContext shellContext) {
4948
List<CommandResolver> resolvers = commandResolvers.orderedStream().collect(Collectors.toList());
5049
CommandCatalog catalog = CommandCatalog.of(resolvers, shellContext);
5150
methodTargetRegistrars.orderedStream().forEach(resolver -> {
@@ -58,7 +57,8 @@ public CommandCatalog commandCatalog(ObjectProvider<MethodTargetRegistrar> metho
5857
}
5958

6059
@Bean
61-
public CommandCatalogCustomizer defaultCommandCatalogCustomizer(ObjectProvider<CommandRegistration> commandRegistrations) {
60+
public CommandCatalogCustomizer defaultCommandCatalogCustomizer(
61+
ObjectProvider<CommandRegistration> commandRegistrations) {
6262
return catalog -> {
6363
commandRegistrations.orderedStream().forEach(registration -> {
6464
catalog.register(registration);
@@ -82,7 +82,8 @@ public CommandRegistrationCustomizer helpOptionsCommandRegistrationCustomizer(Sp
8282

8383
@Bean
8484
@ConditionalOnBean(OptionNameModifier.class)
85-
public CommandRegistrationCustomizer customOptionNameModifierCommandRegistrationCustomizer(OptionNameModifier modifier) {
85+
public CommandRegistrationCustomizer customOptionNameModifierCommandRegistrationCustomizer(
86+
OptionNameModifier modifier) {
8687
return builder -> {
8788
builder.defaultOptionNameModifier(modifier);
8889
};
@@ -91,7 +92,8 @@ public CommandRegistrationCustomizer customOptionNameModifierCommandRegistration
9192
@Bean
9293
@ConditionalOnMissingBean(OptionNameModifier.class)
9394
@ConditionalOnProperty(prefix = "spring.shell.option.naming", name = "case-type")
94-
public CommandRegistrationCustomizer defaultOptionNameModifierCommandRegistrationCustomizer(SpringShellProperties properties) {
95+
public CommandRegistrationCustomizer defaultOptionNameModifierCommandRegistrationCustomizer(
96+
SpringShellProperties properties) {
9597
return builder -> {
9698
switch (properties.getOption().getNaming().getCaseType()) {
9799
case NOOP:
@@ -124,4 +126,5 @@ public BuilderSupplier commandRegistrationBuilderSupplier(
124126
return builder;
125127
};
126128
}
129+
127130
}

spring-shell-autoconfigure/src/main/java/org/springframework/shell/boot/CommandRegistrationCustomizer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ public interface CommandRegistrationCustomizer {
2727

2828
/**
2929
* Callback to customize a {@link CommandRegistration.Builder} instance.
30-
*
3130
* @param commandRegistrationBuilder the command registration builder to customize
3231
*/
3332
void customize(CommandRegistration.Builder commandRegistrationBuilder);
33+
3434
}

spring-shell-autoconfigure/src/main/java/org/springframework/shell/boot/CompleterAutoConfiguration.java

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,19 +52,13 @@ public static class CompleterAdapter implements Completer {
5252
public void complete(LineReader reader, ParsedLine line, List<Candidate> candidates) {
5353
CompletingParsedLine cpl = (line instanceof CompletingParsedLine) ? ((CompletingParsedLine) line) : t -> t;
5454

55-
CompletionContext context = new CompletionContext(sanitizeInput(line.words()), line.wordIndex(), line.wordCursor(), null, null);
55+
CompletionContext context = new CompletionContext(sanitizeInput(line.words()), line.wordIndex(),
56+
line.wordCursor(), null, null);
5657

5758
List<CompletionProposal> proposals = shell.complete(context);
5859
proposals.stream()
59-
.map(p -> new Candidate(
60-
p.dontQuote() ? p.value() : cpl.emit(p.value()).toString(),
61-
p.displayText(),
62-
p.category(),
63-
p.description(),
64-
null,
65-
null,
66-
p.complete())
67-
)
60+
.map(p -> new Candidate(p.dontQuote() ? p.value() : cpl.emit(p.value()).toString(), p.displayText(),
61+
p.category(), p.description(), null, null, p.complete()))
6862
.forEach(candidates::add);
6963
}
7064

@@ -74,11 +68,15 @@ public void setShell(Shell shell) {
7468

7569
static List<String> sanitizeInput(List<String> words) {
7670
words = words.stream()
77-
.map(s -> s.replaceAll("^\\n+|\\n+$", "")) // CR at beginning/end of line introduced by backslash continuation
78-
.map(s -> s.replaceAll("\\n+", " ")) // CR in middle of word introduced by return inside a quoted string
71+
.map(s -> s.replaceAll("^\\n+|\\n+$", "")) // CR at beginning/end of line
72+
// introduced by backslash
73+
// continuation
74+
.map(s -> s.replaceAll("\\n+", " ")) // CR in middle of word introduced by
75+
// return inside a quoted string
7976
.collect(Collectors.toList());
8077
return words;
8178
}
79+
8280
}
8381

8482
}

spring-shell-autoconfigure/src/main/java/org/springframework/shell/boot/ComponentFlowAutoConfiguration.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ public ComponentFlowCustomizer shellCommonComponentFlowCustomizer(ObjectProvider
6565
private static class CommonComponentFlowCustomizer implements ComponentFlowCustomizer {
6666

6767
private final ObjectProvider<Terminal> terminal;
68+
6869
private final ObjectProvider<ResourceLoader> resourceLoader;
70+
6971
private final ObjectProvider<TemplateExecutor> templateExecutor;
7072

7173
CommonComponentFlowCustomizer(ObjectProvider<Terminal> terminal, ObjectProvider<ResourceLoader> resourceLoader,
@@ -81,5 +83,7 @@ public void customize(Builder componentFlowBuilder) {
8183
resourceLoader.ifAvailable(dep -> componentFlowBuilder.resourceLoader(dep));
8284
templateExecutor.ifAvailable(dep -> componentFlowBuilder.templateExecutor(dep));
8385
}
86+
8487
}
88+
8589
}

spring-shell-autoconfigure/src/main/java/org/springframework/shell/boot/ComponentFlowCustomizer.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,5 @@ public interface ComponentFlowCustomizer {
3030
* @param componentFlowBuilder the component flow builder to customize
3131
*/
3232
void customize(ComponentFlow.Builder componentFlowBuilder);
33+
3334
}

spring-shell-autoconfigure/src/main/java/org/springframework/shell/boot/ExitCodeAutoConfiguration.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ else if (exception.getCause() instanceof CommandExecution.CommandParserException
6969
// only map parsing error so that other mappers can do their job
7070
return 0;
7171
}
72+
7273
}
7374

7475
static class ShellExitCodeMappingsExceptionMapper implements ExitCodeExceptionMapper, ExitCodeMappings {
@@ -100,6 +101,7 @@ public int getExitCode(Throwable exception) {
100101
}
101102
return exitCode;
102103
}
104+
103105
}
104106

105107
static class ShellExitCodeException extends RuntimeException implements ExitCodeGenerator {
@@ -115,5 +117,7 @@ static class ShellExitCodeException extends RuntimeException implements ExitCode
115117
public int getExitCode() {
116118
return code;
117119
}
120+
118121
}
122+
119123
}

spring-shell-autoconfigure/src/main/java/org/springframework/shell/boot/JLineAutoConfiguration.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,7 @@ public static class JLineHistoryConfiguration {
3333
public org.jline.reader.History history() {
3434
return new DefaultHistory();
3535
}
36+
3637
}
38+
3739
}

spring-shell-autoconfigure/src/main/java/org/springframework/shell/boot/JLineShellAutoConfiguration.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,5 @@ public Parser parser() {
6868
parser.setEofOnEscapedNewLine(true);
6969
return parser;
7070
}
71+
7172
}

0 commit comments

Comments
 (0)