Sonar fixes

- a few complexities
- final method calls from ctor
- raw exception throwing
- useless overrides
- loss of stack trace
This commit is contained in:
Gary Russell
2019-04-29 16:34:39 -04:00
committed by Artem Bilan
parent 7569d0ad79
commit 36c33bb5ab
45 changed files with 134 additions and 114 deletions

View File

@@ -46,14 +46,14 @@ import org.springframework.util.Base64Utils;
* @since 5.0
*
*/
public class TestMailServer {
public final class TestMailServer {
public static SmtpServer smtp(int port) {
try {
return new SmtpServer(port);
}
catch (IOException e) {
throw new RuntimeException(e);
throw new IllegalStateException(e);
}
}
@@ -62,7 +62,7 @@ public class TestMailServer {
return new Pop3Server(port);
}
catch (IOException e) {
throw new RuntimeException(e);
throw new IllegalStateException(e);
}
}
@@ -71,7 +71,7 @@ public class TestMailServer {
return new ImapServer(port);
}
catch (IOException e) {
throw new RuntimeException(e);
throw new IllegalStateException(e);
}
}

View File

@@ -70,7 +70,7 @@ import org.springframework.messaging.MessageHeaders;
* @author Gary Russell
*
*/
public class HeaderMatcher<T> extends TypeSafeMatcher<Message<T>> {
public final class HeaderMatcher<T> extends TypeSafeMatcher<Message<T>> {
private final Matcher<?> matcher;

View File

@@ -61,9 +61,10 @@ import org.hamcrest.core.AllOf;
* @author Iwein Fuld
* @author Gunnar Hillert
* @author Artem Bilan
* @author Gary Russell
*
*/
public class MapContentMatchers<T, V> extends TypeSafeMatcher<Map<? super T, ? super V>> {
public final class MapContentMatchers<T, V> extends TypeSafeMatcher<Map<? super T, ? super V>> {
private final T key;

View File

@@ -64,7 +64,7 @@ import org.springframework.messaging.Message;
* @author Artem Bilan
*
*/
public class MockitoMessageMatchers {
public final class MockitoMessageMatchers {
private MockitoMessageMatchers() {
super();

View File

@@ -49,7 +49,7 @@ import org.springframework.messaging.MessageHeaders;
* @author Gary Russell
*
*/
public class PayloadAndHeaderMatcher<T> extends BaseMatcher<Message<?>> {
public final class PayloadAndHeaderMatcher<T> extends BaseMatcher<Message<?>> {
private final T payload;

View File

@@ -57,7 +57,7 @@ import org.springframework.messaging.Message;
* @author Gary Russell
*
*/
public class PayloadMatcher<T> extends TypeSafeMatcher<Message<?>> {
public final class PayloadMatcher<T> extends TypeSafeMatcher<Message<?>> {
private final Matcher<T> matcher;

View File

@@ -42,11 +42,12 @@ import org.springframework.util.ObjectUtils;
* enabling debug logging for a test case.
*
* @author Artem Bilan
* @author Gary Russell
*
* @since 5.0.1
*
*/
public class Log4j2LevelAdjuster implements MethodRule {
public final class Log4j2LevelAdjuster implements MethodRule {
private static final Log logger = LogFactory.getLog(Log4j2LevelAdjuster.class);

View File

@@ -97,11 +97,12 @@ public class OnlyOnceTrigger implements Trigger {
public void await() {
try {
if (!this.latch.await(10000, TimeUnit.MILLISECONDS)) {
throw new RuntimeException("test latch.await() did not count down");
throw new IllegalStateException("test latch.await() did not count down");
}
}
catch (InterruptedException e) {
throw new RuntimeException("test latch.await() interrupted");
Thread.currentThread().interrupt();
throw new IllegalStateException("test latch.await() interrupted", e);
}
}

View File

@@ -257,7 +257,7 @@ public abstract class TestUtils {
logger.warn("Error message was not delivered.", errorDeliveryError);
}
if (errorDeliveryError instanceof Error) {
throw ((Error) errorDeliveryError);
throw ((Error) errorDeliveryError); // NOSONAR
}
}
}