Skip to content

Commit 067a38c

Browse files
committed
Update to PMD 7.14 and remove unecessary suppressions
1 parent 69396b1 commit 067a38c

File tree

15 files changed

+14
-25
lines changed

15 files changed

+14
-25
lines changed

geowebcache/azureblob/src/test/java/org/geowebcache/azure/tests/online/TemporaryAzureFolder.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ protected void before() throws Throwable {
6060
}
6161

6262
@Override
63-
@SuppressWarnings("PMD.UseTryWithResources") // client is a field, not created here
6463
protected void after() {
6564
if (!isConfigured()) {
6665
return;

geowebcache/core/src/main/java/org/geowebcache/io/ByteArrayResource.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public long getSize() {
9090

9191
/** @see org.geowebcache.io.Resource#transferTo(java.nio.channels.WritableByteChannel) */
9292
@Override
93-
@SuppressWarnings({"PMD.UnusedLocalVariable", "PMD.EmptyControlStatement"})
93+
@SuppressWarnings("PMD.EmptyControlStatement")
9494
public long transferTo(WritableByteChannel channel) throws IOException {
9595
if (length > 0) {
9696
ByteBuffer buffer = ByteBuffer.wrap(data, offset, length);
@@ -103,7 +103,7 @@ public long transferTo(WritableByteChannel channel) throws IOException {
103103

104104
/** @see org.geowebcache.io.Resource#transferFrom(java.nio.channels.ReadableByteChannel) */
105105
@Override
106-
@SuppressWarnings({"PMD.UnusedLocalVariable", "PMD.EmptyControlStatement"})
106+
@SuppressWarnings("PMD.EmptyControlStatement")
107107
public long transferFrom(ReadableByteChannel channel) throws IOException {
108108
if (channel instanceof FileChannel) {
109109
FileChannel fc = (FileChannel) channel;

geowebcache/core/src/main/java/org/geowebcache/io/FileResource.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public long getSize() {
4848
}
4949

5050
@Override
51-
@SuppressWarnings({"PMD.UnusedLocalVariable", "PMD.EmptyControlStatement"})
51+
@SuppressWarnings("PMD.EmptyControlStatement")
5252
public long transferTo(WritableByteChannel target) throws IOException {
5353
// FileLock lock = in.lock();
5454

geowebcache/core/src/test/java/org/geowebcache/blobstore/file/FileBlobStoreComformanceTest.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ public void createTestUnit() throws Exception {
4949

5050
private void putLayerMetadataConcurrently(final int srcStoreKey, final FileBlobStore srcStore, int numberOfThreads)
5151
throws InterruptedException {
52-
@SuppressWarnings("PMD.CloseResource") // implements AutoCloseable in Java 21
5352
ExecutorService service = Executors.newFixedThreadPool(numberOfThreads);
5453
CountDownLatch latch = new CountDownLatch(numberOfThreads);
5554
for (int i = 0; i < numberOfThreads; i++) {
@@ -72,7 +71,6 @@ private void putLayerMetadataConcurrently(final int srcStoreKey, final FileBlobS
7271
}
7372

7473
private void executeStoresConcurrently(int numberOfStores, int numberOfThreads) throws InterruptedException {
75-
@SuppressWarnings("PMD.CloseResource") // implements AutoCloseable in Java 21
7674
ExecutorService service = Executors.newFixedThreadPool(numberOfStores);
7775
CountDownLatch latch = new CountDownLatch(numberOfStores);
7876
for (int i = 0; i < numberOfStores; i++) {
@@ -102,7 +100,6 @@ public void testMetadataWithPointInKey() throws Exception {
102100
public void testConcurrentMetadataWithPointInKey() throws InterruptedException {
103101
assertThat(store.getLayerMetadata("testLayer", "test.Key"), nullValue());
104102
int numberOfThreads = 2;
105-
@SuppressWarnings("PMD.CloseResource") // implements AutoCloseable in Java 21
106103
ExecutorService service = Executors.newFixedThreadPool(numberOfThreads);
107104
CountDownLatch latch = new CountDownLatch(numberOfThreads);
108105
for (int i = 0; i < numberOfThreads; i++) {

geowebcache/core/src/test/java/org/geowebcache/config/ConfigurationTest.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ public void testGetExisting() throws Exception {
217217
assertThat(retrieved, isPresent());
218218
}
219219

220-
@SuppressWarnings({"unchecked", "PMD.UnnecessaryCast"})
220+
@SuppressWarnings("unchecked")
221221
@Test
222222
public void testCantModifyReturnedCollection() throws Exception {
223223
I info = getGoodInfo("test", 1);
@@ -322,7 +322,6 @@ public void testConcurrentAdds() throws Exception {
322322
defaultCount + 10,
323323
getInfoNames(config).size());
324324
// get a thread pool
325-
@SuppressWarnings("PMD.CloseResource") // implements AutoCloseable in Java 21
326325
ExecutorService pool =
327326
Executors.newFixedThreadPool(16, (Runnable r) -> new Thread(r, "Info Concurrency Test for ADD"));
328327
// create a bunch of concurrent adds
@@ -364,7 +363,6 @@ public void testConcurrentDeletes() throws Exception {
364363
defaultCount + 100,
365364
getInfoNames(config).size());
366365
// get a thread pool
367-
@SuppressWarnings("PMD.CloseResource") // implements AutoCloseable in Java 21
368366
ExecutorService pool =
369367
Executors.newFixedThreadPool(16, (Runnable r) -> new Thread(r, "Info Concurrency Test for DELETE"));
370368
// create a bunch of concurrent deletes
@@ -404,7 +402,6 @@ public void testConcurrentModifies() throws Exception {
404402
defaultCount + 100,
405403
getInfoNames(config).size());
406404
// get a thread pool
407-
@SuppressWarnings("PMD.CloseResource") // implements AutoCloseable in Java 21
408405
ExecutorService pool =
409406
Executors.newFixedThreadPool(16, (Runnable r) -> new Thread(r, "Info Concurrency Test for MODIFY"));
410407
// create a bunch of concurrent modifies

geowebcache/core/src/test/java/org/geowebcache/layer/wms/WMSLayerTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,6 @@ private List<ConveyorTile> getTiles(StorageBroker storageBroker, TileRange tr, f
546546
long[] gridLoc = trIter.nextMetaGridLocation(new long[3]);
547547

548548
// six concurrent requests max
549-
@SuppressWarnings("PMD.CloseResource") // implements AutoCloseable in Java 21
550549
ExecutorService requests = Executors.newFixedThreadPool(6);
551550
ExecutorCompletionService<ConveyorTile> completer = new ExecutorCompletionService<>(requests);
552551

geowebcache/core/src/test/java/org/geowebcache/storage/TileRangeIteratorTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,6 @@ private long traverseTileRangeIter(
188188
final int[] metaTilingFactors)
189189
throws Exception {
190190

191-
@SuppressWarnings("PMD.CloseResource") // implements AutoCloseable in Java 21
192191
final ExecutorService executorService = Executors.newFixedThreadPool(nThreads);
193192

194193
final TileRange tileRange;

geowebcache/georss/src/main/java/org/geowebcache/georss/GeoRSSReaderFactory.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ public GeoRSSReader createReader(final URL url, final String username, final Str
5959
contentEncoding = "UTF-8";
6060
}
6161

62-
@SuppressWarnings("PMD.CloseResource") // The stream will be kept open to get new events
6362
Reader reader =
6463
new BufferedReader(new InputStreamReader(response.getEntity().getContent(), contentEncoding));
6564
if (log.isLoggable(Level.FINE)) {

geowebcache/pmd-ruleset.xml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,18 @@ under the License.
1919
-->
2020
<ruleset xmlns="http://pmd.sourceforge.net/ruleset/2.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="Default Maven PMD Plugin Ruleset" xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 http://pmd.sourceforge.net/ruleset_2_0_0.xsd">
2121
<description>
22-
GeoTools ruleset. See https://pmd.github.io/latest/pmd_userdocs_understanding_rulesets.html
22+
GeoWebCache ruleset. See https://pmd.github.io/pmd/pmd_userdocs_making_rulesets.html
2323
</description>
2424
<rule ref="category/java/bestpractices.xml/AvoidUsingHardCodedIP"/>
2525
<rule ref="category/java/bestpractices.xml/CheckResultSet"/>
2626
<!--rule ref="category/java/bestpractices.xml/UnusedFormalParameter" /-->
2727
<rule ref="category/java/bestpractices.xml/UnusedLocalVariable"/>
28-
<rule ref="category/java/bestpractices.xml/UnusedPrivateField"/>
28+
<rule ref="category/java/bestpractices.xml/UnusedPrivateField">
29+
<properties>
30+
<!-- The rule ignores fields that are annotated, but we want to check those annotated only with @SuppressWarnings -->
31+
<property name="reportForAnnotations" value="java.lang.SuppressWarnings" />
32+
</properties>
33+
</rule>
2934
<rule ref="category/java/bestpractices.xml/UnusedPrivateMethod"/>
3035
<rule ref="category/java/bestpractices.xml/SystemPrintln"/>
3136
<rule ref="category/java/bestpractices.xml/ForLoopCanBeForeach" />
@@ -45,6 +50,7 @@ GeoTools ruleset. See https://pmd.github.io/latest/pmd_userdocs_understanding_ru
4550
<rule ref="category/java/bestpractices.xml/UseStandardCharsets" />
4651
<rule ref="category/java/bestpractices.xml/PrimitiveWrapperInstantiation" />
4752
<rule ref="category/java/bestpractices.xml/UseCollectionIsEmpty" />
53+
<rule ref="category/java/bestpractices.xml/UnnecessaryWarningSuppression" />
4854

4955
<rule ref="category/java/codestyle.xml/EmptyControlStatement"/>
5056
<rule ref="category/java/codestyle.xml/UnnecessarySemicolon"/>

geowebcache/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
<errorProneFlags></errorProneFlags>
9090
<errorProne.version>2.31.0</errorProne.version>
9191
<javac.version>9+181-r4173-1</javac.version>
92-
<pmd.version>7.13.0</pmd.version>
92+
<pmd.version>7.14.0</pmd.version>
9393
<checkstyle.skip>false</checkstyle.skip>
9494
<qa>false</qa>
9595
<lint>deprecation,unchecked</lint>

0 commit comments

Comments
 (0)