Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add try-catch to parse #125

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Add try-catch to parse

2f7d857
Select commit
Loading
Failed to load commit list.
Open

Add try-catch to parse #125

Add try-catch to parse
2f7d857
Select commit
Loading
Failed to load commit list.
ci.jenkins.io / SpotBugs failed Dec 14, 2023 in 0s

2 new issues

Total New Outstanding Fixed Trend
2 2 0 0 👎

Reference build: Plugins » accurev-plugin » master #118

Details

Severity distribution of new issues

Error Warning High Warning Normal Warning Low
0 0 1 1

Annotations

Check warning on line 313 in src/main/java/hudson/plugins/accurev/ParseChangeLog.java

See this annotation in the file changed.

@ci-jenkins-io ci-jenkins-io / SpotBugs

REC_CATCH_EXCEPTION

NORMAL:
Exception is caught when Exception is not thrown in hudson.plugins.accurev.ParseChangeLog.parseTransactions(XmlPullParser, File, ParseChangeLog$UpdateLog)
Raw output
<p> This method uses a try-catch block that catches Exception objects, but Exception is not thrown within the try block, and RuntimeException is not explicitly caught. It is a common bug pattern to say try { ... } catch (Exception e) { something } as a shorthand for catching a number of types of exception each of whose catch blocks is identical, but this construct also accidentally catches RuntimeException as well, masking potential bugs. </p> <p>A better approach is to either explicitly catch the specific exceptions that are thrown, or to explicitly catch RuntimeException exception, rethrow it, and then catch all non-Runtime Exceptions, as shown below:</p> <pre><code>try { ... } catch (RuntimeException e) { throw e; } catch (Exception e) { ... deal with all non-runtime exceptions ... } </code></pre>

Check warning on line 313 in src/main/java/hudson/plugins/accurev/ParseChangeLog.java

See this annotation in the file changed.

@ci-jenkins-io ci-jenkins-io / SpotBugs

REC_CATCH_EXCEPTION

LOW:
Exception is caught when Exception is not thrown in hudson.plugins.accurev.ParseChangeLog.parseTransactions(XmlPullParser, File, ParseChangeLog$UpdateLog)
Raw output
<p> This method uses a try-catch block that catches Exception objects, but Exception is not thrown within the try block, and RuntimeException is not explicitly caught. It is a common bug pattern to say try { ... } catch (Exception e) { something } as a shorthand for catching a number of types of exception each of whose catch blocks is identical, but this construct also accidentally catches RuntimeException as well, masking potential bugs. </p> <p>A better approach is to either explicitly catch the specific exceptions that are thrown, or to explicitly catch RuntimeException exception, rethrow it, and then catch all non-Runtime Exceptions, as shown below:</p> <pre><code>try { ... } catch (RuntimeException e) { throw e; } catch (Exception e) { ... deal with all non-runtime exceptions ... } </code></pre>