diff --git a/code-providers/pom.xml b/code-providers/pom.xml index 96b760292..6a7f016ae 100644 --- a/code-providers/pom.xml +++ b/code-providers/pom.xml @@ -42,6 +42,14 @@ 1.3.0 + + + com.google.code.findbugs + annotations + 3.0.1u2 + provided + + io.github.solven-eu.cleanthat test-helpers diff --git a/code-providers/src/main/java/eu/solven/cleanthat/code_provider/inmemory/FileSystemCodeProvider.java b/code-providers/src/main/java/eu/solven/cleanthat/code_provider/inmemory/FileSystemCodeProvider.java index 643ec5f80..45c684145 100644 --- a/code-providers/src/main/java/eu/solven/cleanthat/code_provider/inmemory/FileSystemCodeProvider.java +++ b/code-providers/src/main/java/eu/solven/cleanthat/code_provider/inmemory/FileSystemCodeProvider.java @@ -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; @@ -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(); @@ -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); } @@ -171,7 +174,7 @@ public Optional loadContentForPath(Path path) throws IOException { return safeReadString(pathForRootFS); } - protected Optional safeReadString(Path pathForRootFS) throws IOException { + private Optional safeReadString(Path pathForRootFS) throws IOException { if (Files.exists(pathForRootFS)) { String asString; try { diff --git a/code-providers/src/main/java/eu/solven/cleanthat/codeprovider/DummyCodeProviderFile.java b/code-providers/src/main/java/eu/solven/cleanthat/codeprovider/DummyCodeProviderFile.java index db38195f6..e77960377 100644 --- a/code-providers/src/main/java/eu/solven/cleanthat/codeprovider/DummyCodeProviderFile.java +++ b/code-providers/src/main/java/eu/solven/cleanthat/codeprovider/DummyCodeProviderFile.java @@ -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; diff --git a/code-providers/src/main/java/eu/solven/cleanthat/codeprovider/git/GitRepoBranchSha1.java b/code-providers/src/main/java/eu/solven/cleanthat/codeprovider/git/GitRepoBranchSha1.java index 56d1c96c2..d86033dff 100644 --- a/code-providers/src/main/java/eu/solven/cleanthat/codeprovider/git/GitRepoBranchSha1.java +++ b/code-providers/src/main/java/eu/solven/cleanthat/codeprovider/git/GitRepoBranchSha1.java @@ -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; diff --git a/code-providers/src/main/java/eu/solven/cleanthat/codeprovider/git/GitWebhookRelevancyResult.java b/code-providers/src/main/java/eu/solven/cleanthat/codeprovider/git/GitWebhookRelevancyResult.java index bf7c71484..0fa819be6 100644 --- a/code-providers/src/main/java/eu/solven/cleanthat/codeprovider/git/GitWebhookRelevancyResult.java +++ b/code-providers/src/main/java/eu/solven/cleanthat/codeprovider/git/GitWebhookRelevancyResult.java @@ -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 optRef; diff --git a/config/src/main/java/eu/solven/cleanthat/utils/ResultOrError.java b/config/src/main/java/eu/solven/cleanthat/utils/ResultOrError.java index 6e7315a84..b0e4f4b7b 100644 --- a/config/src/main/java/eu/solven/cleanthat/utils/ResultOrError.java +++ b/config/src/main/java/eu/solven/cleanthat/utils/ResultOrError.java @@ -25,7 +25,7 @@ * @param * @param */ -public class ResultOrError { +public final class ResultOrError { final Optional optResult; final Optional optError; diff --git a/github/pom.xml b/github/pom.xml index 2f7424087..075f5ef5b 100644 --- a/github/pom.xml +++ b/github/pom.xml @@ -87,6 +87,15 @@ com.squareup.okhttp3 okhttp + + + + com.google.code.findbugs + annotations + 3.0.1u2 + provided + + org.bouncycastle diff --git a/github/src/main/java/eu/solven/cleanthat/code_provider/github/event/GithubAppFactory.java b/github/src/main/java/eu/solven/cleanthat/code_provider/github/event/GithubAppFactory.java index aba4831a0..68c47decd 100644 --- a/github/src/main/java/eu/solven/cleanthat/code_provider/github/event/GithubAppFactory.java +++ b/github/src/main/java/eu/solven/cleanthat/code_provider/github/event/GithubAppFactory.java @@ -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; @@ -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; @@ -108,7 +111,7 @@ private ImmutableMap 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) diff --git a/github/src/main/java/eu/solven/cleanthat/code_provider/github/event/GithubWebhookHandler.java b/github/src/main/java/eu/solven/cleanthat/code_provider/github/event/GithubWebhookHandler.java index bf0eacbe7..8b6f78934 100644 --- a/github/src/main/java/eu/solven/cleanthat/code_provider/github/event/GithubWebhookHandler.java +++ b/github/src/main/java/eu/solven/cleanthat/code_provider/github/event/GithubWebhookHandler.java @@ -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); @@ -100,7 +100,7 @@ public GHApp getGithubAsApp() { * @return an {@link Optional} rejection reason * @throws IOException */ - protected Optional checkMarketPlacePlan(GHAppInstallation appInstallation, GHRepository ghRepository) + private Optional checkMarketPlacePlan(GHAppInstallation appInstallation, GHRepository ghRepository) throws IOException { // https://github.com/hub4j/github-api/issues/1613 GHMarketplaceAccount account = appInstallation.getMarketplaceAccount(); diff --git a/github/src/main/java/eu/solven/cleanthat/code_provider/github/refs/AGithubDiffCodeProvider.java b/github/src/main/java/eu/solven/cleanthat/code_provider/github/refs/AGithubDiffCodeProvider.java index f462c8107..8e984649d 100644 --- a/github/src/main/java/eu/solven/cleanthat/code_provider/github/refs/AGithubDiffCodeProvider.java +++ b/github/src/main/java/eu/solven/cleanthat/code_provider/github/refs/AGithubDiffCodeProvider.java @@ -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; @@ -56,6 +57,7 @@ public abstract class AGithubDiffCodeProvider extends AGithubCodeProvider implem final Supplier diffSupplier; + @SuppressFBWarnings(value = "CT_CONSTRUCTOR_THROW", justification = "Unclear FB case") public AGithubDiffCodeProvider(Path repositoryRoot, String token, GHRepository baseRepository) { super(repositoryRoot); this.token = token; diff --git a/github/src/main/java/eu/solven/cleanthat/git_abstraction/GithubFacade.java b/github/src/main/java/eu/solven/cleanthat/git_abstraction/GithubFacade.java index 89d1314b8..1221d5eab 100644 --- a/github/src/main/java/eu/solven/cleanthat/git_abstraction/GithubFacade.java +++ b/github/src/main/java/eu/solven/cleanthat/git_abstraction/GithubFacade.java @@ -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; diff --git a/parent/pom.xml b/parent/pom.xml index 61ac96db0..4f347b4b4 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -55,7 +55,7 @@ 2.41.1 - 4.7.3.6 + 4.8.2.0 3.21.2 diff --git a/runnable/src/main/java/eu/solven/cleanthat/logback/LocalDumperAppender.java b/runnable/src/main/java/eu/solven/cleanthat/logback/LocalDumperAppender.java index 1ef8621a1..64ae362ad 100644 --- a/runnable/src/main/java/eu/solven/cleanthat/logback/LocalDumperAppender.java +++ b/runnable/src/main/java/eu/solven/cleanthat/logback/LocalDumperAppender.java @@ -51,6 +51,10 @@ protected List initialValue() { */ protected Encoder encoder; + public void setEncoder(Encoder encoder) { + this.encoder = encoder; + } + @Override protected void append(ILoggingEvent event) { byte[] byteArray = this.encoder.encode(event); diff --git a/spotless/src/main/java/eu/solven/cleanthat/spotless/pojo/SpotlessFormatterProperties.java b/spotless/src/main/java/eu/solven/cleanthat/spotless/pojo/SpotlessFormatterProperties.java index b0f682755..b3cec2cfb 100644 --- a/spotless/src/main/java/eu/solven/cleanthat/spotless/pojo/SpotlessFormatterProperties.java +++ b/spotless/src/main/java/eu/solven/cleanthat/spotless/pojo/SpotlessFormatterProperties.java @@ -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; diff --git a/spotless/src/main/java/eu/solven/cleanthat/spotless/pojo/SpotlessStepProperties.java b/spotless/src/main/java/eu/solven/cleanthat/spotless/pojo/SpotlessStepProperties.java index 2dfc401a5..79cf256c1 100644 --- a/spotless/src/main/java/eu/solven/cleanthat/spotless/pojo/SpotlessStepProperties.java +++ b/spotless/src/main/java/eu/solven/cleanthat/spotless/pojo/SpotlessStepProperties.java @@ -36,7 +36,7 @@ @Builder @Jacksonized // @JsonDeserialize(converter = SpotlessStepPropertiesSanitizer.class) -public class SpotlessStepProperties { +public final class SpotlessStepProperties { // the step name/id @lombok.NonNull