Skip to content

Commit 4b2daaf

Browse files
Update SpotBugs to 6.4.0 (#1336)
* Update SpotBugs to 6.4.0. * Fix SpotBugs issue relating to deprecated method `.ensureIndex` and replace with `createIndex` * Fix build.gradle issues * Remove deprecation suppressors as these are no longer required.
1 parent 6ce5944 commit 4b2daaf

File tree

6 files changed

+37
-30
lines changed

6 files changed

+37
-30
lines changed

service/build.gradle

Lines changed: 35 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ plugins {
33
id 'io.spring.dependency-management' version '1.1.7'
44
id 'java'
55
id "checkstyle"
6-
id "com.github.spotbugs" version "6.1.13"
6+
id "com.github.spotbugs" version "6.4.0"
77
id "io.freefair.lombok" version "8.14.2"
88
id 'jacoco'
99
id 'org.sonarqube' version '6.2.0.5505'
@@ -13,16 +13,27 @@ plugins {
1313
id 'com.arcmutate.github' version '2.2.3'
1414
}
1515

16+
spotbugs {
17+
toolVersion = '4.9.5'
18+
}
19+
1620
apply plugin: 'java'
1721
apply plugin: 'org.springframework.boot'
1822
apply plugin: 'checkstyle'
1923
apply plugin: "com.github.spotbugs"
2024
apply plugin: 'application'
2125

22-
mainClassName = ' uk.nhs.adaptors.gp2gp.Gp2gpApplication'
26+
application {
27+
mainClassName = 'uk.nhs.adaptors.gp2gp.Gp2gpApplication'
28+
}
2329

2430
group = 'uk.nhs.adaptors'
25-
sourceCompatibility = '21'
31+
32+
java {
33+
toolchain {
34+
languageVersion = JavaLanguageVersion.of(21)
35+
}
36+
}
2637

2738
checkstyle {
2839
toolVersion '10.18.2'
@@ -75,6 +86,8 @@ dependencies {
7586
testImplementation 'com.squareup.okhttp3:mockwebserver3:5.1.0'
7687
testImplementation 'com.adobe.testing:s3mock-testcontainers:4.7.0'
7788

89+
spotbugs 'com.github.spotbugs:spotbugs:4.9.5'
90+
spotbugs 'com.github.spotbugs:spotbugs-annotations:4.9.5'
7891

7992
pitest 'com.arcmutate:base:1.3.2'
8093
pitest 'com.arcmutate:pitest-git-plugin:2.1.0'
@@ -105,9 +118,10 @@ sourceSets {
105118
}
106119
}
107120

108-
task(interoperabilityTestingToolJsonToXml, dependsOn: 'classes', type: JavaExec) {
109-
mainClass.set('uk.nhs.adaptors.gp2gp.transformjsontoxmltool.TransformJsonToXml')
110-
classpath = sourceSets.main.runtimeClasspath
121+
tasks.register('interoperabilityTestingToolJsonToXml', JavaExec) {
122+
dependsOn 'classes'
123+
mainClass.set('uk.nhs.adaptors.gp2gp.transformjsontoxmltool.TransformJsonToXml')
124+
classpath = sourceSets.main.runtimeClasspath
111125
}
112126

113127
configurations {
@@ -117,21 +131,21 @@ configurations {
117131
integrationTestAnnotationProcessor.extendsFrom testAnnotationProcessor
118132
}
119133

120-
task integrationTest(type: Test) {
121-
useJUnitPlatform() {
122-
description = 'Runs integration tests.'
123-
group = 'verification'
134+
tasks.register('integrationTest', Test) {
135+
useJUnitPlatform() {
136+
description = 'Runs integration tests.'
137+
group = 'verification'
124138

125-
testClassesDirs = sourceSets.integrationTest.output.classesDirs
126-
classpath = sourceSets.integrationTest.runtimeClasspath
127-
shouldRunAfter test
128-
}
139+
testClassesDirs = sourceSets.integrationTest.output.classesDirs
140+
classpath = sourceSets.integrationTest.runtimeClasspath
141+
shouldRunAfter test
142+
}
129143
}
130144

131-
tasks.withType(Test) {
132-
testLogging {
133-
events "passed", "skipped", "failed"
134-
}
145+
tasks.withType(Test).configureEach {
146+
testLogging {
147+
events "passed", "skipped", "failed"
148+
}
135149
}
136150

137151
check.dependsOn integrationTest
@@ -141,13 +155,13 @@ spotbugsIntegrationTest.enabled = false
141155
spotbugsMain {
142156
reports {
143157
html {
144-
enabled = true
158+
enabled(true)
145159
}
146160
xml {
147-
enabled = true
161+
enabled(true)
148162
}
149-
excludeFilter.set(file("spotbugs/exclude.xml"))
150163
}
164+
excludeFilter.set(file("spotbugs/exclude.xml"))
151165
}
152166

153167
pitest {

service/src/main/java/uk/nhs/adaptors/gp2gp/common/configuration/CustomTrustStore.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ private X509TrustManager getDefaultTrustManager() {
5757
}
5858

5959
@SneakyThrows
60-
@SuppressFBWarnings("RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE")
6160
protected X509TrustManager getCustomDbTrustManager(S3Uri s3Uri, String trustStorePassword) {
6261
TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
6362
trustManagerFactory.init((KeyStore) null);

service/src/main/java/uk/nhs/adaptors/gp2gp/common/mongo/ttl/CosmosTtlCreator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public void create(Class<? extends TimeToLive> clazz) {
2525
String indexName = findTtlIndex().map(IndexInfo::getName).orElseThrow();
2626
getIndexOperations().dropIndex(indexName);
2727
}
28-
getIndexOperations().ensureIndex(new Index()
28+
getIndexOperations().createIndex(new Index()
2929
.expire(getDuration())
3030
.on(INDEX_FIELD_KEY, Sort.Direction.ASC)
3131
);

service/src/main/java/uk/nhs/adaptors/gp2gp/common/mongo/ttl/MongoTtlCreator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public void create(Class<? extends TimeToLive> clazz) {
2525
clazz.getSimpleName(), getDuration());
2626
getIndexOperations().dropIndex(TTL_INDEX_NAME);
2727
}
28-
getIndexOperations().ensureIndex(new Index()
28+
getIndexOperations().createIndex(new Index()
2929
.expire(getDuration())
3030
.named(TTL_INDEX_NAME)
3131
.on(FIELD_KEY, Sort.Direction.ASC)

service/src/main/java/uk/nhs/adaptors/gp2gp/ehr/mapper/EncounterMapper.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323

2424
import com.github.mustachejava.Mustache;
2525

26-
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
2726
import lombok.RequiredArgsConstructor;
2827
import lombok.SneakyThrows;
2928
import lombok.extern.slf4j.Slf4j;
@@ -171,8 +170,6 @@ private String buildOriginalText(Encounter encounter) {
171170
}
172171

173172
@SneakyThrows
174-
@SuppressFBWarnings(value = "RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE",
175-
justification = "https://github.com/spotbugs/spotbugs/issues/1338")
176173
private static Set<String> getEhrCompositionNameVocabularyCodes() {
177174
try (InputStream is = EncounterMapper.class.getClassLoader().getResourceAsStream("ehr_composition_name_vocabulary_codes.txt");
178175
BufferedReader reader = new BufferedReader(new InputStreamReader(is, UTF_8))) {

service/src/main/java/uk/nhs/adaptors/gp2gp/ehr/mapper/SupportedContentTypes.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import org.springframework.beans.factory.annotation.Autowired;
1313
import org.springframework.stereotype.Component;
1414

15-
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
1615
import lombok.AllArgsConstructor;
1716
import lombok.SneakyThrows;
1817

@@ -27,8 +26,6 @@ public boolean isContentTypeSupported(String attachmentContentType) {
2726
}
2827

2928
@SneakyThrows
30-
@SuppressFBWarnings(value = "RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE",
31-
justification = "https://github.com/spotbugs/spotbugs/issues/1338")
3229
private static Set<String> loadSupportedContentTypes() {
3330
try (InputStream is = SupportedContentTypes.class.getClassLoader().getResourceAsStream(SUPPORTED_CONTENT_TYPES_PATH);
3431
BufferedReader reader = new BufferedReader(new InputStreamReader(is, UTF_8))) {

0 commit comments

Comments
 (0)