Skip to content

Surface implausible JUnit @Timeout values by rewriting them to minutes#1041

Merged
timtebeek merged 1 commit into
mainfrom
tim/long-form-unit-recipe
Jun 20, 2026
Merged

Surface implausible JUnit @Timeout values by rewriting them to minutes#1041
timtebeek merged 1 commit into
mainfrom
tim/long-form-unit-recipe

Conversation

@timtebeek

@timtebeek timtebeek commented Jun 20, 2026

Copy link
Copy Markdown
Member
  • Implements option a) of JUnit 5 recipe request: detect and replace implausible timeouts #452: JUnit Jupiter's @Timeout defaults to TimeUnit.SECONDS, so a value like @Timeout(10000) silently means ~2.8 hours and is almost certainly a millisecond mistake. The new ImplausibleTimeoutToMinutes recipe rewrites such second-based timeouts at or above a configurable threshold (default 1000s) to the equivalent minutes, e.g. @Timeout(10000)@Timeout(value = 167, unit = TimeUnit.MINUTES), preserving the (likely erroneous) semantics while making the mistake obvious in review. It only fires when the effective unit is SECONDS (default or explicit) and the value is an int/long literal, leaving non-SECONDS units, non-literals, and plausibly small values untouched. The recipe is wired into JupiterBestPractices (and thus both JUnit 5 and 6 best practices), with recipes.csv regenerated accordingly.

  • Fixes JUnit 5 recipe request: detect and replace implausible timeouts #452

Rewrites second-based @timeout values at or above a configurable
threshold (default 1000s) to the equivalent minutes, e.g.
@timeout(10000) -> @timeout(value = 167, unit = TimeUnit.MINUTES),
making likely millisecond mistakes visible. Implements option a) of #452
and adds it to JupiterBestPractices.

Fixes #452
@github-project-automation github-project-automation Bot moved this to In Progress in OpenRewrite Jun 20, 2026
@timtebeek timtebeek merged commit 8ade02d into main Jun 20, 2026
1 check passed
@timtebeek timtebeek deleted the tim/long-form-unit-recipe branch June 20, 2026 14:39
@github-project-automation github-project-automation Bot moved this from In Progress to Done in OpenRewrite Jun 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

JUnit 5 recipe request: detect and replace implausible timeouts

1 participant