From 67f97dc12da5f957a5f1eb93ff292a316e811ebb Mon Sep 17 00:00:00 2001 From: Marco Kaufmann <83189575+kaufco@users.noreply.github.com> Date: Wed, 19 Jun 2024 18:09:38 +0200 Subject: [PATCH] Enable S131, S1068, S1110, S1116, S1124, S1161, S1186 on Test code (#4820) --- .../autoscan/autoscan-diff-by-rules.json | 2 +- .../resources/autoscan/diffs/diff_S1161.json | 4 +- .../commons-beanutils/java-S1124.json | 6 + .../commons-beanutils/java-S1186.json | 64 +++++++++ .../java-S1068.json | 2 +- .../java-S1116.json | 10 ++ .../java-S1161.json | 2 +- .../java-S1186.json | 52 +++++++ .../resources/eclipse-jetty/java-S1068.json | 13 ++ .../resources/eclipse-jetty/java-S1110.json | 5 + .../resources/eclipse-jetty/java-S1116.json | 13 ++ .../resources/eclipse-jetty/java-S1161.json | 7 + .../resources/eclipse-jetty/java-S1186.json | 127 ++++++++++++++++++ .../resources/eclipse-jetty/java-S131.json | 3 + .../resources/sonar-server/java-S1068.json | 21 +++ .../resources/sonar-server/java-S1116.json | 20 +++ .../resources/sonar-server/java-S1124.json | 15 +++ .../resources/sonar-server/java-S1161.json | 6 + .../resources/sonar-server/java-S1186.json | 42 ++++++ .../org/sonar/plugins/java/CheckList.java | 19 ++- 20 files changed, 418 insertions(+), 15 deletions(-) create mode 100644 its/ruling/src/test/resources/eclipse-jetty/java-S1110.json create mode 100644 its/ruling/src/test/resources/sonar-server/java-S1068.json create mode 100644 its/ruling/src/test/resources/sonar-server/java-S1116.json create mode 100644 its/ruling/src/test/resources/sonar-server/java-S1124.json create mode 100644 its/ruling/src/test/resources/sonar-server/java-S1161.json create mode 100644 its/ruling/src/test/resources/sonar-server/java-S1186.json diff --git a/its/autoscan/src/test/resources/autoscan/autoscan-diff-by-rules.json b/its/autoscan/src/test/resources/autoscan/autoscan-diff-by-rules.json index e84b3b6dec5..00f2a657630 100644 --- a/its/autoscan/src/test/resources/autoscan/autoscan-diff-by-rules.json +++ b/its/autoscan/src/test/resources/autoscan/autoscan-diff-by-rules.json @@ -302,7 +302,7 @@ { "ruleKey": "S1161", "hasTruePositives": true, - "falseNegatives": 7, + "falseNegatives": 15, "falsePositives": 0 }, { diff --git a/its/autoscan/src/test/resources/autoscan/diffs/diff_S1161.json b/its/autoscan/src/test/resources/autoscan/diffs/diff_S1161.json index 7fd264caaa4..34ce3cc6089 100644 --- a/its/autoscan/src/test/resources/autoscan/diffs/diff_S1161.json +++ b/its/autoscan/src/test/resources/autoscan/diffs/diff_S1161.json @@ -1,6 +1,6 @@ { "ruleKey": "S1161", "hasTruePositives": true, - "falseNegatives": 7, + "falseNegatives": 15, "falsePositives": 0 -} +} \ No newline at end of file diff --git a/its/ruling/src/test/resources/commons-beanutils/java-S1124.json b/its/ruling/src/test/resources/commons-beanutils/java-S1124.json index c123aa44125..b8cc561d636 100644 --- a/its/ruling/src/test/resources/commons-beanutils/java-S1124.json +++ b/its/ruling/src/test/resources/commons-beanutils/java-S1124.json @@ -2,4 +2,10 @@ "commons-beanutils:commons-beanutils:src/main/java/org/apache/commons/beanutils2/locale/BaseLocaleConverter.java": [ 156 ], +"commons-beanutils:commons-beanutils:src/test/java/org/apache/commons/beanutils2/BasicDynaBeanTestCase.java": [ +60 +], +"commons-beanutils:commons-beanutils:src/test/java/org/apache/commons/beanutils2/PropertyUtilsTestCase.java": [ +160 +] } diff --git a/its/ruling/src/test/resources/commons-beanutils/java-S1186.json b/its/ruling/src/test/resources/commons-beanutils/java-S1186.json index e264c17e612..b965238791b 100644 --- a/its/ruling/src/test/resources/commons-beanutils/java-S1186.json +++ b/its/ruling/src/test/resources/commons-beanutils/java-S1186.json @@ -5,4 +5,68 @@ "commons-beanutils:commons-beanutils:src/main/java/org/apache/commons/beanutils2/expression/DefaultResolver.java": [ 67 ], +"commons-beanutils:commons-beanutils:src/test/java/org/apache/commons/beanutils2/AlphaBean.java": [ +44 +], +"commons-beanutils:commons-beanutils:src/test/java/org/apache/commons/beanutils2/BeanWithInnerBean.java": [ +29 +], +"commons-beanutils:commons-beanutils:src/test/java/org/apache/commons/beanutils2/ExtendMapBean.java": [ +32 +], +"commons-beanutils:commons-beanutils:src/test/java/org/apache/commons/beanutils2/IndexedTestBean.java": [ +39 +], +"commons-beanutils:commons-beanutils:src/test/java/org/apache/commons/beanutils2/LazyDynaListTestCase.java": [ +82, +89 +], +"commons-beanutils:commons-beanutils:src/test/java/org/apache/commons/beanutils2/MappedPropertyTestBean.java": [ +90 +], +"commons-beanutils:commons-beanutils:src/test/java/org/apache/commons/beanutils2/MappedPropertyTestCase.java": [ +53, +67 +], +"commons-beanutils:commons-beanutils:src/test/java/org/apache/commons/beanutils2/MethodUtilsTestCase.java": [ +56, +71 +], +"commons-beanutils:commons-beanutils:src/test/java/org/apache/commons/beanutils2/TestBean.java": [ +433 +], +"commons-beanutils:commons-beanutils:src/test/java/org/apache/commons/beanutils2/bugs/Jira359TestCase.java": [ +151 +], +"commons-beanutils:commons-beanutils:src/test/java/org/apache/commons/beanutils2/bugs/Jira381TestCase.java": [ +69, +75 +], +"commons-beanutils:commons-beanutils:src/test/java/org/apache/commons/beanutils2/converters/ArrayConverterTestCase.java": [ +52, +57 +], +"commons-beanutils:commons-beanutils:src/test/java/org/apache/commons/beanutils2/converters/CharacterConverterTestCase.java": [ +51, +56 +], +"commons-beanutils:commons-beanutils:src/test/java/org/apache/commons/beanutils2/converters/ClassConverterTestCase.java": [ +51, +56 +], +"commons-beanutils:commons-beanutils:src/test/java/org/apache/commons/beanutils2/converters/DateConverterTestCase.java": [ +50, +55 +], +"commons-beanutils:commons-beanutils:src/test/java/org/apache/commons/beanutils2/expression/DefaultResolverTestCase.java": [ +70, +77 +], +"commons-beanutils:commons-beanutils:src/test/java/org/apache/commons/beanutils2/locale/LocaleBeanUtilsTestCase.java": [ +52, +69 +], +"commons-beanutils:commons-beanutils:src/test/java/org/apache/commons/beanutils2/locale/converters/BaseLocaleConverterTestCase.java": [ +268 +] } diff --git a/its/ruling/src/test/resources/eclipse-jetty-similar-to-main/java-S1068.json b/its/ruling/src/test/resources/eclipse-jetty-similar-to-main/java-S1068.json index a3c5fe08b91..106292f537e 100644 --- a/its/ruling/src/test/resources/eclipse-jetty-similar-to-main/java-S1068.json +++ b/its/ruling/src/test/resources/eclipse-jetty-similar-to-main/java-S1068.json @@ -25,5 +25,5 @@ ], "org.eclipse.jetty:jetty-project:jetty-server/src/main/java/org/eclipse/jetty/server/session/JDBCSessionDataStore.java": [ 61 -], +] } diff --git a/its/ruling/src/test/resources/eclipse-jetty-similar-to-main/java-S1116.json b/its/ruling/src/test/resources/eclipse-jetty-similar-to-main/java-S1116.json index 4a7f2f6f355..810abb33e4e 100644 --- a/its/ruling/src/test/resources/eclipse-jetty-similar-to-main/java-S1116.json +++ b/its/ruling/src/test/resources/eclipse-jetty-similar-to-main/java-S1116.json @@ -1,5 +1,15 @@ { +"org.eclipse.jetty:jetty-project:jetty-http/src/test/java/org/eclipse/jetty/http/CookieCutterLenientTest.java": [ +204 +], +"org.eclipse.jetty:jetty-project:jetty-http/src/test/java/org/eclipse/jetty/http/HttpFieldsTest.java": [ +940, +1008 +], "org.eclipse.jetty:jetty-project:jetty-server/src/main/java/org/eclipse/jetty/server/handler/BufferedResponseHandler.java": [ 197 ], +"org.eclipse.jetty:jetty-project:jetty-server/src/test/java/org/eclipse/jetty/server/HttpServerTestBase.java": [ +1481 +] } diff --git a/its/ruling/src/test/resources/eclipse-jetty-similar-to-main/java-S1161.json b/its/ruling/src/test/resources/eclipse-jetty-similar-to-main/java-S1161.json index 4809028fbde..c9107b19618 100644 --- a/its/ruling/src/test/resources/eclipse-jetty-similar-to-main/java-S1161.json +++ b/its/ruling/src/test/resources/eclipse-jetty-similar-to-main/java-S1161.json @@ -10,5 +10,5 @@ ], "org.eclipse.jetty:jetty-project:jetty-server/src/main/java/org/eclipse/jetty/server/OptionalSslConnectionFactory.java": [ 64 -], +] } diff --git a/its/ruling/src/test/resources/eclipse-jetty-similar-to-main/java-S1186.json b/its/ruling/src/test/resources/eclipse-jetty-similar-to-main/java-S1186.json index d2e8aef2039..b708a7e8d51 100644 --- a/its/ruling/src/test/resources/eclipse-jetty-similar-to-main/java-S1186.json +++ b/its/ruling/src/test/resources/eclipse-jetty-similar-to-main/java-S1186.json @@ -2,6 +2,10 @@ "org.eclipse.jetty:jetty-project:jetty-http/src/main/java/org/eclipse/jetty/http/MimeTypes.java": [ 290 ], +"org.eclipse.jetty:jetty-project:jetty-http/src/test/java/org/eclipse/jetty/http/HttpGeneratorServerHTTPTest.java": [ +229, +253 +], "org.eclipse.jetty:jetty-project:jetty-io/src/main/java/org/eclipse/jetty/io/ByteBufferOutputStream.java": [ 40, 44 @@ -13,6 +17,13 @@ "org.eclipse.jetty:jetty-project:jetty-io/src/main/java/org/eclipse/jetty/io/ManagedSelector.java": [ 795 ], +"org.eclipse.jetty:jetty-project:jetty-io/src/test/java/org/eclipse/jetty/io/SelectorManagerTest.java": [ +105 +], +"org.eclipse.jetty:jetty-project:jetty-io/src/test/java/org/eclipse/jetty/io/WriteFlusherTest.java": [ +394, +430 +], "org.eclipse.jetty:jetty-project:jetty-server/src/main/java/org/eclipse/jetty/server/CachedContentFactory.java": [ 545 ], @@ -84,4 +95,45 @@ "org.eclipse.jetty:jetty-project:jetty-server/src/main/java/org/eclipse/jetty/server/session/NullSessionCache.java": [ 49 ], +"org.eclipse.jetty:jetty-project:jetty-server/src/test/java/org/eclipse/jetty/server/AsyncStressTest.java": [ +332, +344, +350 +], +"org.eclipse.jetty:jetty-project:jetty-server/src/test/java/org/eclipse/jetty/server/DetectorConnectionTest.java": [ +528, +589 +], +"org.eclipse.jetty:jetty-project:jetty-server/src/test/java/org/eclipse/jetty/server/HalfCloseTest.java": [ +147, +171 +], +"org.eclipse.jetty:jetty-project:jetty-server/src/test/java/org/eclipse/jetty/server/HttpChannelEventTest.java": [ +283 +], +"org.eclipse.jetty:jetty-project:jetty-server/src/test/java/org/eclipse/jetty/server/HttpOutputTest.java": [ +82, +785, +996 +], +"org.eclipse.jetty:jetty-project:jetty-server/src/test/java/org/eclipse/jetty/server/LocalAsyncContextTest.java": [ +69, +270, +476, +481 +], +"org.eclipse.jetty:jetty-project:jetty-server/src/test/java/org/eclipse/jetty/server/MultiPartCaptureTest.java": [ +347, +352, +357, +362, +367 +], +"org.eclipse.jetty:jetty-project:jetty-server/src/test/java/org/eclipse/jetty/server/MultiPartFormInputStreamTest.java": [ +246 +], +"org.eclipse.jetty:jetty-project:jetty-server/src/test/java/org/eclipse/jetty/server/NotAcceptingTest.java": [ +272, +427 +] } diff --git a/its/ruling/src/test/resources/eclipse-jetty/java-S1068.json b/its/ruling/src/test/resources/eclipse-jetty/java-S1068.json index 106292f537e..be69e12f628 100644 --- a/its/ruling/src/test/resources/eclipse-jetty/java-S1068.json +++ b/its/ruling/src/test/resources/eclipse-jetty/java-S1068.json @@ -1,4 +1,10 @@ { +"org.eclipse.jetty:jetty-project:jetty-jmx/src/test/java/com/acme/DerivedExtended.java": [ +28 +], +"org.eclipse.jetty:jetty-project:jetty-jmx/src/test/java/com/acme/jmx/DerivedMBean.java": [ +32 +], "org.eclipse.jetty:jetty-project:jetty-server/src/main/java/org/eclipse/jetty/server/HttpOutput.java": [ 1825 ], @@ -25,5 +31,12 @@ ], "org.eclipse.jetty:jetty-project:jetty-server/src/main/java/org/eclipse/jetty/server/session/JDBCSessionDataStore.java": [ 61 +], +"org.eclipse.jetty:jetty-project:jetty-util/src/test/java/org/eclipse/jetty/util/PathWatcherTest.java": [ +301 +], +"org.eclipse.jetty:jetty-project:jetty-util/src/test/java/org/eclipse/jetty/util/TestIntrospectionUtil.java": [ +55, +63 ] } diff --git a/its/ruling/src/test/resources/eclipse-jetty/java-S1110.json b/its/ruling/src/test/resources/eclipse-jetty/java-S1110.json new file mode 100644 index 00000000000..7fce79789d3 --- /dev/null +++ b/its/ruling/src/test/resources/eclipse-jetty/java-S1110.json @@ -0,0 +1,5 @@ +{ +"org.eclipse.jetty:jetty-project:jetty-slf4j-impl/src/test/java/org/eclipse/jetty/logging/Slf4jEffort.java": [ +72 +] +} diff --git a/its/ruling/src/test/resources/eclipse-jetty/java-S1116.json b/its/ruling/src/test/resources/eclipse-jetty/java-S1116.json index 9d979e7a2ba..6424303ae35 100644 --- a/its/ruling/src/test/resources/eclipse-jetty/java-S1116.json +++ b/its/ruling/src/test/resources/eclipse-jetty/java-S1116.json @@ -1,5 +1,18 @@ { +"org.eclipse.jetty:jetty-project:jetty-http/src/test/java/org/eclipse/jetty/http/CookieCutterLenientTest.java": [ +204 +], +"org.eclipse.jetty:jetty-project:jetty-http/src/test/java/org/eclipse/jetty/http/HttpFieldsTest.java": [ +940, +1008 +], "org.eclipse.jetty:jetty-project:jetty-server/src/main/java/org/eclipse/jetty/server/handler/BufferedResponseHandler.java": [ 197 +], +"org.eclipse.jetty:jetty-project:jetty-server/src/test/java/org/eclipse/jetty/server/HttpServerTestBase.java": [ +1481 +], +"org.eclipse.jetty:jetty-project:jetty-server/src/test/java/org/eclipse/jetty/server/handler/NcsaRequestLogTest.java": [ +867 ] } diff --git a/its/ruling/src/test/resources/eclipse-jetty/java-S1161.json b/its/ruling/src/test/resources/eclipse-jetty/java-S1161.json index d6c199a9549..d6a6290ea27 100644 --- a/its/ruling/src/test/resources/eclipse-jetty/java-S1161.json +++ b/its/ruling/src/test/resources/eclipse-jetty/java-S1161.json @@ -17,5 +17,12 @@ "org.eclipse.jetty:jetty-project:jetty-util/src/main/java/org/eclipse/jetty/util/Callback.java": [ 150, 169 +], +"org.eclipse.jetty:jetty-project:jetty-util/src/test/java/org/eclipse/jetty/util/component/LifeCycleListenerTest.java": [ +174, +185, +191, +208, +214 ] } diff --git a/its/ruling/src/test/resources/eclipse-jetty/java-S1186.json b/its/ruling/src/test/resources/eclipse-jetty/java-S1186.json index 53dc51b4f8f..f2ddd2f9dd5 100644 --- a/its/ruling/src/test/resources/eclipse-jetty/java-S1186.json +++ b/its/ruling/src/test/resources/eclipse-jetty/java-S1186.json @@ -2,6 +2,10 @@ "org.eclipse.jetty:jetty-project:jetty-http/src/main/java/org/eclipse/jetty/http/MimeTypes.java": [ 290 ], +"org.eclipse.jetty:jetty-project:jetty-http/src/test/java/org/eclipse/jetty/http/HttpGeneratorServerHTTPTest.java": [ +229, +253 +], "org.eclipse.jetty:jetty-project:jetty-io/src/main/java/org/eclipse/jetty/io/ByteBufferOutputStream.java": [ 40, 44 @@ -13,6 +17,13 @@ "org.eclipse.jetty:jetty-project:jetty-io/src/main/java/org/eclipse/jetty/io/ManagedSelector.java": [ 795 ], +"org.eclipse.jetty:jetty-project:jetty-io/src/test/java/org/eclipse/jetty/io/SelectorManagerTest.java": [ +105 +], +"org.eclipse.jetty:jetty-project:jetty-io/src/test/java/org/eclipse/jetty/io/WriteFlusherTest.java": [ +394, +430 +], "org.eclipse.jetty:jetty-project:jetty-server/src/main/java/org/eclipse/jetty/server/CachedContentFactory.java": [ 545 ], @@ -84,9 +95,94 @@ "org.eclipse.jetty:jetty-project:jetty-server/src/main/java/org/eclipse/jetty/server/session/NullSessionCache.java": [ 49 ], +"org.eclipse.jetty:jetty-project:jetty-server/src/test/java/org/eclipse/jetty/server/AsyncStressTest.java": [ +332, +344, +350 +], +"org.eclipse.jetty:jetty-project:jetty-server/src/test/java/org/eclipse/jetty/server/DetectorConnectionTest.java": [ +528, +589 +], +"org.eclipse.jetty:jetty-project:jetty-server/src/test/java/org/eclipse/jetty/server/HalfCloseTest.java": [ +147, +171 +], +"org.eclipse.jetty:jetty-project:jetty-server/src/test/java/org/eclipse/jetty/server/HttpChannelEventTest.java": [ +283 +], +"org.eclipse.jetty:jetty-project:jetty-server/src/test/java/org/eclipse/jetty/server/HttpOutputTest.java": [ +82, +785, +996 +], +"org.eclipse.jetty:jetty-project:jetty-server/src/test/java/org/eclipse/jetty/server/LocalAsyncContextTest.java": [ +69, +270, +476, +481 +], +"org.eclipse.jetty:jetty-project:jetty-server/src/test/java/org/eclipse/jetty/server/MockConnector.java": [ +31 +], +"org.eclipse.jetty:jetty-project:jetty-server/src/test/java/org/eclipse/jetty/server/MultiPartCaptureTest.java": [ +347, +352, +357, +362, +367 +], +"org.eclipse.jetty:jetty-project:jetty-server/src/test/java/org/eclipse/jetty/server/MultiPartFormInputStreamTest.java": [ +246 +], +"org.eclipse.jetty:jetty-project:jetty-server/src/test/java/org/eclipse/jetty/server/NotAcceptingTest.java": [ +272, +427 +], +"org.eclipse.jetty:jetty-project:jetty-server/src/test/java/org/eclipse/jetty/server/ResponseTest.java": [ +164, +169 +], +"org.eclipse.jetty:jetty-project:jetty-server/src/test/java/org/eclipse/jetty/server/SuspendHandler.java": [ +40, +178, +190, +195 +], +"org.eclipse.jetty:jetty-project:jetty-server/src/test/java/org/eclipse/jetty/server/handler/HandlerTest.java": [ +274 +], +"org.eclipse.jetty:jetty-project:jetty-server/src/test/java/org/eclipse/jetty/server/handler/NcsaRequestLogTest.java": [ +654 +], +"org.eclipse.jetty:jetty-project:jetty-server/src/test/java/org/eclipse/jetty/server/handler/StatisticsHandlerTest.java": [ +310, +315, +320, +605, +610, +720, +725, +730 +], +"org.eclipse.jetty:jetty-project:jetty-server/src/test/java/org/eclipse/jetty/server/session/SessionCookieTest.java": [ +48, +109 +], +"org.eclipse.jetty:jetty-project:jetty-server/src/test/java/org/eclipse/jetty/server/ssl/SelectChannelServerSslTest.java": [ +237, +243 +], "org.eclipse.jetty:jetty-project:jetty-util-ajax/src/main/java/org/eclipse/jetty/util/ajax/JSON.java": [ 305 ], +"org.eclipse.jetty:jetty-project:jetty-util-ajax/src/test/java/org/eclipse/jetty/util/ajax/AsyncJSONTest.java": [ +409, +423 +], +"org.eclipse.jetty:jetty-project:jetty-util-ajax/src/test/java/org/eclipse/jetty/util/ajax/JSONTest.java": [ +548 +], "org.eclipse.jetty:jetty-project:jetty-util/src/main/java/org/eclipse/jetty/util/ByteArrayISO8859Writer.java": [ 213, 223 @@ -138,7 +234,38 @@ "org.eclipse.jetty:jetty-project:jetty-util/src/main/java/org/eclipse/jetty/util/thread/ThreadPoolBudget.java": [ 75 ], +"org.eclipse.jetty:jetty-project:jetty-util/src/test/java/org/eclipse/jetty/util/TestIntrospectionUtil.java": [ +71, +75, +79, +83, +90, +94, +98, +102 +], +"org.eclipse.jetty:jetty-project:jetty-util/src/test/java/org/eclipse/jetty/util/component/ContainerLifeCycleTest.java": [ +504, +509 +], +"org.eclipse.jetty:jetty-project:jetty-util/src/test/java/org/eclipse/jetty/util/ssl/X509CertificateAdapter.java": [ +42, +47, +82, +87 +], +"org.eclipse.jetty:jetty-project:jetty-util/src/test/java/org/eclipse/jetty/util/thread/ReservedThreadExecutorTest.java": [ +46 +], "org.eclipse.jetty:jetty-project:jetty-xml/src/main/java/org/eclipse/jetty/xml/XmlConfiguration.java": [ 336 +], +"org.eclipse.jetty:jetty-project:jetty-xml/src/test/java/org/eclipse/jetty/xml/XmlConfigurationTest.java": [ +663, +667, +671, +675, +679, +683 ] } diff --git a/its/ruling/src/test/resources/eclipse-jetty/java-S131.json b/its/ruling/src/test/resources/eclipse-jetty/java-S131.json index 60b9e2d6f51..23ee94c86c3 100644 --- a/its/ruling/src/test/resources/eclipse-jetty/java-S131.json +++ b/its/ruling/src/test/resources/eclipse-jetty/java-S131.json @@ -1,4 +1,7 @@ { +"org.eclipse.jetty:jetty-project:jetty-server/src/test/java/org/eclipse/jetty/server/handler/NcsaRequestLogTest.java": [ +811 +], "org.eclipse.jetty:jetty-project:jetty-util/src/main/java/org/eclipse/jetty/util/UrlEncoded.java": [ 197 ] diff --git a/its/ruling/src/test/resources/sonar-server/java-S1068.json b/its/ruling/src/test/resources/sonar-server/java-S1068.json new file mode 100644 index 00000000000..1640a784d24 --- /dev/null +++ b/its/ruling/src/test/resources/sonar-server/java-S1068.json @@ -0,0 +1,21 @@ +{ +"org.sonarsource.sonarqube:sonar-server:src/test/java/org/sonar/server/computation/task/projectanalysis/measure/MapBasedRawMeasureRepositoryTest.java": [ +80 +], +"org.sonarsource.sonarqube:sonar-server:src/test/java/org/sonar/server/issue/IssueServiceMediumTest.java": [ +70 +], +"org.sonarsource.sonarqube:sonar-server:src/test/java/org/sonar/server/qualityprofile/QProfileExportersTest.java": [ +79 +], +"org.sonarsource.sonarqube:sonar-server:src/test/java/org/sonar/server/rule/RuleUpdaterTest.java": [ +85 +], +"org.sonarsource.sonarqube:sonar-server:src/test/java/org/sonar/server/rule/ws/UpdateActionTest.java": [ +101 +], +"org.sonarsource.sonarqube:sonar-server:src/test/java/org/sonar/server/user/index/UserIndexTest.java": [ +42, +43 +] +} diff --git a/its/ruling/src/test/resources/sonar-server/java-S1116.json b/its/ruling/src/test/resources/sonar-server/java-S1116.json new file mode 100644 index 00000000000..bb50debd69d --- /dev/null +++ b/its/ruling/src/test/resources/sonar-server/java-S1116.json @@ -0,0 +1,20 @@ +{ +"org.sonarsource.sonarqube:sonar-server:src/test/java/org/sonar/server/computation/task/projectanalysis/issue/IssueCounterTest.java": [ +142 +], +"org.sonarsource.sonarqube:sonar-server:src/test/java/org/sonar/server/issue/notification/DoNotFixNotificationDispatcherTest.java": [ +40 +], +"org.sonarsource.sonarqube:sonar-server:src/test/java/org/sonar/server/qualitygate/ws/QualityGatesWsTest.java": [ +212 +], +"org.sonarsource.sonarqube:sonar-server:src/test/java/org/sonar/server/rule/index/RuleIndexDefinitionTest.java": [ +38 +], +"org.sonarsource.sonarqube:sonar-server:src/test/java/org/sonar/server/rule/ws/SearchActionTest.java": [ +445 +], +"org.sonarsource.sonarqube:sonar-server:src/test/java/org/sonar/server/test/index/TestResultSetIteratorTest.java": [ +141 +] +} diff --git a/its/ruling/src/test/resources/sonar-server/java-S1124.json b/its/ruling/src/test/resources/sonar-server/java-S1124.json new file mode 100644 index 00000000000..1ae1904056f --- /dev/null +++ b/its/ruling/src/test/resources/sonar-server/java-S1124.json @@ -0,0 +1,15 @@ +{ +"org.sonarsource.sonarqube:sonar-server:src/test/java/org/sonar/server/batch/IssuesActionTest.java": [ +63 +], +"org.sonarsource.sonarqube:sonar-server:src/test/java/org/sonar/server/computation/task/projectanalysis/formula/counter/IntSumCounterTest.java": [ +35 +], +"org.sonarsource.sonarqube:sonar-server:src/test/java/org/sonar/server/language/ws/LanguageWsTest.java": [ +122 +], +"org.sonarsource.sonarqube:sonar-server:src/test/java/org/sonar/server/source/ws/HashActionTest.java": [ +43, +44 +] +} diff --git a/its/ruling/src/test/resources/sonar-server/java-S1161.json b/its/ruling/src/test/resources/sonar-server/java-S1161.json new file mode 100644 index 00000000000..f28107b20a8 --- /dev/null +++ b/its/ruling/src/test/resources/sonar-server/java-S1161.json @@ -0,0 +1,6 @@ +{ +"org.sonarsource.sonarqube:sonar-server:src/test/java/org/sonar/server/platform/web/WebPagesFilterTest.java": [ +170, +174 +] +} diff --git a/its/ruling/src/test/resources/sonar-server/java-S1186.json b/its/ruling/src/test/resources/sonar-server/java-S1186.json new file mode 100644 index 00000000000..631089b12c3 --- /dev/null +++ b/its/ruling/src/test/resources/sonar-server/java-S1186.json @@ -0,0 +1,42 @@ +{ +"org.sonarsource.sonarqube:sonar-server:src/test/java/org/sonar/server/authentication/OAuth2CallbackFilterTest.java": [ +209 +], +"org.sonarsource.sonarqube:sonar-server:src/test/java/org/sonar/server/component/ws/ComponentsWsTest.java": [ +37 +], +"org.sonarsource.sonarqube:sonar-server:src/test/java/org/sonar/server/computation/queue/ReportSubmitterTest.java": [ +132, +164 +], +"org.sonarsource.sonarqube:sonar-server:src/test/java/org/sonar/server/notification/NotificationChannelTest.java": [ +39 +], +"org.sonarsource.sonarqube:sonar-server:src/test/java/org/sonar/server/platform/web/MasterServletFilterTest.java": [ +153, +164 +], +"org.sonarsource.sonarqube:sonar-server:src/test/java/org/sonar/server/platform/web/WebPagesFilterTest.java": [ +166 +], +"org.sonarsource.sonarqube:sonar-server:src/test/java/org/sonar/server/plugins/TestPluginA.java": [ +26 +], +"org.sonarsource.sonarqube:sonar-server:src/test/java/org/sonar/server/root/ws/RootsWsTest.java": [ +49 +], +"org.sonarsource.sonarqube:sonar-server:src/test/java/org/sonar/server/tester/AttributeHolderServletContextTest.java": [ +220, +230, +240, +277, +282, +287 +], +"org.sonarsource.sonarqube:sonar-server:src/test/java/org/sonar/server/user/SecurityRealmFactoryTest.java": [ +148 +], +"org.sonarsource.sonarqube:sonar-server:src/test/java/org/sonar/server/util/AbstractStoppableExecutorServiceTest.java": [ +46 +] +} diff --git a/sonar-java-plugin/src/main/java/org/sonar/plugins/java/CheckList.java b/sonar-java-plugin/src/main/java/org/sonar/plugins/java/CheckList.java index 0b08c589901..b7584e62057 100644 --- a/sonar-java-plugin/src/main/java/org/sonar/plugins/java/CheckList.java +++ b/sonar-java-plugin/src/main/java/org/sonar/plugins/java/CheckList.java @@ -822,9 +822,7 @@ public final class CheckList { EmptyClassCheck.class, EmptyDatabasePasswordCheck.class, EmptyLineRegexCheck.class, - EmptyMethodsCheck.class, EmptyRegexGroupCheck.class, - EmptyStatementUsageCheck.class, EmptyStringRepetitionCheck.class, EncryptionAlgorithmCheck.class, EnumEqualCheck.class, @@ -929,7 +927,6 @@ public final class CheckList { MissingDeprecatedCheck.class, MissingOverridesInRecordWithArrayComponentCheck.class, ModelAttributeNamingConventionForSpELCheck.class, - ModifiersOrderCheck.class, ModulusEqualityCheck.class, MultipleWhitespaceCheck.class, NPEThrowCheck.class, @@ -962,7 +959,6 @@ public final class CheckList { OptionalAsParameterCheck.class, OptionalRestParametersShouldBeObjectsCheck.class, OutputStreamOverrideWriteCheck.class, - OverrideAnnotationCheck.class, OverwrittenKeyCheck.class, PasswordEncoderCheck.class, MissingPathVariableAnnotationCheck.class, @@ -1090,7 +1086,6 @@ public final class CheckList { SwitchCaseTooBigCheck.class, SwitchDefaultLastCaseCheck.class, SwitchInsteadOfIfSequenceCheck.class, - SwitchLastCaseIsDefaultCheck.class, SwitchRedundantKeywordCheck.class, SwitchWithLabelsCheck.class, SwitchWithTooManyCasesCheck.class, @@ -1148,7 +1143,6 @@ public final class CheckList { UnusedGroupNamesCheck.class, UnusedLabelCheck.class, UnusedPrivateClassCheck.class, - UnusedPrivateFieldCheck.class, UnusedReturnedDataCheck.class, UnusedThrowableCheck.class, UnusedTypeParameterCheck.class, @@ -1157,7 +1151,6 @@ public final class CheckList { UseSwitchExpressionCheck.class, UselessExtendsCheck.class, UselessIncrementCheck.class, - UselessParenthesesCheck.class, UserEnumerationCheck.class, UtilityClassWithPublicConstructorCheck.class, ValueAnnotationShouldInjectPropertyOrSpELCheck.class, @@ -1247,8 +1240,7 @@ public final class CheckList { EnumMapCheck.class, LeftCurlyBraceStartLineCheck.class, DisallowedClassCheck.class, - ParameterReassignedToCheck.class - ); + ParameterReassignedToCheck.class); private static final List> JAVA_TEST_CHECKS = Arrays.asList( // Rule classes are listed alphabetically @@ -1313,6 +1305,8 @@ public final class CheckList { DeadStoreCheck.class, DefaultPackageCheck.class, EmptyBlockCheck.class, + EmptyMethodsCheck.class, + EmptyStatementUsageCheck.class, FixmeTagPresenceCheck.class, HiddenFieldCheck.class, ImmediatelyReturnedVariableCheck.class, @@ -1320,6 +1314,8 @@ public final class CheckList { MethodIdenticalImplementationsCheck.class, MethodNameSameAsClassCheck.class, MismatchPackageDirectoryCheck.class, + ModifiersOrderCheck.class, + OverrideAnnotationCheck.class, PrintfMisuseCheck.class, RedundantThrowsDeclarationCheck.class, ReplaceGuavaWithJavaCheck.class, @@ -1330,8 +1326,11 @@ public final class CheckList { TodoTagPresenceCheck.class, UnusedLocalVariableCheck.class, UnusedMethodParameterCheck.class, + UnusedPrivateFieldCheck.class, UnusedPrivateMethodCheck.class, - UselessImportCheck.class); + UselessParenthesesCheck.class, + UselessImportCheck.class, + SwitchLastCaseIsDefaultCheck.class); private static final List> ALL_CHECKS = Stream.of(JAVA_MAIN_CHECKS, JAVA_MAIN_AND_TEST_CHECKS, JAVA_TEST_CHECKS) .flatMap(List::stream)