Skip to content

Commit a99ca17

Browse files
committed
Set up Spotbugs, squash warnings
1 parent 78bb4b1 commit a99ca17

9 files changed

+42
-13
lines changed

pom.xml

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@
5959
<maven-clean-plugin.version>3.3.2</maven-clean-plugin.version>
6060
<spotless.version>2.43.0</spotless.version>
6161
<google-java-format.version>1.22.0</google-java-format.version>
62+
<spotbugs-maven-plugin.version>4.8.5.0</spotbugs-maven-plugin.version>
63+
<spotbugs.version>4.8.5</spotbugs.version>
6264
<buildnumber.plugin.version>3.2.0</buildnumber.plugin.version>
6365
<asciidoctor.maven.plugin.version>3.0.0</asciidoctor.maven.plugin.version>
6466
<asciidoctorj.version>2.5.13</asciidoctorj.version>
@@ -164,6 +166,12 @@
164166
<scope>test</scope>
165167
</dependency>
166168

169+
<dependency>
170+
<groupId>com.github.spotbugs</groupId>
171+
<artifactId>spotbugs-annotations</artifactId>
172+
<version>${spotbugs.version}</version>
173+
<scope>provided</scope>
174+
</dependency>
167175

168176
</dependencies>
169177

@@ -391,6 +399,26 @@
391399
</configuration>
392400
</plugin>
393401

402+
<plugin>
403+
<groupId>com.github.spotbugs</groupId>
404+
<artifactId>spotbugs-maven-plugin</artifactId>
405+
<version>${spotbugs-maven-plugin.version}</version>
406+
<dependencies>
407+
<dependency>
408+
<groupId>com.github.spotbugs</groupId>
409+
<artifactId>spotbugs</artifactId>
410+
<version>${spotbugs.version}</version>
411+
</dependency>
412+
</dependencies>
413+
<executions>
414+
<execution>
415+
<goals>
416+
<goal>check</goal>
417+
</goals>
418+
</execution>
419+
</executions>
420+
</plugin>
421+
394422
</plugins>
395423

396424
</build>
@@ -407,7 +435,6 @@
407435
</properties>
408436
</profile>
409437

410-
411438
<profile>
412439
<id>jvm-test-arguments-java-21-and-more</id>
413440
<activation>

src/main/java/com/rabbitmq/model/ByteCapacity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public long toBytes() {
108108
public static ByteCapacity from(String value) {
109109
Matcher matcher = PATTERN.matcher(value);
110110
if (matcher.matches()) {
111-
long size = Long.valueOf(matcher.group(GROUP_SIZE));
111+
long size = Long.parseLong(matcher.group(GROUP_SIZE));
112112
String unit = matcher.group(GROUP_UNIT);
113113
ByteCapacity result;
114114
if (unit == null) {

src/main/java/com/rabbitmq/model/amqp/AmqpConnection.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
import org.slf4j.Logger;
4545
import org.slf4j.LoggerFactory;
4646

47-
class AmqpConnection extends ResourceBase implements Connection {
47+
final class AmqpConnection extends ResourceBase implements Connection {
4848

4949
private static final Predicate<Throwable> RECOVERY_PREDICATE =
5050
t -> {

src/main/java/com/rabbitmq/model/amqp/AmqpConsumer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
import org.slf4j.Logger;
4545
import org.slf4j.LoggerFactory;
4646

47-
class AmqpConsumer extends ResourceBase implements Consumer {
47+
final class AmqpConsumer extends ResourceBase implements Consumer {
4848

4949
private static final AtomicLong ID_SEQUENCE = new AtomicLong(0);
5050

src/main/java/com/rabbitmq/model/amqp/AmqpEnvironmentBuilder.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import com.rabbitmq.model.EnvironmentBuilder;
2323
import com.rabbitmq.model.metrics.MetricsCollector;
2424
import com.rabbitmq.model.metrics.NoOpMetricsCollector;
25+
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
2526
import java.util.concurrent.ExecutorService;
2627

2728
public class AmqpEnvironmentBuilder implements EnvironmentBuilder {
@@ -43,6 +44,7 @@ public AmqpEnvironmentBuilder metricsCollector(MetricsCollector metricsCollector
4344
return this;
4445
}
4546

47+
@SuppressFBWarnings("EI_EXPOSE_REP")
4648
public EnvironmentConnectionSettings connectionSettings() {
4749
return this.connectionSettings;
4850
}

src/main/java/com/rabbitmq/model/amqp/AmqpExchangeSpecification.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,13 @@
2525

2626
class AmqpExchangeSpecification implements Management.ExchangeSpecification {
2727

28+
private static final boolean DURABLE = true;
29+
private static final boolean INTERNAL = false;
30+
2831
private final AmqpManagement management;
2932

3033
private String name;
3134
private String type = Management.ExchangeType.DIRECT.name().toLowerCase(Locale.ENGLISH);
32-
private final boolean durable = true;
33-
private final boolean internal = false;
3435
private boolean autoDelete = false;
3536
private final Map<String, Object> arguments = new LinkedHashMap<>();
3637

@@ -77,9 +78,9 @@ public void declare() {
7778
// TODO check name is specified (server-named entities not allowed)
7879
Map<String, Object> body = new LinkedHashMap<>();
7980
body.put("type", this.type);
80-
body.put("durable", this.durable);
81+
body.put("durable", DURABLE);
8182
body.put("auto_delete", this.autoDelete);
82-
body.put("internal", this.internal);
83+
body.put("internal", INTERNAL);
8384
body.put("arguments", this.arguments);
8485
this.management.declareExchange(this.name, body);
8586
this.management.recovery().exchangeDeclared(this);

src/main/java/com/rabbitmq/model/amqp/AmqpPublisher.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
import org.slf4j.Logger;
3232
import org.slf4j.LoggerFactory;
3333

34-
class AmqpPublisher extends ResourceBase implements Publisher {
34+
final class AmqpPublisher extends ResourceBase implements Publisher {
3535

3636
private static final AtomicLong ID_SEQUENCE = new AtomicLong(0);
3737

src/main/java/com/rabbitmq/model/amqp/AmqpQueueSpecification.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
class AmqpQueueSpecification implements Management.QueueSpecification {
3333

3434
private static final Logger LOGGER = LoggerFactory.getLogger(AmqpQueueSpecification.class);
35-
3635
private static final Duration TEN_YEARS = Duration.ofDays(365 * 10);
36+
private static final boolean DURABLE = true;
3737

3838
private final AmqpManagement management;
3939

@@ -44,7 +44,6 @@ class AmqpQueueSpecification implements Management.QueueSpecification {
4444
// the user until the fix arrives)
4545
private boolean shortcutArguments = false;
4646
private String name;
47-
private final boolean durable = true;
4847
private boolean exclusive = false;
4948
private boolean autoDelete = false;
5049
private final Map<String, Object> arguments = new LinkedHashMap<>();
@@ -189,7 +188,7 @@ public Management.QueueInfo declare() {
189188
// TODO check name is specified (server-named entities not allowed)
190189
// generate a random name if name not specified
191190
Map<String, Object> body = new LinkedHashMap<>();
192-
body.put("durable", this.durable);
191+
body.put("durable", DURABLE);
193192
body.put("exclusive", this.exclusive);
194193
body.put("auto_delete", this.autoDelete);
195194
body.put("arguments", this.arguments);

src/main/java/com/rabbitmq/model/amqp/RecordingTopologyListener.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
import org.slf4j.Logger;
2929
import org.slf4j.LoggerFactory;
3030

31-
class RecordingTopologyListener implements TopologyListener, AutoCloseable {
31+
final class RecordingTopologyListener implements TopologyListener, AutoCloseable {
3232

3333
private static final Duration TIMEOUT = Duration.ofSeconds(60);
3434

0 commit comments

Comments
 (0)