Enable RedundantModifier checkstyle, add fixer

Add `fixModifiers.gradle` to run after `check` task.

The `RedundantModifierChecker` doesn't catch all errors at once.
We need run `check -> fixModifiers` pair several times to reach `SUCCESSFUL`.

The `fixThis` has been ported from the SA, but without applying.

* Polishing for `fixModifiers.gradle`
* Fix all redundant modifier with the `fixModifiers.gradle`

NOTE: Since all these task modify files on Windows we have to run them with the `-Dfile.encoding=UTF-8`.
Otherwise they are read and write with the Windows default `cp1251` making them incompatible with Unix system.
This commit is contained in:
Artem Bilan
2016-03-17 13:10:05 -04:00
parent 714734115a
commit c2954881ad
62 changed files with 259 additions and 141 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2016 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.
@@ -29,13 +29,13 @@ import java.util.Map;
*/
interface PublisherMetadataSource {
static final String METHOD_NAME_VARIABLE_NAME = "method";
String METHOD_NAME_VARIABLE_NAME = "method";
static final String ARGUMENT_MAP_VARIABLE_NAME = "args";
String ARGUMENT_MAP_VARIABLE_NAME = "args";
static final String RETURN_VALUE_VARIABLE_NAME = "return";
String RETURN_VALUE_VARIABLE_NAME = "return";
static final String EXCEPTION_VARIABLE_NAME = "exception";
String EXCEPTION_VARIABLE_NAME = "exception";
/**

View File

@@ -31,6 +31,6 @@ import org.springframework.messaging.MessageHandler;
*/
public interface LoadBalancingStrategy {
public Iterator<MessageHandler> getHandlerIterator(Message<?> message, Collection<MessageHandler> handlers);
Iterator<MessageHandler> getHandlerIterator(Message<?> message, Collection<MessageHandler> handlers);
}

View File

@@ -40,11 +40,11 @@ public final class MethodArgsHolder {
this.args = args;//NOSONAR - direct storage
}
public final Method getMethod() {
public Method getMethod() {
return method;
}
public final Object[] getArgs() {
public Object[] getArgs() {
return args;//NOSONAR - direct access
}

View File

@@ -37,6 +37,6 @@ public interface PostProcessingMessageHandler {
* @param message The message.
* @return The post-processed result.
*/
public Object postProcess(Message<?> message, Object result);
Object postProcess(Message<?> message, Object result);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2016 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.
@@ -76,7 +76,7 @@ public class JsonInboundMessageMapper extends AbstractJsonInboundMessageMapper<J
return null;
}
public static interface JsonMessageParser<P> {
public interface JsonMessageParser<P> {
Message<?> doInParser(JsonInboundMessageMapper messageMapper, String jsonMessage) throws Exception;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2016 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.
@@ -255,7 +255,7 @@ public class SimplePool<T> implements Pool<T> {
* various pool operations.
*
*/
public static interface PoolItemCallback<T> {
public interface PoolItemCallback<T> {
/**
* Called by the pool when a new instance is required to populate the pool. Only

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2010 the original author or authors.
* Copyright 2002-2016 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.
@@ -100,7 +100,7 @@ public class MessagePublishingInterceptorTests {
}
static interface TestBean {
interface TestBean {
String test();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2016 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.
@@ -121,14 +121,14 @@ public class PublisherAnnotationAdvisorTests {
}
static interface TestBean {
interface TestBean {
String test();
}
static interface TestVoidBean {
interface TestVoidBean {
void testVoidMethod(String s);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2016 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.
@@ -72,7 +72,7 @@ public class PublisherExpressionTests {
}
static interface TestBean {
interface TestBean {
String test(String sku);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2010 the original author or authors.
* Copyright 2002-2016 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.
@@ -52,7 +52,7 @@ public class ChannelCapacityPlaceholderTests {
}
public static interface TestService {
public interface TestService {
@org.springframework.integration.annotation.Gateway(requestChannel="channel")
void test();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2016 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.
@@ -346,7 +346,7 @@ public class MessagingAnnotationPostProcessorTests {
@MessageEndpoint
private static interface SimpleAnnotatedEndpointInterface {
private interface SimpleAnnotatedEndpointInterface {
String test(String input);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2010 the original author or authors.
* Copyright 2002-2016 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.
@@ -105,7 +105,7 @@ public class PNamespaceTests {
public interface InboundGateway {
public String echo();
String echo();
}

View File

@@ -83,7 +83,7 @@ class TimeBasedUUIDGenerator {
return new UUID(time, lsb);
}
}
private static final long getMac(){
private static long getMac(){
long macAddressAsLong = 0;
try {
InetAddress address = InetAddress.getLocalHost();

View File

@@ -397,19 +397,19 @@ public class GatewayInterfaceTests {
public interface Foo {
@Gateway(requestChannel="requestChannelFoo")
public void foo(String payload);
void foo(String payload);
public void baz(String payload);
void baz(String payload);
public String lateReply(String payload);
String lateReply(String payload);
}
public static interface Bar extends Foo {
public interface Bar extends Foo {
@Gateway(requestChannel="requestChannelBar")
public void bar(String payload);
void bar(String payload);
public void qux(String payload, @Header("name") String nameHeader);
void qux(String payload, @Header("name") String nameHeader);
}
public static class NotAnInterface {
@@ -418,7 +418,7 @@ public class GatewayInterfaceTests {
public interface Baz {
public void baz(String payload);
void baz(String payload);
}
public static class BazMapper implements MethodArgsMessageMapper {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2016 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.
@@ -163,8 +163,8 @@ public class GatewayInvokingMessageHandlerTests {
}
public static interface SimpleGateway {
public String process(String str);
public interface SimpleGateway {
String process(String str);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2016 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.
@@ -286,7 +286,7 @@ public class GatewayMethodInboundMessageMapperToMessageTests {
}
private static interface TestService {
private interface TestService {
void sendPayload(String payload);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 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.
@@ -399,13 +399,13 @@ public class GatewayProxyFactoryBeanTests {
}
static interface TestEchoService {
interface TestEchoService {
Message<?> echo(String s);
}
static interface TestExceptionThrowingInterface {
interface TestExceptionThrowingInterface {
String throwCheckedException(String s) throws TestException;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 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.
@@ -211,7 +211,7 @@ public class GatewayProxyMessageMappingTests {
}
public static interface TestGateway {
public interface TestGateway {
void payloadAndHeaderMapWithoutAnnotations(String s, Map<String, Object> map);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2016 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.
@@ -62,8 +62,8 @@ public class GatewayRequiresReplyTests {
}
public static interface TestService {
public String test(String s);
public interface TestService {
String test(String s);
}
public static class LongRunningService {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2016 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.
@@ -48,9 +48,9 @@ public class GatewayWithHeaderAnnotations {
}
public static interface TestService {
public interface TestService {
// wrt INT-1205, priority no longer has a $ prefix, so here we are testing the $custom header as well
public String test(String str, @Header(IntegrationMessageHeaderAccessor.PRIORITY) int priority,
String test(String str, @Header(IntegrationMessageHeaderAccessor.PRIORITY) int priority,
@Header("$custom") String custom);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2016 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.
@@ -76,7 +76,7 @@ public class GatewayWithPayloadExpressionTests {
}
public static interface SampleGateway {
public interface SampleGateway {
void send1(String value);
@@ -86,7 +86,7 @@ public class GatewayWithPayloadExpressionTests {
}
public static interface SampleAnnotatedGateway {
public interface SampleAnnotatedGateway {
@Payload("#args[0] + #args[1]")
void send(String value1, String value2);

View File

@@ -74,7 +74,7 @@ public class GatewayXmlAndAnnotationTests {
assertEquals(4, assertions);
}
public static interface AGateway {
public interface AGateway {
@Gateway
String annotationShouldntOverrideDefault(String foo);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2016 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.
@@ -106,13 +106,13 @@ public class HeaderEnrichedGatewayTests {
}
public static interface SampleGateway {
public interface SampleGateway {
public void sendString(String value);
void sendString(String value);
public void sendInteger(Integer value);
void sendInteger(Integer value);
public void sendStringWithParameterHeaders(String value,
void sendStringWithParameterHeaders(String value,
@Header("headerA") String headerA, @Header("headerB") String headerB);
}

View File

@@ -110,7 +110,7 @@ public class InnerGatewayWithChainTests {
verify(handler, times(1)).handleMessage(Mockito.any(Message.class));
}
public static interface TestGateway{
public String echo(int value);
public interface TestGateway{
String echo(int value);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2016 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.
@@ -70,10 +70,10 @@ public class MultiMethodGatewayConfigTests {
}
}
public static interface TestGateway {
public String echo(String str);
public String echoViaDefault(String str);
public String echoUpperCase(String str);
public interface TestGateway {
String echo(String str);
String echoViaDefault(String str);
String echoUpperCase(String str);
}
}

View File

@@ -58,8 +58,8 @@ public class MultipleEndpointGatewayTests {
// there is nothing to assert. Successful execution of the above is all we care in this test
}
public static interface SampleGateway{
public Object echo(Object value);
public interface SampleGateway{
Object echo(Object value);
}
public static class SampleEchoService {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2009 the original author or authors.
* Copyright 2002-2016 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.
@@ -58,7 +58,7 @@ public class MockHandlerTests {
}
public static interface TestInterface {
public interface TestInterface {
String test(String input);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2016 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.
@@ -249,8 +249,8 @@ public class MessageHistoryIntegrationTests {
System.out.println("Elapsed time without history 10000 calls: " + stopWatch.getTotalTimeSeconds());
}
public static interface SampleGateway {
public Message<?> echo(String value);
public interface SampleGateway {
Message<?> echo(String value);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2009 the original author or authors.
* Copyright 2002-2016 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.
@@ -84,12 +84,12 @@ public class HeaderValueRouterParserTests {
}
public static interface TestServiceA {
public void foo(Message<?> message);
public interface TestServiceA {
void foo(Message<?> message);
}
public static interface TestServiceB {
public void foo(Message<?> message);
public interface TestServiceB {
void foo(Message<?> message);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2010 the original author or authors.
* Copyright 2002-2016 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.
@@ -106,8 +106,8 @@ public class PayloadTypeRouterParserTests {
"</beans:beans>";
public static interface TestService{
public void foo(Message<?> message);
public interface TestService{
void foo(Message<?> message);
}
}

View File

@@ -91,7 +91,7 @@ public class MutableMessageBuilderFactoryTests {
}
@MessagingGateway
static interface TestGateway {
interface TestGateway {
@Gateway(requestChannel = "input")
void input(String payload);