From e87c97d54a672c1b8a1a9a0a924c755de1c592c3 Mon Sep 17 00:00:00 2001 From: Judit Knoll Date: Tue, 3 Dec 2024 13:35:25 +0100 Subject: [PATCH] remove unnecessary throws declarations from methods --- .../de/tobject/findbugs/quickfix/test/QuickfixMulti.java | 2 +- eclipsePlugin/src/de/tobject/findbugs/FindbugsPlugin.java | 3 +-- .../src/de/tobject/findbugs/builder/FindBugsBuilder.java | 3 +-- .../src/de/tobject/findbugs/builder/FindBugsWorker.java | 2 -- .../umd/cs/findbugs/CurrentThreadExecutorServiceTest.java | 2 +- .../src/test/java/edu/umd/cs/findbugs/DetectorsTest.java | 2 +- .../test/java/edu/umd/cs/findbugs/ba/ch/Subtypes2Test.java | 2 +- .../edu/umd/cs/findbugs/filter/AnnotationMatcherTest.java | 2 +- .../java/edu/umd/cs/findbugs/filter/NotMatcherTest.java | 4 ++-- .../java/edu/umd/cs/findbugs/filter/SourceMatcherTest.java | 6 +++--- .../edu/umd/cs/findbugs/sarif/SarifBugReporterTest.java | 2 +- .../src/main/java/edu/umd/cs/findbugs/PluginLoader.java | 2 +- .../src/main/java/edu/umd/cs/findbugs/ba/SourceFinder.java | 4 ++-- .../umd/cs/findbugs/classfile/impl/DirectoryCodeBase.java | 2 +- .../edu/umd/cs/findbugs/detect/CallToUnsupportedMethod.java | 2 +- .../edu/umd/cs/findbugs/detect/CheckTypeQualifiers.java | 4 ++-- .../umd/cs/findbugs/workflow/RejarClassesForAnalysis.java | 2 +- 17 files changed, 21 insertions(+), 25 deletions(-) diff --git a/eclipsePlugin-test/src/de/tobject/findbugs/quickfix/test/QuickfixMulti.java b/eclipsePlugin-test/src/de/tobject/findbugs/quickfix/test/QuickfixMulti.java index 4a6f5c6d71d..82178ebbe82 100644 --- a/eclipsePlugin-test/src/de/tobject/findbugs/quickfix/test/QuickfixMulti.java +++ b/eclipsePlugin-test/src/de/tobject/findbugs/quickfix/test/QuickfixMulti.java @@ -118,7 +118,7 @@ protected void doTestMultiQuickfixResolution(IProject project, List args) { * @param kind * kind the kind of build being requested, see * IncrementalProjectBuilder - * @throws CoreException */ - private void doBuild(final Map args, final IProgressMonitor monitor, int kind) throws CoreException { + private void doBuild(final Map args, final IProgressMonitor monitor, int kind) { boolean incremental = (kind == IncrementalProjectBuilder.INCREMENTAL_BUILD || kind == IncrementalProjectBuilder.AUTO_BUILD); IProject project = getProject(); diff --git a/eclipsePlugin/src/de/tobject/findbugs/builder/FindBugsWorker.java b/eclipsePlugin/src/de/tobject/findbugs/builder/FindBugsWorker.java index 7ee5c260358..c4621d05c4d 100644 --- a/eclipsePlugin/src/de/tobject/findbugs/builder/FindBugsWorker.java +++ b/eclipsePlugin/src/de/tobject/findbugs/builder/FindBugsWorker.java @@ -367,8 +367,6 @@ private void updateBugCollection(Project findBugsProject, Reporter bugReporter, // props st.newPoint("storeBugCollection"); FindbugsPlugin.storeBugCollection(project, resultCollection, monitor); - } catch (IOException e) { - FindbugsPlugin.getDefault().logException(e, "Error performing SpotBugs results update"); } catch (CoreException e) { FindbugsPlugin.getDefault().logException(e, "Error performing SpotBugs results update"); } diff --git a/spotbugs-tests/src/test/java/edu/umd/cs/findbugs/CurrentThreadExecutorServiceTest.java b/spotbugs-tests/src/test/java/edu/umd/cs/findbugs/CurrentThreadExecutorServiceTest.java index 41aefa45e38..e6ebaab5960 100644 --- a/spotbugs-tests/src/test/java/edu/umd/cs/findbugs/CurrentThreadExecutorServiceTest.java +++ b/spotbugs-tests/src/test/java/edu/umd/cs/findbugs/CurrentThreadExecutorServiceTest.java @@ -62,7 +62,7 @@ void testCloseTwice() { } @Test - void awaitTerminationWithoutShutdown() throws InterruptedException { + void awaitTerminationWithoutShutdown() { ExecutorService executorService = new CurrentThreadExecutorService(); Assertions.assertThrows(IllegalStateException.class, () -> { executorService.awaitTermination(1, TimeUnit.SECONDS); diff --git a/spotbugs-tests/src/test/java/edu/umd/cs/findbugs/DetectorsTest.java b/spotbugs-tests/src/test/java/edu/umd/cs/findbugs/DetectorsTest.java index 728d5ca4e9a..e0e99a184b9 100644 --- a/spotbugs-tests/src/test/java/edu/umd/cs/findbugs/DetectorsTest.java +++ b/spotbugs-tests/src/test/java/edu/umd/cs/findbugs/DetectorsTest.java @@ -89,7 +89,7 @@ private File getFindbugsTestCasesFile(String path) { } @BeforeEach - void setUp() throws Exception { + void setUp() { loadFindbugsPlugin(); } diff --git a/spotbugs-tests/src/test/java/edu/umd/cs/findbugs/ba/ch/Subtypes2Test.java b/spotbugs-tests/src/test/java/edu/umd/cs/findbugs/ba/ch/Subtypes2Test.java index b51ee9618ec..cd99b0a02d7 100644 --- a/spotbugs-tests/src/test/java/edu/umd/cs/findbugs/ba/ch/Subtypes2Test.java +++ b/spotbugs-tests/src/test/java/edu/umd/cs/findbugs/ba/ch/Subtypes2Test.java @@ -94,7 +94,7 @@ class Subtypes2Test extends FindBugsTestCase { ObjectType typeParameterString; @BeforeEach - void setUp() throws Exception { + void setUp() { typeSerializable = ObjectTypeFactory.getInstance("java.io.Serializable"); typeClonable = ObjectTypeFactory.getInstance("java.lang.Cloneable"); typeObject = ObjectTypeFactory.getInstance(Values.DOTTED_JAVA_LANG_OBJECT); diff --git a/spotbugs-tests/src/test/java/edu/umd/cs/findbugs/filter/AnnotationMatcherTest.java b/spotbugs-tests/src/test/java/edu/umd/cs/findbugs/filter/AnnotationMatcherTest.java index 64a3055d4e0..136afd75f02 100644 --- a/spotbugs-tests/src/test/java/edu/umd/cs/findbugs/filter/AnnotationMatcherTest.java +++ b/spotbugs-tests/src/test/java/edu/umd/cs/findbugs/filter/AnnotationMatcherTest.java @@ -128,7 +128,7 @@ private Filter readFilterFromXML() throws IOException { } @Test - void testPerformAnalysis(SpotBugsRunner spotbugs) throws Exception { + void testPerformAnalysis(SpotBugsRunner spotbugs) { BugCollection bugCollection = spotbugs.performAnalysis( Paths.get("../spotbugsTestCases/build/classes/java/main/org/immutables/value/Generated.class"), Paths.get("../spotbugsTestCases/build/classes/java/main/org/immutables/value/Value.class"), diff --git a/spotbugs-tests/src/test/java/edu/umd/cs/findbugs/filter/NotMatcherTest.java b/spotbugs-tests/src/test/java/edu/umd/cs/findbugs/filter/NotMatcherTest.java index 372e6e75fa4..989fe794870 100644 --- a/spotbugs-tests/src/test/java/edu/umd/cs/findbugs/filter/NotMatcherTest.java +++ b/spotbugs-tests/src/test/java/edu/umd/cs/findbugs/filter/NotMatcherTest.java @@ -42,7 +42,7 @@ class NotMatcherTest { private final BugInstance bug = new BugInstance("UUF_UNUSED_FIELD", 0); @Test - void invertsResultsFromWrappedMatcher_doesntMatchWhenWrappedDoesMatch() throws Exception { + void invertsResultsFromWrappedMatcher_doesntMatchWhenWrappedDoesMatch() { Matcher wrappedMatcher = new TestMatcher(true); NotMatcher notMatcher = new NotMatcher(); notMatcher.addChild(wrappedMatcher); @@ -51,7 +51,7 @@ void invertsResultsFromWrappedMatcher_doesntMatchWhenWrappedDoesMatch() throws E } @Test - void invertsResultsFromWrappedMatcher_doesMatchWhenWrappedDoesnt() throws Exception { + void invertsResultsFromWrappedMatcher_doesMatchWhenWrappedDoesnt() { Matcher wrappedMatcher = new TestMatcher(false); NotMatcher notMatcher = new NotMatcher(); notMatcher.addChild(wrappedMatcher); diff --git a/spotbugs-tests/src/test/java/edu/umd/cs/findbugs/filter/SourceMatcherTest.java b/spotbugs-tests/src/test/java/edu/umd/cs/findbugs/filter/SourceMatcherTest.java index 0d81678c376..2bb5a03ef03 100644 --- a/spotbugs-tests/src/test/java/edu/umd/cs/findbugs/filter/SourceMatcherTest.java +++ b/spotbugs-tests/src/test/java/edu/umd/cs/findbugs/filter/SourceMatcherTest.java @@ -96,7 +96,7 @@ void readXML() throws Exception { @Test - void match() throws Exception { + void match() { SourceMatcher sm = new SourceMatcher(fileName); // no source set: test incomplete data @@ -131,7 +131,7 @@ void match() throws Exception { } @Test - void testRealPathMatchWithRegexpAndProject() throws Exception { + void testRealPathMatchWithRegexpAndProject() { // add this test class as the bug target bug.addClass("SourceMatcherTest", null); ClassAnnotation primaryClass = bug.getPrimaryClass(); @@ -155,7 +155,7 @@ void testRealPathMatchWithRegexpAndProject() throws Exception { } @Test - void testRealPathMatchWithRegexpAndAnalysisContext() throws Exception { + void testRealPathMatchWithRegexpAndAnalysisContext() { // add this test class as the bug target bug.addClass("SourceMatcherTest", null); ClassAnnotation primaryClass = bug.getPrimaryClass(); diff --git a/spotbugs-tests/src/test/java/edu/umd/cs/findbugs/sarif/SarifBugReporterTest.java b/spotbugs-tests/src/test/java/edu/umd/cs/findbugs/sarif/SarifBugReporterTest.java index c97893335eb..9be5f63efb0 100644 --- a/spotbugs-tests/src/test/java/edu/umd/cs/findbugs/sarif/SarifBugReporterTest.java +++ b/spotbugs-tests/src/test/java/edu/umd/cs/findbugs/sarif/SarifBugReporterTest.java @@ -308,7 +308,7 @@ void testHelpUriAndTags() { } @Test - void testExtensions() throws PluginException { + void testExtensions() { PluginLoader pluginLoader = DetectorFactoryCollection.instance().getCorePlugin().getPluginLoader(); Plugin plugin = new Plugin("pluginId", "version", null, pluginLoader, true, false); DetectorFactoryCollection dfc = new DetectorFactoryCollection(plugin); diff --git a/spotbugs/src/main/java/edu/umd/cs/findbugs/PluginLoader.java b/spotbugs/src/main/java/edu/umd/cs/findbugs/PluginLoader.java index d5ef1bb5503..1a2479f1691 100644 --- a/spotbugs/src/main/java/edu/umd/cs/findbugs/PluginLoader.java +++ b/spotbugs/src/main/java/edu/umd/cs/findbugs/PluginLoader.java @@ -1178,7 +1178,7 @@ private Plugin constructMinimalPlugin(Document pluginDescriptor, List return constructedPlugin; } - public Document getPluginDescriptor() throws PluginException, PluginDoesntContainMetadataException { + public Document getPluginDescriptor() throws PluginException { Document pluginDescriptor; // Read the plugin descriptor diff --git a/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/SourceFinder.java b/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/SourceFinder.java index 2b73f72d084..3c748ec4795 100644 --- a/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/SourceFinder.java +++ b/spotbugs/src/main/java/edu/umd/cs/findbugs/ba/SourceFinder.java @@ -267,7 +267,7 @@ SourceRepository makeInMemorySourceRepository(final String url) { return r; } - SourceRepository makeJarURLConnectionSourceRepository(final String url) throws MalformedURLException, IOException { + SourceRepository makeJarURLConnectionSourceRepository(final String url) throws IOException { final File file = File.createTempFile("jar_cache", null); file.deleteOnExit(); final BlockingSourceRepository r = new BlockingSourceRepository(); @@ -288,7 +288,7 @@ SourceRepository makeJarURLConnectionSourceRepository(final String url) throws M * @throws IOException * @throws MalformedURLException */ - private InputStream open(final String url) throws IOException, MalformedURLException { + private InputStream open(final String url) throws IOException { InputStream in = null; URLConnection connection = new URL(url).openConnection(); if (getProject().isGuiAvaliable()) { diff --git a/spotbugs/src/main/java/edu/umd/cs/findbugs/classfile/impl/DirectoryCodeBase.java b/spotbugs/src/main/java/edu/umd/cs/findbugs/classfile/impl/DirectoryCodeBase.java index bf10652b94b..9ea6b66a149 100644 --- a/spotbugs/src/main/java/edu/umd/cs/findbugs/classfile/impl/DirectoryCodeBase.java +++ b/spotbugs/src/main/java/edu/umd/cs/findbugs/classfile/impl/DirectoryCodeBase.java @@ -149,7 +149,7 @@ public ICodeBaseEntry lookupResource(String resourceName) { return new DirectoryCodeBaseEntry(this, resourceName); } - InputStream openFile(String resourceName) throws FileNotFoundException, IOException { + InputStream openFile(String resourceName) throws IOException { File path = getFullPathOfResource(resourceName); return new BufferedInputStream(new FileInputStream(path)); } diff --git a/spotbugs/src/main/java/edu/umd/cs/findbugs/detect/CallToUnsupportedMethod.java b/spotbugs/src/main/java/edu/umd/cs/findbugs/detect/CallToUnsupportedMethod.java index 1ff975c4001..986c55b13a8 100644 --- a/spotbugs/src/main/java/edu/umd/cs/findbugs/detect/CallToUnsupportedMethod.java +++ b/spotbugs/src/main/java/edu/umd/cs/findbugs/detect/CallToUnsupportedMethod.java @@ -89,7 +89,7 @@ public void visitClassContext(ClassContext classContext) { * @param classContext * @param method */ - private void analyzeMethod(ClassContext classContext, Method method) throws MethodUnprofitableException, CFGBuilderException, + private void analyzeMethod(ClassContext classContext, Method method) throws CFGBuilderException, DataflowAnalysisException { if (BCELUtil.isSynthetic(method) || (method.getAccessFlags() & Const.ACC_BRIDGE) == Const.ACC_BRIDGE) { return; diff --git a/spotbugs/src/main/java/edu/umd/cs/findbugs/detect/CheckTypeQualifiers.java b/spotbugs/src/main/java/edu/umd/cs/findbugs/detect/CheckTypeQualifiers.java index 210bc95dd94..265f2927058 100644 --- a/spotbugs/src/main/java/edu/umd/cs/findbugs/detect/CheckTypeQualifiers.java +++ b/spotbugs/src/main/java/edu/umd/cs/findbugs/detect/CheckTypeQualifiers.java @@ -256,7 +256,7 @@ private void checkQualifier(XMethod xmethod, CFG cfg, TypeQualifierValue type private void checkDataflow(XMethod xmethod, CFG cfg, TypeQualifierValue typeQualifierValue, ValueNumberDataflow vnaDataflow, ForwardTypeQualifierDataflow forwardDataflow, - BackwardTypeQualifierDataflow backwardDataflow) throws DataflowAnalysisException, CheckedAnalysisException { + BackwardTypeQualifierDataflow backwardDataflow) throws CheckedAnalysisException { for (Iterator i = cfg.locationIterator(); i.hasNext();) { Location loc = i.next(); @@ -371,7 +371,7 @@ private void checkForEqualityTest(XMethod xmethod, CFG cfg, TypeQualifierValue typeQualifierValue, ValueNumberDataflow vnaDataflow, ForwardTypeQualifierDataflow forwardDataflow, - BackwardTypeQualifierDataflow backwardDataflow) throws DataflowAnalysisException, CheckedAnalysisException { + BackwardTypeQualifierDataflow backwardDataflow) throws CheckedAnalysisException { // Check to see if any backwards ALWAYS or NEVER values // reach incompatible sources. diff --git a/spotbugs/src/main/java/edu/umd/cs/findbugs/workflow/RejarClassesForAnalysis.java b/spotbugs/src/main/java/edu/umd/cs/findbugs/workflow/RejarClassesForAnalysis.java index 6eeea437af2..2805eb1a641 100644 --- a/spotbugs/src/main/java/edu/umd/cs/findbugs/workflow/RejarClassesForAnalysis.java +++ b/spotbugs/src/main/java/edu/umd/cs/findbugs/workflow/RejarClassesForAnalysis.java @@ -626,7 +626,7 @@ private void copyEntry(ZipFile zipInputFile, ZipEntry ze, boolean writeToAnalyze zipIn.close(); } - private void advanceAuxiliaryOut() throws IOException, FileNotFoundException { + private void advanceAuxiliaryOut() throws IOException { auxiliaryOut.close(); auxiliaryOut = createZipFile(getNextAuxiliaryFileOutput()); }