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

Fix Sonar S1130 throws declarations should not be superfluous #1062

Merged
merged 1 commit into from Jun 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -132,7 +132,7 @@ public void computeMolecularWeight(ElementTable eTable){
* @throws NullPointerException
* 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");
}
Expand Down
Expand Up @@ -283,7 +283,7 @@ public class StockholmFileParser {
* @throws ParserException
* 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);
inStream.close();
Expand All @@ -307,7 +307,7 @@ public StockholmStructure parse(String filename) throws IOException, ParserExcep
* @throws ParserException
* if unexpected format is encountered
*/
public List<StockholmStructure> parse(String filename, int max) throws IOException, ParserException {
public List<StockholmStructure> parse(String filename, int max) throws IOException {
InputStreamProvider isp = new InputStreamProvider();
InputStream inStream = isp.getInputStream(filename);
return parse(inStream, max);
Expand All @@ -325,7 +325,7 @@ public List<StockholmStructure> parse(String filename, int max) throws IOExcepti
* @throws IOException
* @throws ParserException
*/
public StockholmStructure parse(InputStream inStream) throws ParserException, IOException {
public StockholmStructure parse(InputStream inStream) throws IOException {
return parse(inStream, 1).get(0);
}

Expand Down Expand Up @@ -391,7 +391,7 @@ public List<StockholmStructure> parseNext(int max) throws IOException {
* @throws IOException
* @throws Exception
*/
StockholmStructure parse(Scanner scanner) throws ParserException, IOException {
StockholmStructure parse(Scanner scanner) throws IOException {
if (scanner == null) {
if (internalScanner != null) {
scanner = internalScanner;
Expand Down Expand Up @@ -528,7 +528,7 @@ StockholmStructure parse(Scanner scanner) throws ParserException, IOException {
* the line to be parsed
* @throws Exception
*/
private void handleSequenceLine(String line) throws ParserException {
private void handleSequenceLine(String line) {
String[] lineContent = line.split("\\s+");
if (lineContent.length != 2) {
throw new ParserException("Could not split sequence line into sequence name and sequence:\n" + line);
Expand Down
Expand Up @@ -165,7 +165,7 @@ private void reset() {
* {@inheritDoc}
* The last accession passed to this routine will always be the one used.
*/
public void setVersion(int version) throws ParserException {
public void setVersion(int version) {
if (this.versionSeen) throw new ParserException("Current BioEntry already has a version");
else {
try {
Expand All @@ -182,23 +182,23 @@ public void setVersion(int version) throws ParserException {
* {@inheritDoc}
* The last accession passed to this routine will always be the one used.
*/
public void setAccession(String accession) throws ParserException {
public void setAccession(String accession) {
if (accession==null) throw new ParserException("Accession cannot be null");
this.accession = accession;
}

/**
* {@inheritDoc}
*/
public void setDescription(String description) throws ParserException {
public void setDescription(String description) {
if (this.description!=null) throw new ParserException("Current BioEntry already has a description");
this.description = description;
}

/**
* {@inheritDoc}
*/
public void setIdentifier(String identifier) throws ParserException {
public void setIdentifier(String identifier) {
if (identifier==null) throw new ParserException("Identifier cannot be null");
if (this.identifier!=null) throw new ParserException("Current BioEntry already has a identifier");
this.identifier = identifier;
Expand All @@ -207,7 +207,7 @@ public void setIdentifier(String identifier) throws ParserException {
/**
* {@inheritDoc}
*/
public void setName(String name) throws ParserException {
public void setName(String name) {
if (name==null) throw new ParserException("Name cannot be null");
if (this.name!=null) throw new ParserException("Current BioEntry already has a name");
this.name = name;
Expand All @@ -216,7 +216,7 @@ public void setName(String name) throws ParserException {
/**
* {@inheritDoc}
*/
public void setComment(String comment) throws ParserException {
public void setComment(String comment) {
if (comment==null) throw new ParserException("Comment cannot be null");
this.comments.add(comment);
}
Expand Down
Expand Up @@ -242,7 +242,7 @@ public String getName() {
* {@link #getCodons(CompoundSet, CompoundSet)} was not called first.
*/
@Override
public boolean isStart(AminoAcidCompound compound) throws IllegalStateException {
public boolean isStart(AminoAcidCompound compound) {
if(this.codons.isEmpty()) {
throw new IllegalStateException("Codons are empty; please request getCodons() fist before asking this");
}
Expand Down
Expand Up @@ -87,7 +87,7 @@ public static void copy(InputStream input, OutputStream output)
* @param processor The processor to invoke on all lines
* @throws ParserException Can throw this if we cannot parse the given reader
*/
public static void processReader(BufferedReader br, ReaderProcessor processor) throws ParserException {
public static void processReader(BufferedReader br, ReaderProcessor processor) {
String line;
try {
while( (line = br.readLine()) != null ) {
Expand All @@ -109,7 +109,7 @@ public static void processReader(BufferedReader br, ReaderProcessor processor) t
* @return List of Strings
* @throws ParserException Can throw this if we cannot parse the given reader
*/
public static List<String> getList(BufferedReader br) throws ParserException {
public static List<String> getList(BufferedReader br) {
final List<String> list = new ArrayList<String>();
processReader(br, new ReaderProcessor() {
@Override
Expand All @@ -130,7 +130,7 @@ public void process(String line) {
* @throws ParserException Can throw this if the file is not a file or we
* cannot parse it
*/
public static List<String> getList(InputStream is) throws ParserException {
public static List<String> getList(InputStream is) {
return getList(new BufferedReader(new InputStreamReader(is)));
}

Expand Down
Expand Up @@ -638,7 +638,7 @@ private StringBuilder fetchUniprotXML(String uniprotURL)
* @throws IOException
*/
private StringBuilder fetchFromCache(String key)
throws FileNotFoundException, IOException {
throws IOException {
int index;
File f = new File(uniprotDirectoryCache + File.separatorChar + key + ".xml");
StringBuilder sb = new StringBuilder();
Expand Down
Expand Up @@ -131,7 +131,7 @@ public void setSequenceLength(long sequenceLength) {
* @return The parsed location
* @throws ParserException thrown in the event of any error during parsing
*/
public Location parse(String locationString) throws ParserException {
public Location parse(String locationString) {
featureGlobalStart = Integer.MAX_VALUE;
featureGlobalEnd = 1;

Expand All @@ -151,7 +151,7 @@ public Location parse(String locationString) throws ParserException {
return l;
}

private List<Location> parseLocationString(String string, int versus) throws ParserException {
private List<Location> parseLocationString(String string, int versus) {
Matcher m;
List<Location> boundedLocationsCollection = new ArrayList<Location>();

Expand Down
Expand Up @@ -368,7 +368,7 @@ public C getCompoundAt(int position) {
* @return Byte representation of the compound
* @throws IllegalStateException Done whenever this method is invoked
*/
protected byte processUnknownCompound(C compound, int position) throws IllegalStateException {
protected byte processUnknownCompound(C compound, int position) {
throw new IllegalStateException("Do not know how to translate the compound " + compound + " to a " + bitsPerCompound() + "bit representation");
}

Expand Down
Expand Up @@ -263,7 +263,7 @@ public C next() {


@Override
public void remove() throws UnsupportedOperationException {
public void remove() {
throw new UnsupportedOperationException("Cannot remove from this Sequence");
}
};
Expand All @@ -289,7 +289,7 @@ public int countCompounds(C... compounds) {


@Override
public AccessionID getAccession() throws UnsupportedOperationException {
public AccessionID getAccession() {
throw new UnsupportedOperationException();
}

Expand Down
Expand Up @@ -96,7 +96,7 @@ public void remove() {
}

@Override
public Term getTerm(String s) throws NoSuchElementException {
public Term getTerm(String s) {
int val = Integer.parseInt(s);
return resolveInt(val);
}
Expand All @@ -117,37 +117,37 @@ public Set getRemoteTerms() {
}

@Override
public Term createTerm(String name) throws AlreadyExistsException, IllegalArgumentException {
public Term createTerm(String name) throws AlreadyExistsException {
throw new IllegalArgumentException(getName() + " is immutable");
}

@Override
public Term createTerm(String name, String description)
throws
AlreadyExistsException,
AlreadyExistsException

IllegalArgumentException
{

{
throw new IllegalArgumentException(getName() + " is immutable");
}

@Override
public Term createTerm(String name, String description, Object[] synonyms)
throws
AlreadyExistsException,
AlreadyExistsException

IllegalArgumentException
{

{
throw new IllegalArgumentException(getName() + " is immutable");
}

@Override
public Variable createVariable(String name, String description)
throws
AlreadyExistsException,
AlreadyExistsException

IllegalArgumentException
{

{
throw new IllegalArgumentException(getName() + " is immutable");
}

Expand Down