Skip to content

Commit

Permalink
Address SpotBugs findings, fix insufficient Exception catch in versio…
Browse files Browse the repository at this point in the history
…n check
  • Loading branch information
tylercamp committed Jan 20, 2023
1 parent 5a859bc commit 157eeb8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
Expand Up @@ -299,7 +299,7 @@ public void perform(
try {
cdxVersion = repeatingClient.getCodeDxVersion();
buildOutput.println("Got Code Dx version: " + cdxVersion);
} catch (CodeDxClientException e) {
} catch (Exception e) {
e.printStackTrace(buildOutput);
if (handleCodeDxError(build, buildOutput, "An error occurred fetching the Code Dx version")) {
buildOutput.println("The Code Dx plugin cannot continue without verifying the Code Dx version, exiting");
Expand Down Expand Up @@ -411,7 +411,7 @@ public void perform(
}

analysisMonitor = effectiveGitConfig != null
? new GitJobAnalysisMonitor(project, response, buildOutput)
? new GitJobAnalysisMonitor(response, buildOutput)
: new DirectAnalysisMonitor(response, buildOutput);

} catch (CodeDxClientException e) {
Expand Down
Expand Up @@ -22,16 +22,13 @@
import java.util.List;

public class GitJobAnalysisMonitor implements AnalysisMonitor {
ProjectContext project;
StartAnalysisResponse originalAnalysisResponse, newAnalysisResponse;
PrintStream logger;

public GitJobAnalysisMonitor(
ProjectContext project,
StartAnalysisResponse originalAnalysisResponse,
PrintStream logger
) {
this.project = project;
this.originalAnalysisResponse = originalAnalysisResponse;
this.logger = logger;
}
Expand Down
7 changes: 7 additions & 0 deletions src/spotbugs/excludesFilter.xml
Expand Up @@ -11,6 +11,7 @@
<!-- Warnings regarding unwritten/unused fields - these are serialization classes -->
<Match>
<Class name="com.codedx.api.client.CodeDxClient$CodeDxVersionResponse" />
<Class name="com.codedx.api.client.GitConfigResponse" />
</Match>

<!-- Warnings about not overriding .Equals (these classes should be reference-compared, so default impl. should be ok) -->
Expand All @@ -33,6 +34,12 @@
<Bug pattern="SE_COMPARATOR_SHOULD_BE_SERIALIZABLE" />
</Match>

<!-- Warnings about try/catch exception mismatch, this class uses broad Exception catches intentionally to respect Error Handling option -->
<Match>
<Class name="org.jenkinsci.plugins.codedx.CodeDxPublisher" />
<Bug pattern="REC_CATCH_EXCEPTION" />
</Match>

<!-- <Match>-->
<!-- <Class name="com.foobar.ClassWithSomeBugsMatched" />-->
<!-- <Bug code="DE,UrF,SIC" />-->
Expand Down

0 comments on commit 157eeb8

Please sign in to comment.