Skip to content

Commit

Permalink
Enforce SpotBugs
Browse files Browse the repository at this point in the history
Add a few missing SpotBugs annotations
Add serialVersionUID to LeastLoadBalancer$ExecutorChunkComparator since
it is Serializable.

Tested locally with:

  mvn clean -DskipTests verify
  • Loading branch information
Vlatombe authored and hashar committed Nov 19, 2024
1 parent c58d433 commit bd6d8b7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
5 changes: 5 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@
<tag>HEAD</tag>
</scm>

<properties>
<spotbugs.effort>Max</spotbugs.effort>
<spotbugs.threshold>Low</spotbugs.threshold>
</properties>

<repositories>
<repository>
<id>repo.jenkins-ci.org</id>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
package org.bstick12.jenkinsci.plugins.leastload;

import com.google.common.base.Preconditions;
import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.NonNull;
import hudson.init.Initializer;
import hudson.model.Computer;
import hudson.model.Executor;
Expand Down Expand Up @@ -58,7 +60,7 @@
*/
public class LeastLoadBalancer extends LoadBalancer {

private static final Logger LOGGER = Logger.getLogger(LeastLoadBalancer.class.getCanonicalName());
private static final Logger LOGGER = Logger.getLogger(LeastLoadBalancer.class.getName());

private static final Comparator<ExecutorChunk> EXECUTOR_CHUNK_COMPARATOR = Collections.reverseOrder(new ExecutorChunkComparator());

Expand All @@ -82,7 +84,8 @@ public static void register() {
}

@Override
public Mapping map(Task task, MappingWorksheet ws) {
@CheckForNull
public Mapping map(@NonNull Task task, MappingWorksheet ws) {

try {

Expand Down Expand Up @@ -180,6 +183,7 @@ public LoadBalancer getFallBackLoadBalancer() {
}

protected static class ExecutorChunkComparator implements Comparator<ExecutorChunk>, Serializable {
private static final long serialVersionUID = 1L;

public int compare(ExecutorChunk ec1, ExecutorChunk ec2) {

Expand Down Expand Up @@ -207,5 +211,4 @@ private boolean isIdle(Computer computer) {
}

}

}

0 comments on commit bd6d8b7

Please sign in to comment.