rewrite-static-analysis icon indicating copy to clipboard operation
rewrite-static-analysis copied to clipboard

UnnecessaryThrows still ends up with `Exception 'java.lang.Exception' is never thrown in the method`

Open Pankraz76 opened this issue 8 months ago • 2 comments

Exception 'java.lang.Exception' is never thrown in the method

  • https://docs.openrewrite.org/recipes/staticanalysis/unnecessarythrows
  • https://github.com/apache/maven/blob/3706aa1e5c7b96632eb0b69e1210f7648df0e981/impl/maven-executor/src/test/java/org/apache/maven/cling/executor/MavenExecutorTestSupport.java#L322
Image

Pankraz76 avatar May 01 '25 14:05 Pankraz76

Just so we're clear: You're saying we missed out on removing that throws Exception ?

timtebeek avatar May 01 '25 14:05 timtebeek

exactly, much was updated but this one not.

Pankraz76 avatar May 01 '25 14:05 Pankraz76

@Pankraz76 If that's not a problem for you, I suggest to post the context information (like expected vs. observed, or code to reproduce) as text, not screenshots. It's easier if this reporting structure is followed to: understand what's the issue, and decide on the actual expectations, validate the assumptions, etc.

greg-at-moderne avatar Jul 07 '25 14:07 greg-at-moderne

Since that method is protected we should not remove the throws declaration as per:

  • https://github.com/openrewrite/rewrite-static-analysis/pull/553

timtebeek avatar Jul 26 '25 17:07 timtebeek