Skip to content

Commit b543266

Browse files
committed
Reformat code
1 parent 6555254 commit b543266

File tree

21 files changed

+73
-51
lines changed

21 files changed

+73
-51
lines changed

spring-javaformat-gradle/spring-javaformat-gradle-plugin/src/main/java/io/spring/javaformat/gradle/SpringJavaFormatPlugin.java

+10-6
Original file line numberDiff line numberDiff line change
@@ -56,24 +56,28 @@ private void addSourceTasks() {
5656
TaskProvider<Task> checkAllProvider = tasks.register(CheckFormat.NAME);
5757
checkAllProvider.configure((checkAll) -> checkAll.setDescription(CheckFormat.DESCRIPTION));
5858
tasks.named(JavaBasePlugin.CHECK_TASK_NAME).configure((check) -> check.dependsOn(checkAllProvider));
59-
this.project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets()
60-
.all((sourceSet) -> addSourceTasks(sourceSet, checkAllProvider, formatAllProvider));
59+
this.project.getConvention()
60+
.getPlugin(JavaPluginConvention.class)
61+
.getSourceSets()
62+
.all((sourceSet) -> addSourceTasks(sourceSet, checkAllProvider, formatAllProvider));
6163
});
6264
}
6365

64-
private void addSourceTasks(SourceSet sourceSet, TaskProvider<Task> checkAllProvider, TaskProvider<Task> formatAllProvider) {
66+
private void addSourceTasks(SourceSet sourceSet, TaskProvider<Task> checkAllProvider,
67+
TaskProvider<Task> formatAllProvider) {
6568
TaskProvider<CheckFormat> checkTaskProvider = addFormatterTask(sourceSet, CheckFormat.class, CheckFormat.NAME,
6669
CheckFormat.DESCRIPTION);
6770
checkTaskProvider.configure((checkTask) -> checkTask.setReportLocation(
6871
new File(this.project.getBuildDir(), "reports/format/" + sourceSet.getName() + "/check-format.txt")));
6972
checkAllProvider.configure((checkAll) -> checkAll.dependsOn(checkTaskProvider));
70-
TaskProvider<Format> formatTaskProvider = addFormatterTask(sourceSet, Format.class, Format.NAME, Format.DESCRIPTION);
73+
TaskProvider<Format> formatTaskProvider = addFormatterTask(sourceSet, Format.class, Format.NAME,
74+
Format.DESCRIPTION);
7175
formatTaskProvider.configure((format) -> format.conventionMapping("encoding", () -> "UTF-8"));
7276
formatAllProvider.configure((formatAll) -> formatAll.dependsOn(formatTaskProvider));
7377
}
7478

75-
private <T extends FormatterTask> TaskProvider<T> addFormatterTask(SourceSet sourceSet, Class<T> taskType, String name,
76-
String desc) {
79+
private <T extends FormatterTask> TaskProvider<T> addFormatterTask(SourceSet sourceSet, Class<T> taskType,
80+
String name, String desc) {
7781
String taskName = sourceSet.getTaskName(name, null);
7882
TaskProvider<T> provider = this.project.getTasks().register(taskName, taskType);
7983
provider.configure((task) -> {

spring-javaformat-gradle/spring-javaformat-gradle-plugin/src/main/java/io/spring/javaformat/gradle/tasks/CheckFormat.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,9 @@ public class CheckFormat extends FormatterTask {
5353

5454
@TaskAction
5555
public void checkFormatting() throws IOException, InterruptedException {
56-
List<File> problems = formatFiles().filter(FileEdit::hasEdits).map(FileEdit::getFile)
57-
.collect(Collectors.toList());
56+
List<File> problems = formatFiles().filter(FileEdit::hasEdits)
57+
.map(FileEdit::getFile)
58+
.collect(Collectors.toList());
5859
this.reportLocation.getParentFile().mkdirs();
5960
if (!problems.isEmpty()) {
6061
StringBuilder message = new StringBuilder("Formatting violations found in the following files:\n");

spring-javaformat-intellij-idea/spring-javaformat-intellij-idea-plugin/src/main/java/io/spring/format/formatter/intellij/monitor/GradleMonitor.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
import io.spring.format.formatter.intellij.state.State;
3333

3434
/**
35-
* {@link Monitor} that looks for a {@code spring-javaformat-gradle-plugin}
36-
* declaration in the build.gradle file.
35+
* {@link Monitor} that looks for a {@code spring-javaformat-gradle-plugin} declaration in
36+
* the build.gradle file.
3737
*
3838
* @author Phillip Webb
3939
*/

spring-javaformat-intellij-idea/spring-javaformat-intellij-idea-plugin/src/test/java/io/spring/format/formatter/intellij/formatting/EclipseDocumentAdapterTests.java

+1
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,5 @@ void replaceAppliesToIntellijDocument() throws Exception {
4848
assertThat(adapter.get()).isEqualTo("help");
4949
verify(intellijDocument).replaceString(3, 5, "p");
5050
}
51+
5152
}

spring-javaformat-maven/spring-javaformat-maven-plugin/src/main/java/io/spring/format/maven/FormatMojo.java

+7-4
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,9 @@ public final void execute() throws MojoExecutionException, MojoFailureException
130130
}
131131

132132
private Stream<File> resolve(List<String> directories) {
133-
return directories.stream().map(directory -> FileUtils.resolveFile(this.project.getBasedir(), directory))
134-
.filter(this::include);
133+
return directories.stream()
134+
.map(directory -> FileUtils.resolveFile(this.project.getBasedir(), directory))
135+
.filter(this::include);
135136
}
136137

137138
private boolean include(File file) {
@@ -168,8 +169,10 @@ private List<File> scan(File directory) {
168169
scanner.setCaseSensitive(false);
169170
scanner.setFollowSymlinks(false);
170171
scanner.scan();
171-
return Arrays.asList(scanner.getIncludedFiles()).stream().map(name -> new File(directory, name))
172-
.collect(Collectors.toList());
172+
return Arrays.asList(scanner.getIncludedFiles())
173+
.stream()
174+
.map(name -> new File(directory, name))
175+
.collect(Collectors.toList());
173176
}
174177

175178
private boolean hasLength(Object[] array) {

spring-javaformat-maven/spring-javaformat-maven-plugin/src/main/java/io/spring/format/maven/ValidateMojo.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,10 @@ protected void execute(List<File> files, Charset encoding, String lineSeparator)
5050
getLog().debug("skipping validation as per configuration.");
5151
return;
5252
}
53-
List<File> problems = getFormatter().formatFiles(files, encoding, lineSeparator).filter(FileEdit::hasEdits)
54-
.map(FileEdit::getFile).collect(Collectors.toList());
53+
List<File> problems = getFormatter().formatFiles(files, encoding, lineSeparator)
54+
.filter(FileEdit::hasEdits)
55+
.map(FileEdit::getFile)
56+
.collect(Collectors.toList());
5557
if (!problems.isEmpty()) {
5658
StringBuilder message = new StringBuilder("Formatting violations found in the following files:\n");
5759
problems.stream().forEach((f) -> message.append(" * " + f + "\n"));

spring-javaformat-maven/spring-javaformat-maven-plugin/src/test/java/io/spring/format/maven/VerifyApply.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ public void verify(File base, String lineSeparator, boolean spaces) throws IOExc
5050
String formated = new String(Files.readAllBytes(base.toPath().resolve(JAVA_FILE)), StandardCharsets.UTF_8);
5151
String indent = (!spaces) ? " " : " ";
5252
assertThat(formated).contains("Simple." + lineSeparator + " *" + lineSeparator + " * @author")
53-
.contains("public class Simple {").contains(indent + "public static void main");
53+
.contains("public class Simple {")
54+
.contains(indent + "public static void main");
5455
}
5556

5657
public static void main(String[] args) throws IOException {

spring-javaformat/spring-javaformat-checkstyle/src/main/java/io/spring/javaformat/checkstyle/SpringConfigurationLoader.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,10 @@ public Collection<FileSetCheck> load(PropertyResolver propertyResolver) {
5252
System.out.println(getClass().getResource("spring-checkstyle.xml"));
5353
Configuration config = loadConfiguration(getClass().getResourceAsStream("spring-checkstyle.xml"),
5454
propertyResolver);
55-
return Arrays.stream(config.getChildren()).filter(this.moduleFactory::nonFiltered).map(this::load)
56-
.collect(Collectors.toList());
55+
return Arrays.stream(config.getChildren())
56+
.filter(this.moduleFactory::nonFiltered)
57+
.map(this::load)
58+
.collect(Collectors.toList());
5759
}
5860

5961
private Configuration loadConfiguration(InputStream inputStream, PropertyResolver propertyResolver) {

spring-javaformat/spring-javaformat-checkstyle/src/main/java/io/spring/javaformat/checkstyle/check/SpringHideUtilityClassConstructor.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,9 @@ public class SpringHideUtilityClassConstructor extends HideUtilityClassConstruct
3939
annotations.add("org.springframework.context.annotation.Configuration");
4040
annotations.add("org.springframework.boot.autoconfigure.SpringBootApplication");
4141
annotations.add("org.springframework.boot.autoconfigure.EnableAutoConfiguration");
42-
Set<String> shortNames = annotations.stream().map((name) -> name.substring(name.lastIndexOf(".") + 1))
43-
.collect(Collectors.toSet());
42+
Set<String> shortNames = annotations.stream()
43+
.map((name) -> name.substring(name.lastIndexOf(".") + 1))
44+
.collect(Collectors.toSet());
4445
annotations.addAll(shortNames);
4546
BYPASS_ANNOTATIONS = Collections.unmodifiableSet(annotations);
4647
}

spring-javaformat/spring-javaformat-checkstyle/src/main/java/io/spring/javaformat/checkstyle/check/SpringJUnit5Check.java

+7-7
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,11 @@ public void beginTree(DetailAST rootAST) {
9797
@Override
9898
public void visitToken(DetailAST ast) {
9999
switch (ast.getType()) {
100-
case TokenTypes.METHOD_DEF:
101-
visitMethodDef(ast);
102-
case TokenTypes.IMPORT:
103-
visitImport(ast);
104-
break;
100+
case TokenTypes.METHOD_DEF:
101+
visitMethodDef(ast);
102+
case TokenTypes.IMPORT:
103+
visitImport(ast);
104+
break;
105105
}
106106
}
107107

@@ -172,8 +172,8 @@ private void log(DetailAST method, String key) {
172172
}
173173

174174
public void setUnlessImports(String unlessImports) {
175-
this.unlessImports = Collections.unmodifiableList(
176-
Arrays.stream(unlessImports.split(",")).map(String::trim).collect(Collectors.toList()));
175+
this.unlessImports = Collections
176+
.unmodifiableList(Arrays.stream(unlessImports.split(",")).map(String::trim).collect(Collectors.toList()));
177177
}
178178

179179
}

spring-javaformat/spring-javaformat-checkstyle/src/main/java/io/spring/javaformat/checkstyle/check/SpringJavadocCheck.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,8 @@ private void checkSinceTag(DetailAST ast, TextBlock javadoc) {
166166
}
167167
String[] text = javadoc.getText();
168168
DetailAST interfaceOrAnnotationDef = getInterfaceOrAnnotationDef(ast);
169-
boolean privateType = !isPublicOrProtected(ast) && (interfaceOrAnnotationDef == null || !isPublicOrProtected(interfaceOrAnnotationDef));
169+
boolean privateType = !isPublicOrProtected(ast)
170+
&& (interfaceOrAnnotationDef == null || !isPublicOrProtected(interfaceOrAnnotationDef));
170171
boolean innerType = ast.getParent() != null && ast.getParent().getType() != TokenTypes.COMPILATION_UNIT;
171172
boolean found = false;
172173
for (int i = 0; i < text.length; i++) {
@@ -231,7 +232,7 @@ private DetailAST getInterfaceOrAnnotationDef(DetailAST ast) {
231232

232233
private DetailAST findParent(DetailAST ast, int... classDefs) {
233234
while (ast != null) {
234-
for (int classDef: classDefs) {
235+
for (int classDef : classDefs) {
235236
if (ast.getType() == classDef) {
236237
return ast;
237238
}

spring-javaformat/spring-javaformat-checkstyle/src/main/java/io/spring/javaformat/checkstyle/check/SpringMethodOrderCheck.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
public class SpringMethodOrderCheck extends AbstractSpringCheck {
3434

3535
private static final List<String> EXPECTED_ORDER = Collections
36-
.unmodifiableList(Arrays.asList("equals", "hashCode", "toString"));
36+
.unmodifiableList(Arrays.asList("equals", "hashCode", "toString"));
3737

3838
@Override
3939
public int[] getAcceptableTokens() {

spring-javaformat/spring-javaformat-checkstyle/src/main/java/io/spring/javaformat/checkstyle/check/SpringTernaryCheck.java

+10-10
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ private void visitQuestion(DetailAST ast) {
6161
private boolean requiresParens(DetailAST expression) {
6262
if (expression != null && expression.getChildCount() > 1) {
6363
switch (expression.getType()) {
64-
case TokenTypes.METHOD_CALL:
65-
case TokenTypes.DOT:
66-
return false;
64+
case TokenTypes.METHOD_CALL:
65+
case TokenTypes.DOT:
66+
return false;
6767
}
6868
return true;
6969
}
@@ -86,13 +86,13 @@ private boolean isSimpleEqualsExpression(DetailAST expression) {
8686

8787
private boolean isEqualsTestAllowed(DetailAST ast) {
8888
switch (this.equalsTest) {
89-
case ANY:
90-
return true;
91-
case NEVER:
92-
return false;
93-
case NEVER_FOR_NULLS:
94-
DetailAST equal = ast.findFirstToken(TokenTypes.EQUAL);
95-
return equal.findFirstToken(TokenTypes.LITERAL_NULL) == null;
89+
case ANY:
90+
return true;
91+
case NEVER:
92+
return false;
93+
case NEVER_FOR_NULLS:
94+
DetailAST equal = ast.findFirstToken(TokenTypes.EQUAL);
95+
return equal.findFirstToken(TokenTypes.LITERAL_NULL) == null;
9696
}
9797
throw new IllegalStateException("Unsupported equals test " + this.equalsTest);
9898
}

spring-javaformat/spring-javaformat-checkstyle/src/test/java/io/spring/javaformat/checkstyle/AssertionsAuditListener.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ private void recordLevel(AuditEvent event) {
111111

112112
private void recordLocalizedMessage(String message, String... args) {
113113
recordMessage(new Violation(0, Definitions.CHECKSTYLE_BUNDLE, message, args, null, Violation.class, null)
114-
.getViolation());
114+
.getViolation());
115115
}
116116

117117
private void recordMessage(String message) {

spring-javaformat/spring-javaformat-checkstyle/src/test/java/io/spring/javaformat/checkstyle/SpringChecksTests.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,10 @@ private void printDebugInfo(File file) throws CheckstyleException {
113113
}
114114

115115
public static Collection<Parameter> paramaters() throws IOException {
116-
ArrayList<Parameter> parameters = Arrays.stream(SOURCES_DIR.listFiles(SpringChecksTests::sourceFile)).sorted()
117-
.map(Parameter::new).collect(Collectors.toCollection(ArrayList::new));
116+
ArrayList<Parameter> parameters = Arrays.stream(SOURCES_DIR.listFiles(SpringChecksTests::sourceFile))
117+
.sorted()
118+
.map(Parameter::new)
119+
.collect(Collectors.toCollection(ArrayList::new));
118120
parameters.add(new Parameter(new File(SOURCES_DIR, "nopackageinfo/NoPackageInfo.java")));
119121
return parameters;
120122
}

spring-javaformat/spring-javaformat-checkstyle/src/test/java/io/spring/javaformat/checkstyle/SpringConfigurationLoaderTests.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public void loadShouldLoadChecks() {
5454
@Test
5555
public void loadWithExcludeShouldExcludeChecks() {
5656
Set<String> excludes = Collections
57-
.singleton("com.puppycrawl.tools.checkstyle.checks.whitespace.MethodParamPadCheck");
57+
.singleton("com.puppycrawl.tools.checkstyle.checks.whitespace.MethodParamPadCheck");
5858
Collection<FileSetCheck> checks = load(excludes);
5959
assertThat(checks).hasSize(4);
6060
TreeWalker treeWalker = (TreeWalker) checks.toArray()[3];
@@ -75,7 +75,7 @@ private Collection<FileSetCheck> load(Set<String> excludes) {
7575
new PackageObjectFactory(getClass().getPackage().getName(), getClass().getClassLoader()), excludes);
7676
context.add("moduleFactory", filteredModuleFactory);
7777
Collection<FileSetCheck> checks = new SpringConfigurationLoader(context, filteredModuleFactory)
78-
.load(getPropertyResolver());
78+
.load(getPropertyResolver());
7979
return checks;
8080
}
8181

spring-javaformat/spring-javaformat-formatter-eclipse-jdt-jdk11/src/main/java/org/eclipse/jdt/internal/formatter/ExtendedCodeFormatter.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,9 @@ protected void prepareWraps(int kind) {
107107
}
108108

109109
private void applyPreparators(Phase preWrapping, int kind, ASTNode astRoot, TokenManager tokenManager) {
110-
this.preparators.stream().filter((preparator) -> preparator.getPhase() == preWrapping)
111-
.forEach((preparator) -> preparator.apply(kind, tokenManager, astRoot));
110+
this.preparators.stream()
111+
.filter((preparator) -> preparator.getPhase() == preWrapping)
112+
.forEach((preparator) -> preparator.apply(kind, tokenManager, astRoot));
112113
}
113114

114115
@SuppressWarnings("unchecked")

spring-javaformat/spring-javaformat-formatter-eclipse-jdt-jdk8/src/main/java/org/eclipse/jdt/internal/formatter/ExtendedCodeFormatter.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,9 @@ protected void prepareWraps(int kind) {
107107
}
108108

109109
private void applyPreparators(Phase preWrapping, int kind, ASTNode astRoot, TokenManager tokenManager) {
110-
this.preparators.stream().filter((preparator) -> preparator.getPhase() == preWrapping)
111-
.forEach((preparator) -> preparator.apply(kind, tokenManager, astRoot));
110+
this.preparators.stream()
111+
.filter((preparator) -> preparator.getPhase() == preWrapping)
112+
.forEach((preparator) -> preparator.apply(kind, tokenManager, astRoot));
112113
}
113114

114115
@SuppressWarnings("unchecked")

spring-javaformat/spring-javaformat-formatter-eclipse-jdt-jdk8/src/main/java/org/eclipse/jdt/internal/formatter/linewrap/WrapPreparator.java

+1
Original file line numberDiff line numberDiff line change
@@ -1684,4 +1684,5 @@ private void handleParenthesesPositions(int openingParenIndex, int closingParenI
16841684
}
16851685

16861686
// @formatter:on
1687+
16871688
}

spring-javaformat/spring-javaformat-formatter-tests/src/test/java/io/spring/javaformat/formatter/FormatterIntegrationTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ void formatCodeWithV11BaselineCanFormatOn11OrHigher(String version) throws Excep
6363
@ValueSource(strings = "8")
6464
void formatCodeWithV11BaselineCannotFormatOn8(String version) throws Exception {
6565
assertThatExceptionOfType(ContainerLaunchException.class)
66-
.isThrownBy(() -> runFormatter(JavaBaseline.V11, version));
66+
.isThrownBy(() -> runFormatter(JavaBaseline.V11, version));
6767
}
6868

6969
private void runFormatter(JavaBaseline baseline, String version) throws IOException, Exception {

spring-javaformat/spring-javaformat-formatter/src/main/java/io/spring/javaformat/formatter/StreamsFormatter.java

+1
Original file line numberDiff line numberDiff line change
@@ -121,4 +121,5 @@ private String readContent(Reader reader) throws IOException {
121121
}
122122
return result.toString();
123123
}
124+
124125
}

0 commit comments

Comments
 (0)