Skip to content

Commit

Permalink
Update SpotBugs
Browse files Browse the repository at this point in the history
  • Loading branch information
blacelle committed Dec 4, 2023
1 parent 4f540a2 commit a31709f
Show file tree
Hide file tree
Showing 15 changed files with 42 additions and 13 deletions.
8 changes: 8 additions & 0 deletions code-providers/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@
<version>1.3.0</version>
</dependency>

<dependency>
<!-- https://stackoverflow.com/questions/1829904/is-there-a-way-to-ignore-a-single-findbugs-warning -->
<groupId>com.google.code.findbugs</groupId>
<artifactId>annotations</artifactId>
<version>3.0.1u2</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>io.github.solven-eu.cleanthat</groupId>
<artifactId>test-helpers</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@

import com.google.common.jimfs.Jimfs;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import eu.solven.cleanthat.code_provider.CleanthatPathHelpers;
import eu.solven.cleanthat.codeprovider.CodeProviderHelpers;
import eu.solven.cleanthat.codeprovider.DummyCodeProviderFile;
Expand All @@ -58,6 +59,8 @@ public class FileSystemCodeProvider implements ICodeProviderWriter {
final Path root;
final Charset charset;

@SuppressFBWarnings(value = "CT_CONSTRUCTOR_THROW",
justification = "We need to derive this class in FileSystemGitCodeProvider")
public FileSystemCodeProvider(Path root, Charset charset) {
this.fs = root.getFileSystem();
this.root = root.normalize();
Expand Down Expand Up @@ -131,7 +134,7 @@ public String toString() {
return root.toAbsolutePath().toString();
}

protected Path resolvePath(Path inMemoryPath) {
private Path resolvePath(Path inMemoryPath) {
return CleanthatPathHelpers.resolveChild(root, inMemoryPath);
}

Expand Down Expand Up @@ -171,7 +174,7 @@ public Optional<String> loadContentForPath(Path path) throws IOException {
return safeReadString(pathForRootFS);
}

protected Optional<String> safeReadString(Path pathForRootFS) throws IOException {
private Optional<String> safeReadString(Path pathForRootFS) throws IOException {
if (Files.exists(pathForRootFS)) {
String asString;
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* @author Benoit Lacelle
*
*/
public class DummyCodeProviderFile implements ICodeProviderFile {
public final class DummyCodeProviderFile implements ICodeProviderFile {
private final Path path;
private final Object raw;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*
*/
// https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#webhook-payload-example-32
public class GitRepoBranchSha1 {
public final class GitRepoBranchSha1 {
final String repoName;
final String ref;
final String sha;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* @author Benoit Lacelle
*
*/
public class GitWebhookRelevancyResult implements IExternalWebhookRelevancyResult {
public final class GitWebhookRelevancyResult implements IExternalWebhookRelevancyResult {
final boolean rrOpen;
final boolean pushRef;
final Optional<GitRepoBranchSha1> optRef;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* @param <R>
* @param <E>
*/
public class ResultOrError<R, E> {
public final class ResultOrError<R, E> {
final Optional<R> optResult;
final Optional<E> optError;

Expand Down
9 changes: 9 additions & 0 deletions github/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,15 @@
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
</dependency>

<dependency>
<!-- https://stackoverflow.com/questions/1829904/is-there-a-way-to-ignore-a-single-findbugs-warning -->
<groupId>com.google.code.findbugs</groupId>
<artifactId>annotations</artifactId>
<version>3.0.1u2</version>
<scope>provided</scope>
</dependency>

<dependency>
<!-- Enables loading a PEM file -->
<groupId>org.bouncycastle</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import com.nimbusds.jose.crypto.impl.RSAKeyUtils;
import com.nimbusds.jose.jwk.RSAKey;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import eu.solven.cleanthat.code_provider.github.event.pojo.WebhookRelevancyResult;
import eu.solven.cleanthat.utils.ResultOrError;
import okhttp3.OkHttpClient;
Expand All @@ -53,6 +54,8 @@
* @author Benoit Lacelle
*
*/
// https://github.com/spotbugs/spotbugs/issues/2695
@SuppressFBWarnings("CT_CONSTRUCTOR_THROW")
public class GithubAppFactory implements IGithubAppFactory {
private static final int PUBLIC_CHARS_IN_TOKEN = 10;

Expand Down Expand Up @@ -108,7 +111,7 @@ private ImmutableMap<String, GHPermissionType> getRequestedPermissions() {
.build();
}

protected GitHub makeInstallationGithub(GitHub github, String appToken) throws IOException {
private GitHub makeInstallationGithub(GitHub github, String appToken) throws IOException {
GitHubConnector ghConnector = createGithubConnector();
return new GitHubBuilder().withEndpoint(github.getApiUrl())
.withAppInstallationToken(appToken)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
*/
// https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads
@SuppressWarnings("PMD.GodClass")
public class GithubWebhookHandler implements IGithubWebhookHandler {
public final class GithubWebhookHandler implements IGithubWebhookHandler {
private static final String EOL = "\r\n";

private static final Logger LOGGER = LoggerFactory.getLogger(GithubWebhookHandler.class);
Expand Down Expand Up @@ -100,7 +100,7 @@ public GHApp getGithubAsApp() {
* @return an {@link Optional} rejection reason
* @throws IOException
*/
protected Optional<String> checkMarketPlacePlan(GHAppInstallation appInstallation, GHRepository ghRepository)
private Optional<String> checkMarketPlacePlan(GHAppInstallation appInstallation, GHRepository ghRepository)
throws IOException {
// https://github.com/hub4j/github-api/issues/1613
GHMarketplaceAccount account = appInstallation.getMarketplaceAccount();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import com.google.common.base.Supplier;
import com.google.common.base.Suppliers;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import eu.solven.cleanthat.code_provider.CleanthatPathHelpers;
import eu.solven.cleanthat.code_provider.github.code_provider.AGithubCodeProvider;
import eu.solven.cleanthat.code_provider.github.code_provider.FileIsTooBigException;
Expand All @@ -56,6 +57,7 @@ public abstract class AGithubDiffCodeProvider extends AGithubCodeProvider implem

final Supplier<GHCompare> diffSupplier;

@SuppressFBWarnings(value = "CT_CONSTRUCTOR_THROW", justification = "Unclear FB case")
public AGithubDiffCodeProvider(Path repositoryRoot, String token, GHRepository baseRepository) {
super(repositoryRoot);
this.token = token;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
* @author Benoit Lacelle
*
*/
public class GithubFacade {
public final class GithubFacade {
private static final Logger LOGGER = LoggerFactory.getLogger(GithubFacade.class);

final GitHub github;
Expand Down
2 changes: 1 addition & 1 deletion parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
<!-- https://mvnrepository.com/artifact/com.diffplug.spotless/spotless-maven-plugin -->
<spotless.version>2.41.1</spotless.version>
<!-- https://mvnrepository.com/artifact/com.github.spotbugs/spotbugs-maven-plugin -->
<spotbugs.version>4.7.3.6</spotbugs.version>
<spotbugs.version>4.8.2.0</spotbugs.version>
<!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-pmd-plugin -->
<maven-pmd-plugin.version>3.21.2</maven-pmd-plugin.version>
<!-- https://mvnrepository.com/artifact/net.sourceforge.pmd/pmd -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ protected List<byte[]> initialValue() {
*/
protected Encoder<ILoggingEvent> encoder;

public void setEncoder(Encoder<ILoggingEvent> encoder) {
this.encoder = encoder;
}

@Override
protected void append(ILoggingEvent event) {
byte[] byteArray = this.encoder.encode(event);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
@Data
@Builder
@Jacksonized
public class SpotlessFormatterProperties {
public final class SpotlessFormatterProperties {
// If left to default, we will rely on the engine encoding
private String encoding;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
@Builder
@Jacksonized
// @JsonDeserialize(converter = SpotlessStepPropertiesSanitizer.class)
public class SpotlessStepProperties {
public final class SpotlessStepProperties {

// the step name/id
@lombok.NonNull
Expand Down

0 comments on commit a31709f

Please sign in to comment.