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
Fix Sonar S1130 throws declarations should not be superfluous #1062
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice indeed, thank you! LGTM
I was trying to see if the number of code smells went down after this merge. But it seems not: https://sonarcloud.io/project/activity?id=biojava_biojava&graph=issues (I hope you can see this @jlerbsc ? let me know if not). Any ideas what's happening? Perhaps our sonar setup is not right somehow? |
Your link points on the master branch. Have you merged the PR? Envoyé depuis mon téléphone-------- Message original --------De : Jose Manuel Duarte ***@***.***>Date : ven. 2 juin 2023 à 20:11À : biojava/biojava ***@***.***>Cc : jean pierre Lerbscher ***@***.***>, Mention ***@***.***>Objet : Re: [biojava/biojava] Fix Sonar S1130 throws declarations should not be superfluous (PR #1062)
I was trying to see if the number of code smells went down after this merge. But it seems not: https://sonarcloud.io/project/activity?id=biojava_biojava&graph=issues (I hope you can see this @jlerbsc ? let me know if not). Any ideas what's happening? Perhaps our sonar setup is not right somehow?
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Sorry for the late reply but I am currently on vacation.
The type of issue not covered actually is "completely unnecessary because the declared exception type cannot actually be thrown". There may be cases that are not fully covered by our solution, I will look at this when I return from leave. Best wishes. |
I found that there are indeed 5 cases that were not covered when running our solution although they matched "a subclass of another listed exception" as they appeared in constructors while our solution only parsed method declarations. We have upgraded our solution to take constructor declarations into account. Would you like me to propose a new PR to complete the corrections on the sonar rule s1130 "throws declarations should not be superfluous"? Below is the summary of the execution Executed on 2023-06-20T10:38:37 on class org\biojava\nbio\ronn\ORonn.java with rule S1130 detected 2 defect(s) The corrections relate to the removal of the declaration of the exception NumberFormatException which is a RuntimeException as well as the removal of the declaration of FileNotFoundException when it is associated with IOException because FileNotFoundException is a subtype of IOException |
Thanks for explaining. Yes we'd be happy to review a new PR. |
Here is the corresponding PR #1065 |
This is a fix on #1061
The goal is to remove all unnecessary exception declarations or that overload the method declaration. All RuntimeExceptions are suppressed as they are automatically propagated by Java. When the method declaration contains a checked exception as well as a parent exception, only the parent exception is kept because the derived exception is also automatically picked up by the parent exception declaration.
Our automatic defect correction solution detected and corrected 72 violations of the Sonar S1130 rule '"throws" declarations should not be superfluous'. According to Sonar, it would have taken 6 hours to identify and correct these violations.
We hope that this PR suits you and allows you to improve the quality of your project.