Skip to content

Suggestion: Sonar S1130 "throws" declarations should not be superfluous #1061

Description

@jlerbsc

Hi,

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.

https://rules.sonarsource.com/java/RSPEC-1130

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);

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions