Introduce Checkstyle rule for separator symbol location

This commit is contained in:
Sam Brannen
2025-03-19 15:35:35 +01:00
parent 18c3b637e4
commit 208d52d852
97 changed files with 378 additions and 403 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2024 the original author or authors.
* Copyright 2002-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -118,8 +118,8 @@ abstract class AbstractExpressionEvaluatingCondition implements ExecutionConditi
if (logger.isInfoEnabled()) {
logger.info(reason);
}
result = (enabledOnTrue ? ConditionEvaluationResult.enabled(reason)
: ConditionEvaluationResult.disabled(reason));
result = (enabledOnTrue ? ConditionEvaluationResult.enabled(reason) :
ConditionEvaluationResult.disabled(reason));
}
else {
String adjective = (enabledOnTrue ? "disabled" : "enabled");

View File

@@ -252,8 +252,8 @@ abstract class ContextLoaderUtils {
// annotated class.
if (currentAnnotation.equals(previousAnnotation) && hasResources(currentAnnotation)) {
if (logger.isDebugEnabled()) {
logger.debug(String.format("Ignoring duplicate %s declaration on [%s], "
+ "since it is also declared on [%s].", currentAnnotation,
logger.debug(String.format("Ignoring duplicate %s declaration on [%s], " +
"since it is also declared on [%s].", currentAnnotation,
previousDeclaringClass.getName(), descriptor.getRootDeclaringClass().getName()));
}
}

View File

@@ -36,12 +36,14 @@ import org.springframework.util.ClassUtils;
*/
public class DelegatingSmartContextLoader extends AbstractDelegatingSmartContextLoader {
private static final String GROOVY_XML_CONTEXT_LOADER_CLASS_NAME = "org.springframework.test.context.support.GenericGroovyXmlContextLoader";
private static final String GROOVY_XML_CONTEXT_LOADER_CLASS_NAME =
"org.springframework.test.context.support.GenericGroovyXmlContextLoader";
private static final boolean groovyPresent = ClassUtils.isPresent("groovy.lang.Closure",
DelegatingSmartContextLoader.class.getClassLoader())
&& ClassUtils.isPresent(GROOVY_XML_CONTEXT_LOADER_CLASS_NAME,
DelegatingSmartContextLoader.class.getClassLoader());
DelegatingSmartContextLoader.class.getClassLoader()) &&
ClassUtils.isPresent(GROOVY_XML_CONTEXT_LOADER_CLASS_NAME,
DelegatingSmartContextLoader.class.getClassLoader());
private final SmartContextLoader xmlLoader;
private final SmartContextLoader annotationConfigLoader;
@@ -55,8 +57,8 @@ public class DelegatingSmartContextLoader extends AbstractDelegatingSmartContext
this.xmlLoader = (SmartContextLoader) BeanUtils.instantiateClass(loaderClass);
}
catch (Throwable ex) {
throw new IllegalStateException("Failed to enable support for Groovy scripts; "
+ "could not load class: " + GROOVY_XML_CONTEXT_LOADER_CLASS_NAME, ex);
throw new IllegalStateException("Failed to enable support for Groovy scripts; " +
"could not load class: " + GROOVY_XML_CONTEXT_LOADER_CLASS_NAME, ex);
}
}
else {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2024 the original author or authors.
* Copyright 2002-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -92,9 +92,9 @@ class TestPropertySourceAttributes {
*/
void mergeWith(TestPropertySourceAttributes attributes) {
Assert.state(attributes.declaringClass == this.declaringClass,
() -> "Detected @TestPropertySource declarations within an aggregate index "
+ "with different sources: " + this.declaringClass.getName() + " and "
+ attributes.declaringClass.getName());
() -> "Detected @TestPropertySource declarations within an aggregate index " +
"with different sources: " + this.declaringClass.getName() + " and " +
attributes.declaringClass.getName());
logger.trace(LogMessage.format("Retrieved %s for declaring class [%s].",
attributes, this.declaringClass.getName()));
assertSameBooleanAttribute(this.inheritLocations, attributes.inheritLocations,

View File

@@ -39,9 +39,9 @@ public class WebDelegatingSmartContextLoader extends AbstractDelegatingSmartCont
private static final String GROOVY_XML_WEB_CONTEXT_LOADER_CLASS_NAME = "org.springframework.test.context.web.GenericGroovyXmlWebContextLoader";
private static final boolean groovyPresent = ClassUtils.isPresent("groovy.lang.Closure",
WebDelegatingSmartContextLoader.class.getClassLoader())
&& ClassUtils.isPresent(GROOVY_XML_WEB_CONTEXT_LOADER_CLASS_NAME,
WebDelegatingSmartContextLoader.class.getClassLoader());
WebDelegatingSmartContextLoader.class.getClassLoader()) &&
ClassUtils.isPresent(GROOVY_XML_WEB_CONTEXT_LOADER_CLASS_NAME,
WebDelegatingSmartContextLoader.class.getClassLoader());
private final SmartContextLoader xmlLoader;
private final SmartContextLoader annotationConfigLoader;
@@ -55,8 +55,8 @@ public class WebDelegatingSmartContextLoader extends AbstractDelegatingSmartCont
this.xmlLoader = (SmartContextLoader) BeanUtils.instantiateClass(loaderClass);
}
catch (Throwable ex) {
throw new IllegalStateException("Failed to enable support for Groovy scripts; "
+ "could not load class: " + GROOVY_XML_WEB_CONTEXT_LOADER_CLASS_NAME, ex);
throw new IllegalStateException("Failed to enable support for Groovy scripts; " +
"could not load class: " + GROOVY_XML_WEB_CONTEXT_LOADER_CLASS_NAME, ex);
}
}
else {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2024 the original author or authors.
* Copyright 2002-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -41,8 +41,8 @@ public abstract class JsonAssert {
* @see JSONCompareMode#LENIENT
*/
public static JsonComparator comparator(JsonCompareMode compareMode) {
JSONCompareMode jsonAssertCompareMode = (compareMode != JsonCompareMode.LENIENT
? JSONCompareMode.STRICT : JSONCompareMode.LENIENT);
JSONCompareMode jsonAssertCompareMode = (compareMode != JsonCompareMode.LENIENT ?
JSONCompareMode.STRICT : JSONCompareMode.LENIENT);
return comparator(jsonAssertCompareMode);
}
@@ -81,18 +81,14 @@ public abstract class JsonAssert {
@Override
public JsonComparison compare(@Nullable String expectedJson, @Nullable String actualJson) {
if (actualJson == null) {
return (expectedJson != null)
? JsonComparison.mismatch("Expected null JSON")
: JsonComparison.match();
return (expectedJson != null) ? JsonComparison.mismatch("Expected null JSON") : JsonComparison.match();
}
if (expectedJson == null) {
return JsonComparison.mismatch("Expected non-null JSON");
}
try {
JSONCompareResult result = JSONCompare.compareJSON(expectedJson, actualJson, this.jsonAssertComparator);
return (!result.passed())
? JsonComparison.mismatch(result.getMessage())
: JsonComparison.match();
return (!result.passed()) ? JsonComparison.mismatch(result.getMessage()) : JsonComparison.match();
}
catch (JSONException ex) {
throw new IllegalStateException(ex);