Skip to content

Commit 208d52d

Browse files
committed
Introduce Checkstyle rule for separator symbol location
1 parent 18c3b63 commit 208d52d

File tree

97 files changed

+378
-403
lines changed

Some content is hidden

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

97 files changed

+378
-403
lines changed

Diff for: spring-aop/src/main/java/org/springframework/aop/config/AspectEntry.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2023 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
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.
@@ -46,8 +46,8 @@ public AspectEntry(String id, String ref) {
4646

4747
@Override
4848
public String toString() {
49-
return "Aspect: " + (StringUtils.hasLength(this.id) ? "id='" + this.id + "'"
50-
: "ref='" + this.ref + "'");
49+
return "Aspect: " + (StringUtils.hasLength(this.id) ? "id='" + this.id + "'" :
50+
"ref='" + this.ref + "'");
5151
}
5252

5353
}

Diff for: spring-aop/src/main/java/org/springframework/aop/support/ClassFilters.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2023 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
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.
@@ -198,8 +198,8 @@ public boolean matches(Class<?> clazz) {
198198

199199
@Override
200200
public boolean equals(Object other) {
201-
return (this == other || (other instanceof NegateClassFilter that
202-
&& this.original.equals(that.original)));
201+
return (this == other || (other instanceof NegateClassFilter that &&
202+
this.original.equals(that.original)));
203203
}
204204

205205
@Override

Diff for: spring-aop/src/main/java/org/springframework/aop/support/MethodMatchers.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2023 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
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.
@@ -378,8 +378,8 @@ public boolean matches(Method method, Class<?> targetClass, Object... args) {
378378

379379
@Override
380380
public boolean equals(Object other) {
381-
return (this == other || (other instanceof NegateMethodMatcher that
382-
&& this.original.equals(that.original)));
381+
return (this == other || (other instanceof NegateMethodMatcher that &&
382+
this.original.equals(that.original)));
383383
}
384384

385385
@Override

Diff for: spring-beans/src/main/java/org/springframework/beans/factory/aot/AotServices.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2022 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
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.
@@ -212,9 +212,9 @@ public <T> AotServices<T> load(Class<T> type) {
212212
}
213213

214214
private <T> Map<String, T> loadBeans(Class<T> type) {
215-
return (this.beanFactory != null) ? BeanFactoryUtils
216-
.beansOfTypeIncludingAncestors(this.beanFactory, type, true, false)
217-
: Collections.emptyMap();
215+
return (this.beanFactory != null ?
216+
BeanFactoryUtils.beansOfTypeIncludingAncestors(this.beanFactory, type, true, false) :
217+
Collections.emptyMap());
218218
}
219219

220220
}

Diff for: spring-beans/src/main/java/org/springframework/beans/factory/aot/BeanDefinitionMethodGeneratorFactory.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ class BeanDefinitionMethodGeneratorFactory {
6969
this.excludeFilters = loader.load(BeanRegistrationExcludeFilter.class);
7070
for (BeanRegistrationExcludeFilter excludeFilter : this.excludeFilters) {
7171
if (this.excludeFilters.getSource(excludeFilter) == Source.BEAN_FACTORY) {
72-
Assert.state(excludeFilter instanceof BeanRegistrationAotProcessor
73-
|| excludeFilter instanceof BeanFactoryInitializationAotProcessor,
72+
Assert.state(excludeFilter instanceof BeanRegistrationAotProcessor ||
73+
excludeFilter instanceof BeanFactoryInitializationAotProcessor,
7474
() -> "BeanRegistrationExcludeFilter bean of type %s must also implement an AOT processor interface"
7575
.formatted(excludeFilter.getClass().getName()));
7676
}

Diff for: spring-beans/src/main/java/org/springframework/beans/factory/aot/InstanceSupplierCodeGenerator.java

+2-4
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,7 @@ private void buildGetInstanceMethodForConstructor(MethodSpec.Builder method, Con
234234

235235
CodeBlock arguments = hasArguments ?
236236
new AutowiredArgumentsCodeGenerator(actualType, constructor)
237-
.generateCode(constructor.getParameterTypes(), (onInnerClass ? 1 : 0))
238-
: NO_ARGS;
237+
.generateCode(constructor.getParameterTypes(), (onInnerClass ? 1 : 0)) : NO_ARGS;
239238

240239
CodeBlock newInstance = generateNewInstanceCodeForConstructor(actualType, arguments);
241240
code.add(generateWithGeneratorCode(hasArguments, newInstance));
@@ -325,8 +324,7 @@ private void buildGetInstanceMethodForFactoryMethod(MethodSpec.Builder method,
325324
boolean hasArguments = factoryMethod.getParameterCount() > 0;
326325
CodeBlock arguments = hasArguments ?
327326
new AutowiredArgumentsCodeGenerator(ClassUtils.getUserClass(targetClass), factoryMethod)
328-
.generateCode(factoryMethod.getParameterTypes())
329-
: NO_ARGS;
327+
.generateCode(factoryMethod.getParameterTypes()) : NO_ARGS;
330328

331329
CodeBlock newInstance = generateNewInstanceCodeForMethod(
332330
factoryBeanName, ClassUtils.getUserClass(targetClass), factoryMethodName, arguments);

Diff for: spring-beans/src/main/java/org/springframework/beans/factory/xml/AbstractBeanDefinitionParser.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ public final BeanDefinition parse(Element element, ParserContext parserContext)
6666
String id = resolveId(element, definition, parserContext);
6767
if (!StringUtils.hasText(id)) {
6868
parserContext.getReaderContext().error(
69-
"Id is required for element '" + parserContext.getDelegate().getLocalName(element)
70-
+ "' when used as a top-level tag", element);
69+
"Id is required for element '" + parserContext.getDelegate().getLocalName(element) +
70+
"' when used as a top-level tag", element);
7171
}
7272
String[] aliases = null;
7373
if (shouldParseNameAsAliases()) {

Diff for: spring-beans/src/test/java/org/springframework/beans/factory/annotation/ParameterResolutionTests.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ void annotatedParametersInInnerClassConstructorAreCandidatesForAutowiring() thro
7171
}
7272

7373
private void assertAutowirableParameters(Executable executable) {
74-
int startIndex = (executable instanceof Constructor)
75-
&& ClassUtils.isInnerClass(executable.getDeclaringClass()) ? 1 : 0;
74+
int startIndex = (executable instanceof Constructor) &&
75+
ClassUtils.isInnerClass(executable.getDeclaringClass()) ? 1 : 0;
7676
Parameter[] parameters = executable.getParameters();
7777
for (int parameterIndex = startIndex; parameterIndex < parameters.length; parameterIndex++) {
7878
Parameter parameter = parameters[parameterIndex];

Diff for: spring-beans/src/test/java/org/springframework/beans/factory/aot/BeanInstanceSupplierTests.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ void forConstructorWhenNotFoundThrowsException() {
103103
RegisteredBean registerBean = source.registerBean(this.beanFactory);
104104
assertThatIllegalArgumentException()
105105
.isThrownBy(() -> resolver.get(registerBean)).withMessage(
106-
"Constructor with parameter types [java.io.InputStream] cannot be found on "
107-
+ SingleArgConstructor.class.getName());
106+
"Constructor with parameter types [java.io.InputStream] cannot be found on " +
107+
SingleArgConstructor.class.getName());
108108
}
109109

110110
@Test
@@ -151,8 +151,8 @@ void forFactoryMethodWhenNotFoundThrowsException() {
151151
RegisteredBean registerBean = source.registerBean(this.beanFactory);
152152
assertThatIllegalArgumentException()
153153
.isThrownBy(() -> resolver.get(registerBean)).withMessage(
154-
"Factory method 'single' with parameter types [java.io.InputStream] declared on class "
155-
+ SingleArgFactory.class.getName() + " cannot be found");
154+
"Factory method 'single' with parameter types [java.io.InputStream] declared on class " +
155+
SingleArgFactory.class.getName() + " cannot be found");
156156
}
157157

158158
@Test

Diff for: spring-beans/src/test/java/org/springframework/beans/factory/aot/DefaultBeanRegistrationCodeFragmentsTests.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ public void getTargetWithInstanceSupplierAndResourceDescription() {
8686
BeanRegistrationCodeFragments codeFragments = createInstance(registeredBean);
8787
assertThatExceptionOfType(AotBeanProcessingException.class)
8888
.isThrownBy(() -> codeFragments.getTarget(registeredBean))
89-
.withMessageContaining("Error processing bean with name 'testBean' defined in my test resource: "
90-
+ "instance supplier is not supported");
89+
.withMessageContaining("Error processing bean with name 'testBean' defined in my test resource: " +
90+
"instance supplier is not supported");
9191
}
9292

9393
@Test

Diff for: spring-context-indexer/src/main/java/org/springframework/context/index/processor/MetadataCollector.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ public CandidateComponentsMetadata getMetadata() {
9393

9494
private boolean shouldBeMerged(ItemMetadata itemMetadata) {
9595
String sourceType = itemMetadata.getType();
96-
return (sourceType != null && !deletedInCurrentBuild(sourceType)
97-
&& !processedInCurrentBuild(sourceType));
96+
return (sourceType != null && !deletedInCurrentBuild(sourceType) &&
97+
!processedInCurrentBuild(sourceType));
9898
}
9999

100100
private boolean deletedInCurrentBuild(String sourceType) {

Diff for: spring-context-indexer/src/test/java/org/springframework/context/index/processor/Metadata.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ public static Condition<CandidateComponentsMetadata> of(String type,
4242
ItemMetadata itemMetadata = metadata.getItems().stream()
4343
.filter(item -> item.getType().equals(type))
4444
.findFirst().orElse(null);
45-
return itemMetadata != null && itemMetadata.getStereotypes().size() == stereotypes.size()
46-
&& itemMetadata.getStereotypes().containsAll(stereotypes);
45+
return (itemMetadata != null && itemMetadata.getStereotypes().size() == stereotypes.size() &&
46+
itemMetadata.getStereotypes().containsAll(stereotypes));
4747
}, "Candidates with type %s and stereotypes %s", type, stereotypes);
4848
}
4949

Diff for: spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/AbstractJCacheKeyOperation.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ public CacheInvocationParameter[] getKeyParameters(Object... values) {
7979
for (CacheParameterDetail keyParameterDetail : this.keyParameterDetails) {
8080
int parameterPosition = keyParameterDetail.getParameterPosition();
8181
if (parameterPosition >= values.length) {
82-
throw new IllegalStateException("Values mismatch, key parameter at position "
83-
+ parameterPosition + " cannot be matched against " + values.length + " value(s)");
82+
throw new IllegalStateException("Values mismatch, key parameter at position " +
83+
parameterPosition + " cannot be matched against " + values.length + " value(s)");
8484
}
8585
result.add(keyParameterDetail.toCacheInvocationParameter(values[parameterPosition]));
8686
}

Diff for: spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/JCacheKeyGeneratorTests.java

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2024 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
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.
@@ -17,7 +17,6 @@
1717
package org.springframework.cache.jcache.interceptor;
1818

1919
import java.lang.reflect.Method;
20-
import java.util.Arrays;
2120
import java.util.concurrent.atomic.AtomicLong;
2221

2322
import javax.cache.annotation.CacheDefaults;
@@ -150,9 +149,9 @@ private void expect(Object... params) {
150149

151150
@Override
152151
public Object generate(Object target, Method method, Object... params) {
153-
assertThat(Arrays.equals(expectedParams, params)).as("Unexpected parameters: expected: "
154-
+ Arrays.toString(this.expectedParams) + " but got: " + Arrays.toString(params)).isTrue();
152+
assertThat(params).as("Unexpected parameters").isEqualTo(expectedParams);
155153
return new SimpleKey(params);
156154
}
157155
}
156+
158157
}

Diff for: spring-context/src/main/java/org/springframework/cache/interceptor/CacheAspectSupport.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,8 @@ public void afterSingletonsInstantiated() {
288288
}
289289
}
290290
catch (NoSuchBeanDefinitionException ex) {
291-
throw new NoSuchBeanDefinitionException(CacheManager.class, "no CacheResolver specified - "
292-
+ "register a CacheManager bean or remove the @EnableCaching annotation from your configuration.");
291+
throw new NoSuchBeanDefinitionException(CacheManager.class, "no CacheResolver specified - " +
292+
"register a CacheManager bean or remove the @EnableCaching annotation from your configuration.");
293293
}
294294
}
295295
this.initialized = true;

Diff for: spring-context/src/main/java/org/springframework/cache/interceptor/NameMatchCacheOperationSource.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ public Collection<CacheOperation> getCacheOperations(Method method, @Nullable Cl
8585
// Look for most specific name match.
8686
String bestNameMatch = null;
8787
for (String mappedName : this.nameMap.keySet()) {
88-
if (isMatch(methodName, mappedName)
89-
&& (bestNameMatch == null || bestNameMatch.length() <= mappedName.length())) {
88+
if (isMatch(methodName, mappedName) &&
89+
(bestNameMatch == null || bestNameMatch.length() <= mappedName.length())) {
9090
ops = this.nameMap.get(mappedName);
9191
bestNameMatch = mappedName;
9292
}

Diff for: spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassParser.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ class ConfigurationClassParser {
105105
(className.startsWith("java.lang.annotation.") || className.startsWith("org.springframework.stereotype."));
106106

107107
private static final Predicate<Condition> REGISTER_BEAN_CONDITION_FILTER = condition ->
108-
(condition instanceof ConfigurationCondition configurationCondition
109-
&& ConfigurationPhase.REGISTER_BEAN.equals(configurationCondition.getConfigurationPhase()));
108+
(condition instanceof ConfigurationCondition configurationCondition &&
109+
ConfigurationPhase.REGISTER_BEAN.equals(configurationCondition.getConfigurationPhase()));
110110

111111
private static final Comparator<DeferredImportSelectorHolder> DEFERRED_IMPORT_COMPARATOR =
112112
(o1, o2) -> AnnotationAwareOrderComparator.INSTANCE.compare(o1.getImportSelector(), o2.getImportSelector());

Diff for: spring-context/src/main/java/org/springframework/context/aot/ApplicationContextInitializationCodeGenerator.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2023 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
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.
@@ -150,12 +150,12 @@ public CodeBlock apply(TypeName typeName) {
150150
@Nullable
151151
private CodeBlock apply(ClassName className) {
152152
String name = className.canonicalName();
153-
if (name.equals(DefaultListableBeanFactory.class.getName())
154-
|| name.equals(ConfigurableListableBeanFactory.class.getName())) {
153+
if (name.equals(DefaultListableBeanFactory.class.getName()) ||
154+
name.equals(ConfigurableListableBeanFactory.class.getName())) {
155155
return CodeBlock.of(BEAN_FACTORY_VARIABLE);
156156
}
157-
else if (name.equals(ConfigurableEnvironment.class.getName())
158-
|| name.equals(Environment.class.getName())) {
157+
else if (name.equals(ConfigurableEnvironment.class.getName()) ||
158+
name.equals(Environment.class.getName())) {
159159
return CodeBlock.of("$L.getEnvironment()", APPLICATION_CONTEXT_VARIABLE);
160160
}
161161
else if (name.equals(ResourceLoader.class.getName())) {

Diff for: spring-context/src/main/java/org/springframework/context/expression/StandardBeanExpressionResolver.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2024 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
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.
@@ -201,8 +201,8 @@ private static int retrieveMaxExpressionLength() {
201201

202202
try {
203203
int maxLength = Integer.parseInt(value.trim());
204-
Assert.isTrue(maxLength > 0, () -> "Value [" + maxLength + "] for system property ["
205-
+ MAX_SPEL_EXPRESSION_LENGTH_PROPERTY_NAME + "] must be positive");
204+
Assert.isTrue(maxLength > 0, () -> "Value [" + maxLength + "] for system property [" +
205+
MAX_SPEL_EXPRESSION_LENGTH_PROPERTY_NAME + "] must be positive");
206206
return maxLength;
207207
}
208208
catch (NumberFormatException ex) {

Diff for: spring-context/src/main/java/org/springframework/context/support/PostProcessorRegistrationDelegate.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -493,8 +493,8 @@ private void postProcessRootBeanDefinition(List<MergedBeanDefinitionPostProcesso
493493

494494
private void postProcessValue(List<MergedBeanDefinitionPostProcessor> postProcessors,
495495
BeanDefinitionValueResolver valueResolver, @Nullable Object value) {
496-
if (value instanceof BeanDefinitionHolder bdh
497-
&& bdh.getBeanDefinition() instanceof AbstractBeanDefinition innerBd) {
496+
if (value instanceof BeanDefinitionHolder bdh &&
497+
bdh.getBeanDefinition() instanceof AbstractBeanDefinition innerBd) {
498498

499499
Class<?> innerBeanType = resolveBeanType(innerBd);
500500
resolveInnerBeanDefinition(valueResolver, innerBd, (innerBeanName, innerBeanDefinition)

Diff for: spring-context/src/main/java/org/springframework/format/datetime/standard/DurationFormatterUtils.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,8 @@ public static DurationFormat.Style detect(String value) {
143143

144144
private static final Pattern ISO_8601_PATTERN = Pattern.compile("^[+-]?[pP].*$");
145145
private static final Pattern SIMPLE_PATTERN = Pattern.compile("^([+-]?\\d+)([a-zA-Z]{0,2})$");
146-
private static final Pattern COMPOSITE_PATTERN = Pattern.compile("^([+-]?)\\(?\\s?(\\d+d)?\\s?(\\d+h)?\\s?(\\d+m)?"
147-
+ "\\s?(\\d+s)?\\s?(\\d+ms)?\\s?(\\d+us)?\\s?(\\d+ns)?\\)?$");
146+
private static final Pattern COMPOSITE_PATTERN = Pattern.compile("^([+-]?)\\(?\\s?(\\d+d)?\\s?(\\d+h)?\\s?(\\d+m)?" +
147+
"\\s?(\\d+s)?\\s?(\\d+ms)?\\s?(\\d+us)?\\s?(\\d+ns)?\\)?$");
148148

149149
private static Duration parseIso8601(String value) {
150150
try {

Diff for: spring-context/src/main/java/org/springframework/scheduling/support/DefaultScheduledTaskObservationConvention.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ public String getName() {
4848

4949
@Override
5050
public String getContextualName(ScheduledTaskObservationContext context) {
51-
return "task " + StringUtils.uncapitalize(context.getTargetClass().getSimpleName())
52-
+ "." + context.getMethod().getName();
51+
return "task " + StringUtils.uncapitalize(context.getTargetClass().getSimpleName()) +
52+
"." + context.getMethod().getName();
5353
}
5454

5555
@Override

Diff for: spring-context/src/test/java/org/springframework/aop/aspectj/AspectAndAdvicePrecedenceTests.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ private static class PrecedenceVerifyingCollaborator implements PrecedenceTestAs
106106
private void checkAdvice(String whatJustHappened) {
107107
//System.out.println("[" + adviceInvocationNumber + "] " + whatJustHappened + " ==> " + EXPECTED[adviceInvocationNumber]);
108108
if (adviceInvocationNumber > (EXPECTED.length - 1)) {
109-
throw new AssertionError("Too many advice invocations, expecting " + EXPECTED.length
110-
+ " but had " + adviceInvocationNumber);
109+
throw new AssertionError("Too many advice invocations, expecting " + EXPECTED.length +
110+
" but had " + adviceInvocationNumber);
111111
}
112112
String expecting = EXPECTED[adviceInvocationNumber++];
113113
if (!whatJustHappened.equals(expecting)) {

0 commit comments

Comments
 (0)