A throws clause lists an exception twice, or one that another listed exception covers

tx0/java:overlapping-throwsstrictwarningstyle

What it finds

throws IOException, FileNotFoundException lists a subclass of an exception already listed, and throws Exception, IOException one that Exception covers; the extra entries say nothing to callers, who must handle the broad type anyway.

Reported is an exception in a throws clause that appears twice, or that is a known subclass of another listed one among the common JDK exceptions.

From the rule's source, redundant_throws.rs.

Example from the rule's tests
import java.io.FileNotFoundException;import java.io.IOException; class Files2 {  void open() throws IOException, FileNotFoundException {}tx0 reports: FileNotFoundException is already covered   void read() throws Exception, IOException {}tx0 reports: IOException is already covered   void write() throws IOException, InterruptedException {}}
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

Turn it on, off or suppress it

The rule runs from the strict tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/java:overlapping-throws" = "warning"

To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:

// tx0: ignore[tx0/java:overlapping-throws] reason="..."

tx0 explain tx0/java:overlapping-throws shows the same in the terminal. Found a false positive? Report it.