Commit 893a6c32 authored by Phillip Webb's avatar Phillip Webb

Upgrade to checkstyle 6.17

Fixes gh-5547
parent 4f200a85
...@@ -134,8 +134,8 @@ public class DataSourceAutoConfigurationTests { ...@@ -134,8 +134,8 @@ public class DataSourceAutoConfigurationTests {
public void hikariValidatesConnectionByDefault() throws Exception { public void hikariValidatesConnectionByDefault() throws Exception {
HikariDataSource dataSource = autoConfigureDataSource(HikariDataSource.class, HikariDataSource dataSource = autoConfigureDataSource(HikariDataSource.class,
"org.apache.tomcat"); "org.apache.tomcat");
assertThat(dataSource.getConnectionTestQuery()).isNull(); // Use assertThat(dataSource.getConnectionTestQuery()).isNull();
// Connection#isValid() // Use Connection#isValid()
} }
@Test @Test
......
...@@ -37,6 +37,7 @@ public @interface DependencyManagementBom { ...@@ -37,6 +37,7 @@ public @interface DependencyManagementBom {
* One or more sets of colon-separated coordinates ({@code group:module:version}) of a * One or more sets of colon-separated coordinates ({@code group:module:version}) of a
* Maven bom that contains dependency management that will add to and override the * Maven bom that contains dependency management that will add to and override the
* default dependency management. * default dependency management.
* @return the BOM coordinates
*/ */
String[] value(); String[] value();
......
...@@ -141,10 +141,10 @@ public class FileSystemWatcher { ...@@ -141,10 +141,10 @@ public class FileSystemWatcher {
this.watchThread = new Thread() { this.watchThread = new Thread() {
@Override @Override
public void run() { public void run() {
int remainingScans = FileSystemWatcher.this.remainingScans.get(); int remaining = FileSystemWatcher.this.remainingScans.get();
while (remainingScans > 0 || remainingScans == -1) { while (remaining > 0 || remaining == -1) {
try { try {
if (remainingScans > 0) { if (remaining > 0) {
FileSystemWatcher.this.remainingScans.decrementAndGet(); FileSystemWatcher.this.remainingScans.decrementAndGet();
} }
scan(); scan();
...@@ -152,7 +152,7 @@ public class FileSystemWatcher { ...@@ -152,7 +152,7 @@ public class FileSystemWatcher {
catch (InterruptedException ex) { catch (InterruptedException ex) {
// Ignore // Ignore
} }
remainingScans = FileSystemWatcher.this.remainingScans.get(); remaining = FileSystemWatcher.this.remainingScans.get();
} }
}; };
}; };
......
...@@ -244,12 +244,12 @@ ...@@ -244,12 +244,12 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId> <artifactId>maven-checkstyle-plugin</artifactId>
<version>2.16</version> <version>2.17</version>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>com.puppycrawl.tools</groupId> <groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId> <artifactId>checkstyle</artifactId>
<version>6.10.1</version> <version>6.17</version>
</dependency> </dependency>
</dependencies> </dependencies>
</plugin> </plugin>
......
...@@ -20,22 +20,4 @@ ...@@ -20,22 +20,4 @@
<suppress files="Ansi.*\.java" checks="JavadocStyle" /> <suppress files="Ansi.*\.java" checks="JavadocStyle" />
<suppress files="LogLevel\.java" checks="JavadocVariable" /> <suppress files="LogLevel\.java" checks="JavadocVariable" />
<suppress files="HelpMojo\.java" checks=".*"/> <suppress files="HelpMojo\.java" checks=".*"/>
<!-- https://github.com/checkstyle/checkstyle/issues/2141 -->
<suppress files="ConfigurationProperties.java" checks="JavadocMethod" />
<suppress files="DeprecatedConfigurationProperty\.java" checks="JavadocMethod" />
<suppress files="EnableConfigurationProperties\.java" checks="JavadocMethod" />
<suppress files="EntityScan\.java" checks="JavadocMethod" />
<suppress files="SpringApplication\.java" checks="JavadocMethod" />
<suppress files="IntegrationTest\.java" checks="JavadocMethod" />
<suppress files="SpringApplicationConfiguration\.java" checks="JavadocMethod" />
<suppress files="WebIntegrationTest\.java" checks="JavadocMethod" />
<suppress files="ServletComponentScan\.java" checks="JavadocMethod" />
<suppress files="AutoConfigureAfter\.java" checks="JavadocMethod" />
<suppress files="AutoConfigureBefore\.java" checks="JavadocMethod" />
<suppress files="ConditionalOn.*\.java" checks="JavadocMethod" />
<suppress files="AutoConfigureOrder.java" checks="JavadocMethod" />
<suppress files="EnableAutoConfiguration.java" checks="JavadocMethod" />
<suppress files="SpringBootApplication.java" checks="JavadocMethod" />
<suppress files="ImportAutoConfiguration.java" checks="JavadocMethod" />
</suppressions> </suppressions>
...@@ -114,7 +114,9 @@ ...@@ -114,7 +114,9 @@
</module> </module>
<!-- Miscellaneous --> <!-- Miscellaneous -->
<module name="CommentsIndentation" /> <module name="CommentsIndentation">
<property name="tokens" value="BLOCK_COMMENT_BEGIN"/>
</module>
<module name="UpperEll" /> <module name="UpperEll" />
<module name="ArrayTypeStyle" /> <module name="ArrayTypeStyle" />
<module name="OuterTypeFilename" /> <module name="OuterTypeFilename" />
......
...@@ -43,6 +43,7 @@ public @interface OverrideAutoConfiguration { ...@@ -43,6 +43,7 @@ public @interface OverrideAutoConfiguration {
/** /**
* The value of the {@link EnableAutoConfiguration#ENABLED_OVERRIDE_PROPERTY enabled * The value of the {@link EnableAutoConfiguration#ENABLED_OVERRIDE_PROPERTY enabled
* property override}. * property override}.
* @return the override value
*/ */
boolean enabled(); boolean enabled();
......
...@@ -103,8 +103,10 @@ public abstract class AnnotationCustomizableTypeExcludeFilter extends TypeExclud ...@@ -103,8 +103,10 @@ public abstract class AnnotationCustomizableTypeExcludeFilter extends TypeExclud
protected abstract Set<Class<?>> getDefaultIncludes(); protected abstract Set<Class<?>> getDefaultIncludes();
protected static enum FilterType { protected enum FilterType {
INCLUDE, EXCLUDE INCLUDE, EXCLUDE
}; };
} }
...@@ -45,6 +45,7 @@ public @interface TypeExcludeFilters { ...@@ -45,6 +45,7 @@ public @interface TypeExcludeFilters {
* specified here can either have a no-arg constructor or accept a single * specified here can either have a no-arg constructor or accept a single
* {@code Class<?>} argument if then need access to the {@code testClass}. * {@code Class<?>} argument if then need access to the {@code testClass}.
* @see TypeExcludeFilter * @see TypeExcludeFilter
* @return the type exclude filters to apply
*/ */
Class<? extends TypeExcludeFilter>[] value(); Class<? extends TypeExcludeFilter>[] value();
......
...@@ -52,6 +52,7 @@ public @interface AutoConfigureJsonTesters { ...@@ -52,6 +52,7 @@ public @interface AutoConfigureJsonTesters {
/** /**
* If {@link BasicJsonTester}, {@link JacksonTester} and {@link GsonTester} fields * If {@link BasicJsonTester}, {@link JacksonTester} and {@link GsonTester} fields
* should be initialized using marshallers from the {@link ApplicationContext}. * should be initialized using marshallers from the {@link ApplicationContext}.
* @return if JSON tester fields should be initialized
*/ */
boolean initFields() default true; boolean initFields() default true;
......
...@@ -47,18 +47,22 @@ public @interface JsonTest { ...@@ -47,18 +47,22 @@ public @interface JsonTest {
* {@code @JsonComponent} and {@code Module} beans are included. * {@code @JsonComponent} and {@code Module} beans are included.
* @see #includeFilters() * @see #includeFilters()
* @see #excludeFilters() * @see #excludeFilters()
* @return if default filters should be used
*/ */
boolean useDefaultFilters() default true; boolean useDefaultFilters() default true;
/** /**
* A set of include filters which can be used to add otherwise filtered beans to the * A set of include filters which can be used to add otherwise filtered beans to the
* application context. * application context.
* @return include filters to apply
*/ */
Filter[] includeFilters() default {}; Filter[] includeFilters() default {};
/** /**
* A set of exclude filters which can be used to filter beans that would otherwise be * A set of exclude filters which can be used to filter beans that would otherwise be
* added to the application context. * added to the application context.
* @return exclude filters to apply
*/ */
Filter[] excludeFilters() default {}; Filter[] excludeFilters() default {};
} }
...@@ -43,13 +43,15 @@ import org.springframework.boot.test.autoconfigure.properties.PropertyMapping; ...@@ -43,13 +43,15 @@ import org.springframework.boot.test.autoconfigure.properties.PropertyMapping;
public @interface AutoConfigureTestDatabase { public @interface AutoConfigureTestDatabase {
/** /**
* If the test database should replace any existing. * Determines what type of existing DataSource beans can be replaced.
* @return the type of existing DataSource to replace
*/ */
Replace replace() default Replace.ANY; Replace replace() default Replace.ANY;
/** /**
* The type of connection to be establish when {@link #replace() replacing} the data * The type of connection to be establish when {@link #replace() replacing} the data
* source. By default will attempt to detect the connection based on the classpath. * source. By default will attempt to detect the connection based on the classpath.
* @return the type of connection to use
*/ */
EmbeddedDatabaseConnection connection() default EmbeddedDatabaseConnection.NONE; EmbeddedDatabaseConnection connection() default EmbeddedDatabaseConnection.NONE;
......
...@@ -69,6 +69,7 @@ public @interface DataJpaTest { ...@@ -69,6 +69,7 @@ public @interface DataJpaTest {
/** /**
* If SQL output should be logged. * If SQL output should be logged.
* @return if SQL is logged
*/ */
@PropertyMapping("spring.jpa.show-sql") @PropertyMapping("spring.jpa.show-sql")
boolean showSql() default true; boolean showSql() default true;
...@@ -79,18 +80,21 @@ public @interface DataJpaTest { ...@@ -79,18 +80,21 @@ public @interface DataJpaTest {
* included. * included.
* @see #includeFilters() * @see #includeFilters()
* @see #excludeFilters() * @see #excludeFilters()
* @return if default filters should be used
*/ */
boolean useDefaultFilters() default true; boolean useDefaultFilters() default true;
/** /**
* A set of include filters which can be used to add otherwise filtered beans to the * A set of include filters which can be used to add otherwise filtered beans to the
* application context. * application context.
* @return include filters to apply
*/ */
Filter[] includeFilters() default {}; Filter[] includeFilters() default {};
/** /**
* A set of exclude filters which can be used to filter beans that would otherwise be * A set of exclude filters which can be used to filter beans that would otherwise be
* added to the application context. * added to the application context.
* @return exclude filters to apply
*/ */
Filter[] excludeFilters() default {}; Filter[] excludeFilters() default {};
......
...@@ -58,6 +58,7 @@ public @interface PropertyMapping { ...@@ -58,6 +58,7 @@ public @interface PropertyMapping {
* Defines the property mapping. When used at the type-level, this value will be used * Defines the property mapping. When used at the type-level, this value will be used
* as a prefix for all mapped attributes. When used on an attribute, the value * as a prefix for all mapped attributes. When used on an attribute, the value
* overrides the generated (kebab case) name. * overrides the generated (kebab case) name.
* @return the property mapping
*/ */
String value() default ""; String value() default "";
...@@ -65,6 +66,7 @@ public @interface PropertyMapping { ...@@ -65,6 +66,7 @@ public @interface PropertyMapping {
* Determines if mapping should occur. When specified at the type-level indicates if * Determines if mapping should occur. When specified at the type-level indicates if
* mapping should occur by default or not. When used at the attribute-level, overrides * mapping should occur by default or not. When used at the attribute-level, overrides
* the type-level default. * the type-level default.
* @return if mapping should occur
*/ */
boolean map() default true; boolean map() default true;
......
...@@ -51,18 +51,21 @@ public @interface AutoConfigureMockMvc { ...@@ -51,18 +51,21 @@ public @interface AutoConfigureMockMvc {
/** /**
* If filters from the application context should be registered with MockMVC. Defaults * If filters from the application context should be registered with MockMVC. Defaults
* to {@code true}. * to {@code true}.
* @return if filters should be added
*/ */
boolean addFilters() default true; boolean addFilters() default true;
/** /**
* If {@link MvcResult} information should always be printed after each MockMVC * If {@link MvcResult} information should always be printed after each MockMVC
* invocation. Defaults to {@code true}. * invocation. Defaults to {@code true}.
* @return if result information is always printed
*/ */
boolean alwaysPrint() default true; boolean alwaysPrint() default true;
/** /**
* If a {@link WebClient} should be auto-configured when HtmlUnit is on the classpath. * If a {@link WebClient} should be auto-configured when HtmlUnit is on the classpath.
* Defaults to {@code true}. * Defaults to {@code true}.
* @return if a {@link WebClient} is auto-configured
*/ */
@PropertyMapping("webclient.enabled") @PropertyMapping("webclient.enabled")
boolean webClientEnabled() default true; boolean webClientEnabled() default true;
...@@ -70,6 +73,7 @@ public @interface AutoConfigureMockMvc { ...@@ -70,6 +73,7 @@ public @interface AutoConfigureMockMvc {
/** /**
* If a {@link WebDriver} should be auto-configured when Selenium is on the classpath. * If a {@link WebDriver} should be auto-configured when Selenium is on the classpath.
* Defaults to {@code true}. * Defaults to {@code true}.
* @return if a {@link WebDriver} is auto-configured
*/ */
@PropertyMapping("webdriver.enabled") @PropertyMapping("webdriver.enabled")
boolean webDriverEnabled() default true; boolean webDriverEnabled() default true;
......
...@@ -78,6 +78,7 @@ public @interface WebMvcTest { ...@@ -78,6 +78,7 @@ public @interface WebMvcTest {
* can be used for brevity if no other attributes are defined. See * can be used for brevity if no other attributes are defined. See
* {@link #controllers()} for details. * {@link #controllers()} for details.
* @see #controllers() * @see #controllers()
* @return the controllers to test
*/ */
@AliasFor("controllers") @AliasFor("controllers")
Class<?>[] value() default {}; Class<?>[] value() default {};
...@@ -86,6 +87,7 @@ public @interface WebMvcTest { ...@@ -86,6 +87,7 @@ public @interface WebMvcTest {
* Specifies the controllers to test. May be left blank if all {@code @Controller} * Specifies the controllers to test. May be left blank if all {@code @Controller}
* beans should be added to the application context. * beans should be added to the application context.
* @see #value() * @see #value()
* @return the controllers to test
*/ */
@AliasFor("value") @AliasFor("value")
Class<?>[] controllers() default {}; Class<?>[] controllers() default {};
...@@ -98,18 +100,21 @@ public @interface WebMvcTest { ...@@ -98,18 +100,21 @@ public @interface WebMvcTest {
* included. * included.
* @see #includeFilters() * @see #includeFilters()
* @see #excludeFilters() * @see #excludeFilters()
* @return if default filters should be used
*/ */
boolean useDefaultFilters() default true; boolean useDefaultFilters() default true;
/** /**
* A set of include filters which can be used to add otherwise filtered beans to the * A set of include filters which can be used to add otherwise filtered beans to the
* application context. * application context.
* @return include filters to apply
*/ */
Filter[] includeFilters() default {}; Filter[] includeFilters() default {};
/** /**
* A set of exclude filters which can be used to filter beans that would otherwise be * A set of exclude filters which can be used to filter beans that would otherwise be
* added to the application context. * added to the application context.
* @return exclude filters to apply
*/ */
Filter[] excludeFilters() default {}; Filter[] excludeFilters() default {};
......
...@@ -61,6 +61,7 @@ public @interface SpringApplicationTest { ...@@ -61,6 +61,7 @@ public @interface SpringApplicationTest {
/** /**
* Properties in form {@literal key=value} that should be added to the Spring * Properties in form {@literal key=value} that should be added to the Spring
* {@link Environment} before the test runs. * {@link Environment} before the test runs.
* @return the properties to add
*/ */
String[] value() default {}; String[] value() default {};
......
...@@ -48,6 +48,7 @@ public @interface TestComponent { ...@@ -48,6 +48,7 @@ public @interface TestComponent {
/** /**
* The value may indicate a suggestion for a logical component name, to be turned into * The value may indicate a suggestion for a logical component name, to be turned into
* a Spring bean in case of an auto-detected component. * a Spring bean in case of an auto-detected component.
* @return the specified bean name, if any
*/ */
String value() default ""; String value() default "";
......
...@@ -45,6 +45,7 @@ public @interface TestConfiguration { ...@@ -45,6 +45,7 @@ public @interface TestConfiguration {
/** /**
* Explicitly specify the name of the Spring bean definition associated with this * Explicitly specify the name of the Spring bean definition associated with this
* Configuration class. See {@link Configuration#value()} for details. * Configuration class. See {@link Configuration#value()} for details.
* @return the specified bean name, if any
*/ */
String value() default ""; String value() default "";
......
...@@ -85,12 +85,14 @@ public @interface MockBean { ...@@ -85,12 +85,14 @@ public @interface MockBean {
* The name of the bean that should be registered with the application context. If not * The name of the bean that should be registered with the application context. If not
* specified the name will either be generated or, if the mock replaces an existing * specified the name will either be generated or, if the mock replaces an existing
* bean, the existing name will be used. * bean, the existing name will be used.
* @return the name of the bean
*/ */
String name() default ""; String name() default "";
/** /**
* The classes to mock. This is an alias of {@link #classes()} which can be used for * The classes to mock. This is an alias of {@link #classes()} which can be used for
* brevity if no other attributes are defined. See {@link #classes()} for details. * brevity if no other attributes are defined. See {@link #classes()} for details.
* @return the classes to mock
*/ */
@AliasFor("classes") @AliasFor("classes")
Class<?>[] value() default {}; Class<?>[] value() default {};
...@@ -105,6 +107,7 @@ public @interface MockBean { ...@@ -105,6 +107,7 @@ public @interface MockBean {
* <p> * <p>
* If this is the only attribute specified consider using the {@code value} alias * If this is the only attribute specified consider using the {@code value} alias
* instead. * instead.
* @return the classes to mock
*/ */
@AliasFor("value") @AliasFor("value")
Class<?>[] classes() default {}; Class<?>[] classes() default {};
...@@ -112,23 +115,27 @@ public @interface MockBean { ...@@ -112,23 +115,27 @@ public @interface MockBean {
/** /**
* Any extra interfaces that should also be declared on the mock. See * Any extra interfaces that should also be declared on the mock. See
* {@link MockSettings#extraInterfaces(Class...)} for details. * {@link MockSettings#extraInterfaces(Class...)} for details.
* @return any extra interfaces
*/ */
Class<?>[] extraInterfaces() default {}; Class<?>[] extraInterfaces() default {};
/** /**
* The {@link Answers} type to use on the mock. * The {@link Answers} type to use on the mock.
* @return the answer type
*/ */
Answers answer() default Answers.RETURNS_DEFAULTS; Answers answer() default Answers.RETURNS_DEFAULTS;
/** /**
* If the generated mock is serializable. See {@link MockSettings#serializable()} for * If the generated mock is serializable. See {@link MockSettings#serializable()} for
* details. * details.
* @return if the mock is serializable
*/ */
boolean serializable() default false; boolean serializable() default false;
/** /**
* The reset mode to apply to the mock bean. The default is {@link MockReset#AFTER} * The reset mode to apply to the mock bean. The default is {@link MockReset#AFTER}
* meaning that mocks are automatically reset after each test method is invoked. * meaning that mocks are automatically reset after each test method is invoked.
* @return the reset mode
*/ */
MockReset reset() default MockReset.AFTER; MockReset reset() default MockReset.AFTER;
......
...@@ -40,6 +40,7 @@ public @interface MockBeans { ...@@ -40,6 +40,7 @@ public @interface MockBeans {
/** /**
* Return the contained {@link MockBean} annotations. * Return the contained {@link MockBean} annotations.
* @return the mock beans
*/ */
MockBean[] value(); MockBean[] value();
......
...@@ -240,30 +240,31 @@ public class RepackageTask extends DefaultTask { ...@@ -240,30 +240,31 @@ public class RepackageTask extends DefaultTask {
} }
private void setMainClass(Repackager repackager) { private void setMainClass(Repackager repackager) {
String mainClass; String mainClassName = getMainClassNameProperty();
if (getProject().hasProperty("mainClassName")) {
mainClass = (String) getProject().property("mainClassName");
}
else {
ExtraPropertiesExtension extraProperties = (ExtraPropertiesExtension) getProject()
.getExtensions().getByName("ext");
mainClass = (String) extraProperties.get("mainClassName");
}
if (RepackageTask.this.mainClass != null) { if (RepackageTask.this.mainClass != null) {
mainClass = RepackageTask.this.mainClass; mainClassName = RepackageTask.this.mainClass;
} }
else if (this.extension.getMainClass() != null) { else if (this.extension.getMainClass() != null) {
mainClass = this.extension.getMainClass(); mainClassName = this.extension.getMainClass();
} }
else { else {
Task runTask = getProject().getTasks().findByName("run"); Task runTask = getProject().getTasks().findByName("run");
if (runTask != null && runTask.hasProperty("main")) { if (runTask != null && runTask.hasProperty("main")) {
mainClass = (String) getProject().getTasks().getByName("run") mainClassName = (String) getProject().getTasks().getByName("run")
.property("main"); .property("main");
} }
} }
getLogger().info("Setting mainClass: " + mainClass); getLogger().info("Setting mainClass: " + mainClassName);
repackager.setMainClass(mainClass); repackager.setMainClass(mainClassName);
}
private String getMainClassNameProperty() {
if (getProject().hasProperty("mainClassName")) {
return (String) getProject().property("mainClassName");
}
ExtraPropertiesExtension extraProperties = (ExtraPropertiesExtension) getProject()
.getExtensions().getByName("ext");
return (String) extraProperties.get("mainClassName");
} }
private LaunchScript getLaunchScript() throws IOException { private LaunchScript getLaunchScript() throws IOException {
......
...@@ -65,6 +65,7 @@ public @interface JsonComponent { ...@@ -65,6 +65,7 @@ public @interface JsonComponent {
/** /**
* The value may indicate a suggestion for a logical component name, to be turned into * The value may indicate a suggestion for a logical component name, to be turned into
* a Spring bean in case of an autodetected component. * a Spring bean in case of an autodetected component.
* @return the component name
*/ */
String value() default ""; String value() default "";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment