You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Suggestion: Sonar S1130 "throws" declarations should not be superfluous #1061
After suggesting that you correct this type of defect automatically (#1051 ), we are offering another code smell correction.
In your project it seems that some methods throw runtime exceptions that it is not useful to declare because it inherits for example from the RuntimeException class.
If this is of interest to you we can push code changes to you in the form of a PR.
Below are examples of the changes made by our software to correct this rule.
org\biojava\nbio\aaproperties\xml\AminoAcidCompositionTable.java
@@ -133,5 +133,5 @@
* thrown if AminoAcidCompositionTable.computeMolecularWeight(ElementTable) is not called before this method
*/
- public double getMolecularWeight(Character aaSymbol) throws NullPointerException{
+ public double getMolecularWeight(Character aaSymbol) {
if(this.aaSymbol2MolecularWeight == null){
throw new NullPointerException("Please call AminoAcidCompositionTable.computeMolecularWeight(ElementTable) before this method");
org\biojava\nbio\alignment\io\StockholmFileParser.java
@@ -284,5 +284,5 @@
* if unexpected format is encountered
*/
- public StockholmStructure parse(String filename) throws IOException, ParserException {
+ public StockholmStructure parse(String filename) throws IOException {
InputStream inStream = new InputStreamProvider().getInputStream(filename);
StockholmStructure structure = parse(inStream);
That sounds reasonable to me: not declaring unchecked exceptions would follow the style that we try to have elsewhere in the biojava library.
As a note: there's a school of thought (see blogpost) that believes that checked exceptions are evil and that one should convert everything to unchecked and declare the unchecked exceptions in signatures for documentation purposes. In any case, I'm not saying we should do that with BioJava now, it would quite a disruptive change.
Do you agree that I submit a PR to you soon on this subject? For information, fixes will be made by our solution which automatically resolves defects in java applications.
Regarding the link you indicated, i consider that checked exceptions give meaning to methods. Of course, as in many areas, there are always supporters and detractors. It seems to me that the article bears witness to a very personal conviction and another person could perfectly well find contradictory scenarios. Personally, I'm very comfortable with checked exceptions and I don't find that managing these exceptions is so restrictive. Everyone sees noon at his door.
Activity
josemduarte commentedon May 17, 2023
That sounds reasonable to me: not declaring unchecked exceptions would follow the style that we try to have elsewhere in the biojava library.
As a note: there's a school of thought (see blogpost) that believes that checked exceptions are evil and that one should convert everything to unchecked and declare the unchecked exceptions in signatures for documentation purposes. In any case, I'm not saying we should do that with BioJava now, it would quite a disruptive change.
jlerbsc commentedon May 18, 2023
Do you agree that I submit a PR to you soon on this subject? For information, fixes will be made by our solution which automatically resolves defects in java applications.
josemduarte commentedon May 18, 2023
Yes, we'd be happy to review a PR.
jlerbsc commentedon May 21, 2023
Regarding the link you indicated, i consider that checked exceptions give meaning to methods. Of course, as in many areas, there are always supporters and detractors. It seems to me that the article bears witness to a very personal conviction and another person could perfectly well find contradictory scenarios. Personally, I'm very comfortable with checked exceptions and I don't find that managing these exceptions is so restrictive. Everyone sees noon at his door.