aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-core
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2018-01-10 21:14:52 +0100
committerSimon Brandhof <simon.brandhof@sonarsource.com>2018-01-14 20:37:37 +0100
commitd55f047c445daf698ccde5f0af9d0669804c818b (patch)
tree990d01ddad6fd40aff012e1f40bfc8ce77918670 /sonar-core
parent4a5be9fbaba0b9729e909eec935852c56f6e71e2 (diff)
downloadsonarqube-d55f047c445daf698ccde5f0af9d0669804c818b.tar.gz
sonarqube-d55f047c445daf698ccde5f0af9d0669804c818b.zip
Cleanup code based on Intellij inspections
Diffstat (limited to 'sonar-core')
-rw-r--r--sonar-core/src/main/java/org/sonar/core/issue/DefaultIssue.java2
-rw-r--r--sonar-core/src/main/java/org/sonar/core/util/CloseableIterator.java4
-rw-r--r--sonar-core/src/main/java/org/sonar/core/util/logs/DefaultProfiler.java5
-rw-r--r--sonar-core/src/test/java/org/sonar/core/i18n/I18nClassloaderTest.java2
-rw-r--r--sonar-core/src/test/java/org/sonar/core/util/CloseableIteratorTest.java6
-rw-r--r--sonar-core/src/test/java/org/sonar/core/util/ContextExceptionTest.java16
-rw-r--r--sonar-core/src/test/java/org/sonar/core/util/HttpsTrustTest.java2
-rw-r--r--sonar-core/src/test/java/org/sonar/core/util/MacAddressProviderTest.java2
-rw-r--r--sonar-core/src/test/java/org/sonar/core/util/ProgressLoggerTest.java2
-rw-r--r--sonar-core/src/test/java/org/sonar/core/util/ProtobufJsonFormatTest.java2
-rw-r--r--sonar-core/src/test/java/org/sonar/core/util/UuidFactoryFastTest.java2
-rw-r--r--sonar-core/src/test/java/org/sonar/core/util/UuidFactoryImplTest.java2
-rw-r--r--sonar-core/src/test/java/org/sonar/core/util/logs/DefaultProfilerTest.java2
13 files changed, 23 insertions, 26 deletions
diff --git a/sonar-core/src/main/java/org/sonar/core/issue/DefaultIssue.java b/sonar-core/src/main/java/org/sonar/core/issue/DefaultIssue.java
index b4cee97eb91..3192a5304bc 100644
--- a/sonar-core/src/main/java/org/sonar/core/issue/DefaultIssue.java
+++ b/sonar-core/src/main/java/org/sonar/core/issue/DefaultIssue.java
@@ -482,7 +482,7 @@ public class DefaultIssue implements Issue, Trackable, org.sonar.api.ce.measure.
@Override
public Map<String, String> attributes() {
- return attributes == null ? Collections.<String, String>emptyMap() : ImmutableMap.copyOf(attributes);
+ return attributes == null ? Collections.emptyMap() : ImmutableMap.copyOf(attributes);
}
public DefaultIssue setAttributes(@Nullable Map<String, String> map) {
diff --git a/sonar-core/src/main/java/org/sonar/core/util/CloseableIterator.java b/sonar-core/src/main/java/org/sonar/core/util/CloseableIterator.java
index 539e66f575a..2bf436033ed 100644
--- a/sonar-core/src/main/java/org/sonar/core/util/CloseableIterator.java
+++ b/sonar-core/src/main/java/org/sonar/core/util/CloseableIterator.java
@@ -46,7 +46,7 @@ public abstract class CloseableIterator<O> implements Iterator<O>, AutoCloseable
}
@Override
- protected void doClose() throws Exception {
+ protected void doClose() {
// do nothing
}
};
@@ -173,7 +173,7 @@ public abstract class CloseableIterator<O> implements Iterator<O>, AutoCloseable
}
@Override
- protected void doClose() throws Exception {
+ protected void doClose() {
// do nothing
}
}
diff --git a/sonar-core/src/main/java/org/sonar/core/util/logs/DefaultProfiler.java b/sonar-core/src/main/java/org/sonar/core/util/logs/DefaultProfiler.java
index 99664224b35..be8d33be3ae 100644
--- a/sonar-core/src/main/java/org/sonar/core/util/logs/DefaultProfiler.java
+++ b/sonar-core/src/main/java/org/sonar/core/util/logs/DefaultProfiler.java
@@ -283,10 +283,7 @@ class DefaultProfiler extends Profiler {
if (level == LoggerLevel.TRACE && !logger.isTraceEnabled()) {
return false;
}
- if (level == LoggerLevel.DEBUG && !logger.isDebugEnabled()) {
- return false;
- }
- return true;
+ return level != LoggerLevel.DEBUG || logger.isDebugEnabled();
}
@Override
diff --git a/sonar-core/src/test/java/org/sonar/core/i18n/I18nClassloaderTest.java b/sonar-core/src/test/java/org/sonar/core/i18n/I18nClassloaderTest.java
index 8e6a0c94367..60046991b57 100644
--- a/sonar-core/src/test/java/org/sonar/core/i18n/I18nClassloaderTest.java
+++ b/sonar-core/src/test/java/org/sonar/core/i18n/I18nClassloaderTest.java
@@ -46,7 +46,7 @@ public class I18nClassloaderTest {
public void aggregate_plugin_classloaders() {
URLClassLoader checkstyle = newCheckstyleClassloader();
- I18nClassloader i18nClassloader = new I18nClassloader(Lists.<ClassLoader>newArrayList(checkstyle));
+ I18nClassloader i18nClassloader = new I18nClassloader(Lists.newArrayList(checkstyle));
assertThat(i18nClassloader.getResource("org/sonar/l10n/checkstyle.properties")).isNotNull();
assertThat(i18nClassloader.getResource("org/sonar/l10n/checkstyle.properties").getFile()).endsWith("checkstyle.properties");
}
diff --git a/sonar-core/src/test/java/org/sonar/core/util/CloseableIteratorTest.java b/sonar-core/src/test/java/org/sonar/core/util/CloseableIteratorTest.java
index d36d07131a4..507339e1ed5 100644
--- a/sonar-core/src/test/java/org/sonar/core/util/CloseableIteratorTest.java
+++ b/sonar-core/src/test/java/org/sonar/core/util/CloseableIteratorTest.java
@@ -160,13 +160,13 @@ public class CloseableIteratorTest {
}
@Test(expected = IllegalArgumentException.class)
- public void wrap_fails_if_iterator_declared_in_other_closeables() throws Exception {
+ public void wrap_fails_if_iterator_declared_in_other_closeables() {
CloseableIterator iterator = new SimpleCloseableIterator();
CloseableIterator.wrap(iterator, iterator);
}
@Test(expected = NullPointerException.class)
- public void wrap_fails_if_null_closeable() throws Exception {
+ public void wrap_fails_if_null_closeable() {
CloseableIterator.wrap(new SimpleCloseableIterator(), null);
}
@@ -189,7 +189,7 @@ public class CloseableIteratorTest {
}
@Override
- public void close() throws IOException {
+ public void close() {
// no need to implement it for real
}
}
diff --git a/sonar-core/src/test/java/org/sonar/core/util/ContextExceptionTest.java b/sonar-core/src/test/java/org/sonar/core/util/ContextExceptionTest.java
index 470a99b93ff..33d5de76398 100644
--- a/sonar-core/src/test/java/org/sonar/core/util/ContextExceptionTest.java
+++ b/sonar-core/src/test/java/org/sonar/core/util/ContextExceptionTest.java
@@ -28,7 +28,7 @@ public class ContextExceptionTest {
public static final String LABEL = "something wrong";
@Test
- public void only_label() throws Exception {
+ public void only_label() {
ContextException e = ContextException.of(LABEL);
assertThat(e.getMessage()).isEqualTo(LABEL);
assertThat(e.getRawMessage()).isEqualTo(LABEL);
@@ -36,7 +36,7 @@ public class ContextExceptionTest {
}
@Test
- public void only_cause() throws Exception {
+ public void only_cause() {
Exception cause = new Exception("cause");
ContextException e = ContextException.of(cause);
assertThat(e.getMessage()).isEqualTo("java.lang.Exception: cause");
@@ -45,7 +45,7 @@ public class ContextExceptionTest {
}
@Test
- public void cause_and_message() throws Exception {
+ public void cause_and_message() {
Exception cause = new Exception("cause");
ContextException e = ContextException.of(LABEL, cause);
assertThat(e.getMessage()).isEqualTo(LABEL);
@@ -54,7 +54,7 @@ public class ContextExceptionTest {
}
@Test
- public void addContext() throws Exception {
+ public void addContext() {
ContextException e = ContextException.of(LABEL)
.addContext("K1", "V1")
.addContext("K2", "V2");
@@ -62,7 +62,7 @@ public class ContextExceptionTest {
}
@Test
- public void setContext() throws Exception {
+ public void setContext() {
ContextException e = ContextException.of(LABEL)
.addContext("K1", "V1")
.setContext("K1", "V2");
@@ -70,7 +70,7 @@ public class ContextExceptionTest {
}
@Test
- public void multiple_context_values() throws Exception {
+ public void multiple_context_values() {
ContextException e = ContextException.of(LABEL)
.addContext("K1", "V1")
.addContext("K1", "V2");
@@ -78,7 +78,7 @@ public class ContextExceptionTest {
}
@Test
- public void merge_ContextException() throws Exception {
+ public void merge_ContextException() {
ContextException cause = ContextException.of("cause").addContext("K1", "V1");
ContextException e = ContextException.of(cause)
.addContext("K1", "V11")
@@ -89,7 +89,7 @@ public class ContextExceptionTest {
}
@Test
- public void merge_ContextException_with_new_message() throws Exception {
+ public void merge_ContextException_with_new_message() {
ContextException cause = ContextException.of("cause").addContext("K1", "V1");
ContextException e = ContextException.of(LABEL, cause).addContext("K2", "V2");
assertThat(e.getContext("K1")).containsOnly("V1");
diff --git a/sonar-core/src/test/java/org/sonar/core/util/HttpsTrustTest.java b/sonar-core/src/test/java/org/sonar/core/util/HttpsTrustTest.java
index d8b1021dbb8..7f2809dd10b 100644
--- a/sonar-core/src/test/java/org/sonar/core/util/HttpsTrustTest.java
+++ b/sonar-core/src/test/java/org/sonar/core/util/HttpsTrustTest.java
@@ -72,7 +72,7 @@ public class HttpsTrustTest {
}
@Test
- public void testAlwaysTrustManager() throws Exception {
+ public void testAlwaysTrustManager() {
HttpsTrust.AlwaysTrustManager manager = new HttpsTrust.AlwaysTrustManager();
assertThat(manager.getAcceptedIssuers()).isEmpty();
// does nothing
diff --git a/sonar-core/src/test/java/org/sonar/core/util/MacAddressProviderTest.java b/sonar-core/src/test/java/org/sonar/core/util/MacAddressProviderTest.java
index 0824488d1d1..e92bc22aa42 100644
--- a/sonar-core/src/test/java/org/sonar/core/util/MacAddressProviderTest.java
+++ b/sonar-core/src/test/java/org/sonar/core/util/MacAddressProviderTest.java
@@ -26,7 +26,7 @@ import static org.assertj.core.api.Assertions.assertThat;
public class MacAddressProviderTest {
@Test
- public void getSecureMungedAddress() throws Exception {
+ public void getSecureMungedAddress() {
byte[] address = MacAddressProvider.getSecureMungedAddress();
assertThat(address).isNotEmpty();
assertThat(address).hasSize(6);
diff --git a/sonar-core/src/test/java/org/sonar/core/util/ProgressLoggerTest.java b/sonar-core/src/test/java/org/sonar/core/util/ProgressLoggerTest.java
index 4e358d962d9..8b67d094115 100644
--- a/sonar-core/src/test/java/org/sonar/core/util/ProgressLoggerTest.java
+++ b/sonar-core/src/test/java/org/sonar/core/util/ProgressLoggerTest.java
@@ -36,7 +36,7 @@ public class ProgressLoggerTest {
public LogTester logTester = new LogTester();
@Test(timeout = 5_000L)
- public void log_at_fixed_intervals() throws Exception {
+ public void log_at_fixed_intervals() {
AtomicLong counter = new AtomicLong(42L);
ProgressLogger progress = new ProgressLogger("ProgressLoggerTest", counter, Loggers.get(getClass()));
progress.setPeriodMs(1L);
diff --git a/sonar-core/src/test/java/org/sonar/core/util/ProtobufJsonFormatTest.java b/sonar-core/src/test/java/org/sonar/core/util/ProtobufJsonFormatTest.java
index 55f6e585b8f..0b0b7e80cd5 100644
--- a/sonar-core/src/test/java/org/sonar/core/util/ProtobufJsonFormatTest.java
+++ b/sonar-core/src/test/java/org/sonar/core/util/ProtobufJsonFormatTest.java
@@ -211,7 +211,7 @@ public class ProtobufJsonFormatTest {
}
@Test
- public void constructor_is_private() throws Exception {
+ public void constructor_is_private() {
assertThat(TestUtils.hasOnlyPrivateConstructors(ProtobufJsonFormat.class)).isTrue();
}
}
diff --git a/sonar-core/src/test/java/org/sonar/core/util/UuidFactoryFastTest.java b/sonar-core/src/test/java/org/sonar/core/util/UuidFactoryFastTest.java
index 49ee0d07c0e..12f796a2d74 100644
--- a/sonar-core/src/test/java/org/sonar/core/util/UuidFactoryFastTest.java
+++ b/sonar-core/src/test/java/org/sonar/core/util/UuidFactoryFastTest.java
@@ -34,7 +34,7 @@ public class UuidFactoryFastTest {
}
@Test
- public void test_format_of_uuid() throws Exception {
+ public void test_format_of_uuid() {
String uuid = underTest.create();
assertThat(uuid.length()).isGreaterThan(10).isLessThan(40);
diff --git a/sonar-core/src/test/java/org/sonar/core/util/UuidFactoryImplTest.java b/sonar-core/src/test/java/org/sonar/core/util/UuidFactoryImplTest.java
index fb3ef42658a..cd6ae3b8bfa 100644
--- a/sonar-core/src/test/java/org/sonar/core/util/UuidFactoryImplTest.java
+++ b/sonar-core/src/test/java/org/sonar/core/util/UuidFactoryImplTest.java
@@ -35,7 +35,7 @@ public class UuidFactoryImplTest {
}
@Test
- public void test_format_of_uuid() throws Exception {
+ public void test_format_of_uuid() {
String uuid = underTest.create();
assertThat(uuid.length()).isGreaterThan(10).isLessThan(40);
diff --git a/sonar-core/src/test/java/org/sonar/core/util/logs/DefaultProfilerTest.java b/sonar-core/src/test/java/org/sonar/core/util/logs/DefaultProfilerTest.java
index 79ccc84f851..1d176f3d8e6 100644
--- a/sonar-core/src/test/java/org/sonar/core/util/logs/DefaultProfilerTest.java
+++ b/sonar-core/src/test/java/org/sonar/core/util/logs/DefaultProfilerTest.java
@@ -50,7 +50,7 @@ public class DefaultProfilerTest {
}
@Test
- public void test_levels() throws Exception {
+ public void test_levels() {
// info by default
assertThat(underTest.isDebugEnabled()).isFalse();
assertThat(underTest.isTraceEnabled()).isFalse();