Skip to main content

8.59.1 release (2025-07-24)

Total recipe count: 4006

info

This changelog only shows what recipes have been added, removed, or changed. OpenRewrite may do releases that do not include these types of changes. To see these changes, please go to the releases page.

New Recipes

static class WithMessage {

@BeforeTemplate
void assertFalseBefore(String message) {
assertFalse(true, message);
}

@BeforeTemplate
void assertTrueBefore(String message) {
assertTrue(false, message);
}

@AfterTemplate
@UseImportPolicy(value = STATIC_IMPORT_ALWAYS)
void after(String message) {
fail(message);
}
}

.

static class WithoutMessage {

@BeforeTemplate
void assertFalseBefore() {
assertFalse(true);
}

@BeforeTemplate
void assertTrueBefore() {
assertTrue(false);
}

@AfterTemplate
@UseImportPolicy(value = STATIC_IMPORT_ALWAYS)
void after() {
fail();
}
}

.

static final class AssertThatHasDays {

@BeforeTemplate
AbstractLongAssert<?> before(Duration duration, long days) {
return assertThat(duration.toDays()).isEqualTo(days);
}

@AfterTemplate
AbstractDurationAssert<?> after(Duration duration, long days) {
return assertThat(duration).hasDays(days);
}
}

.

static final class AssertThatHasHours {

@BeforeTemplate
AbstractLongAssert<?> before(Duration duration, long hours) {
return assertThat(duration.toHours()).isEqualTo(hours);
}

@AfterTemplate
AbstractDurationAssert<?> after(Duration duration, long hours) {
return assertThat(duration).hasHours(hours);
}
}

.

static final class AssertThatHasMillis {

@BeforeTemplate
AbstractLongAssert<?> before(Duration duration, long millis) {
return assertThat(duration.toMillis()).isEqualTo(millis);
}

@AfterTemplate
AbstractDurationAssert<?> after(Duration duration, long millis) {
return assertThat(duration).hasMillis(millis);
}
}

.

static final class AssertThatHasMinutes {

@BeforeTemplate
AbstractLongAssert<?> before(Duration duration, long minutes) {
return assertThat(duration.toMinutes()).isEqualTo(minutes);
}

@AfterTemplate
AbstractDurationAssert<?> after(Duration duration, long minutes) {
return assertThat(duration).hasMinutes(minutes);
}
}

.

static final class AssertThatHasNanos {

@BeforeTemplate
AbstractLongAssert<?> before(Duration duration, long nanos) {
return assertThat(duration.toNanos()).isEqualTo(nanos);
}

@AfterTemplate
AbstractDurationAssert<?> after(Duration duration, long nanos) {
return assertThat(duration).hasNanos(nanos);
}
}

.

static final class AssertThatHasSeconds {

@BeforeTemplate
AbstractLongAssert<?> before(Duration duration, long seconds) {
return assertThat(duration.toSeconds()).isEqualTo(seconds);
}

@AfterTemplate
AbstractDurationAssert<?> after(Duration duration, long seconds) {
return assertThat(duration).hasSeconds(seconds);
}
}

.

static final class AssertThatIsNegative {

@BeforeTemplate
AbstractBooleanAssert<?> before(Duration duration) {
return assertThat(duration.isNegative()).isTrue();
}

@BeforeTemplate
AbstractDurationAssert<?> before2(Duration duration) {
return assertThat(duration).isLessThan(Duration.ZERO);
}

@AfterTemplate
AbstractDurationAssert<?> after(Duration duration) {
return assertThat(duration).isNegative();
}
}

.

static final class AssertThatIsPositive {

@BeforeTemplate
AbstractDurationAssert<?> before(Duration duration) {
return assertThat(duration).isGreaterThan(Duration.ZERO);
}

@AfterTemplate
AbstractDurationAssert<?> after(Duration duration) {
return assertThat(duration).isPositive();
}
}

.

static final class AssertThatIsZero {

@BeforeTemplate
AbstractBooleanAssert<?> before(Duration duration) {
return assertThat(duration.isZero()).isTrue();
}

@BeforeTemplate
AbstractDurationAssert<?> before2(Duration duration) {
return assertThat(duration).isEqualTo(Duration.ZERO);
}

@AfterTemplate
AbstractDurationAssert<?> after(Duration duration) {
return assertThat(duration).isZero();
}
}

.

static final class AssertThatIsAfterOrEqualTo {

@BeforeTemplate
AbstractBooleanAssert<?> before(Instant actual, Instant other) {
return assertThat(actual.isBefore(other)).isFalse();
}

@AfterTemplate
AbstractInstantAssert<?> after(Instant actual, Instant other) {
return assertThat(actual).isAfterOrEqualTo(other);
}
}

.

static final class AssertThatIsAfter {

@BeforeTemplate
AbstractBooleanAssert<?> before(Instant actual, Instant other) {
return assertThat(actual.isAfter(other)).isTrue();
}

@AfterTemplate
AbstractInstantAssert<?> after(Instant actual, Instant other) {
return assertThat(actual).isAfter(other);
}
}

.

static final class AssertThatIsBeforeOrEqualTo {

@BeforeTemplate
AbstractBooleanAssert<?> before(Instant actual, Instant other) {
return assertThat(actual.isAfter(other)).isFalse();
}

@AfterTemplate
AbstractInstantAssert<?> after(Instant actual, Instant other) {
return assertThat(actual).isBeforeOrEqualTo(other);
}
}

.

static final class AssertThatIsBefore {

@BeforeTemplate
AbstractBooleanAssert<?> before(Instant actual, Instant other) {
return assertThat(actual.isBefore(other)).isTrue();
}

@AfterTemplate
AbstractInstantAssert<?> after(Instant actual, Instant other) {
return assertThat(actual).isBefore(other);
}
}

.

static final class AssertThatIsBetween {

@BeforeTemplate
AbstractInstantAssert<?> before(Instant actual, Instant start, Instant end) {
return Refaster.anyOf(assertThat(actual).isAfterOrEqualTo(start).isBeforeOrEqualTo(end), assertThat(actual).isBeforeOrEqualTo(end).isAfterOrEqualTo(start));
}

@AfterTemplate
AbstractInstantAssert<?> after(Instant actual, Instant start, Instant end) {
return assertThat(actual).isBetween(start, end);
}
}

.

static final class AssertThatIsStrictlyBetween {

@BeforeTemplate
AbstractInstantAssert<?> before(Instant actual, Instant start, Instant end) {
return Refaster.anyOf(assertThat(actual).isAfter(start).isBefore(end), assertThat(actual).isBefore(end).isAfter(start));
}

@AfterTemplate
AbstractInstantAssert<?> after(Instant actual, Instant start, Instant end) {
return assertThat(actual).isStrictlyBetween(start, end);
}
}

.

static final class AssertThatMapContainsOnlyKey<K, V> {

@BeforeTemplate
AbstractCollectionAssert<?, Collection<? extends K>, K, ?> before(Map<K, V> map, K key) {
return assertThat(map.keySet()).containsExactly(key);
}

@AfterTemplate
@UseImportPolicy(value = STATIC_IMPORT_ALWAYS)
MapAssert<K, V> after(Map<K, V> map, K key) {
return assertThat(map).containsOnlyKeys(key);
}
}

.

static final class AssertThatHasSameHashCodeAs<T> {

@BeforeTemplate
AbstractIntegerAssert<?> before(T object1, T object2) {
return assertThat(object1.hashCode()).isEqualTo(object2.hashCode());
}

@AfterTemplate
@UseImportPolicy(value = STATIC_IMPORT_ALWAYS)
ObjectAssert<T> after(T object1, T object2) {
return assertThat(object1).hasSameHashCodeAs(object2);
}
}

.

static final class AssertThatIsInstanceOf2<S, T> {

@BeforeTemplate
AbstractBooleanAssert<?> before(T object, Class<S> clazz) {
return assertThat(clazz.isInstance(object)).isTrue();
}

@AfterTemplate
@UseImportPolicy(value = STATIC_IMPORT_ALWAYS)
ObjectAssert<T> after(T object, Class<S> clazz) {
return assertThat(object).isInstanceOf(clazz);
}
}

.

static final class AssertThatIsNotNull<T> {

@BeforeTemplate
@SuppressWarnings(value = "AssertThatIsNotSameAs")
AbstractBooleanAssert<? extends AbstractBooleanAssert<?>> before(T object) {
return Refaster.anyOf(assertThat(object == null).isFalse(), assertThat(object != null).isTrue());
}

@AfterTemplate
@UseImportPolicy(value = STATIC_IMPORT_ALWAYS)
ObjectAssert<T> after(T object) {
return assertThat(object).isNotNull();
}
}

.

static final class AssertThatIsNotSameAs<T> {

@BeforeTemplate
AbstractBooleanAssert<?> before(T object1, T object2) {
return Refaster.anyOf(assertThat(object1 == object2).isFalse(), assertThat(object1 != object2).isTrue());
}

@AfterTemplate
@UseImportPolicy(value = STATIC_IMPORT_ALWAYS)
ObjectAssert<T> after(T object1, T object2) {
return assertThat(object1).isNotSameAs(object2);
}
}

.

static final class AssertThatIsNull<T> {

@BeforeTemplate
@SuppressWarnings(value = "AssertThatIsSameAs")
void before(T object) {
assertThat(object == null).isTrue();
}

@BeforeTemplate
@SuppressWarnings(value = "AssertThatIsSameAs")
void before2(T object) {
assertThat(object != null).isFalse();
}

@AfterTemplate
@UseImportPolicy(value = STATIC_IMPORT_ALWAYS)
void after(T object) {
assertThat(object).isNull();
}
}

.

static final class AssertThatIsSameAs<T> {

@BeforeTemplate
AbstractBooleanAssert<?> before(T object1, T object2) {
return Refaster.anyOf(assertThat(object1 == object2).isTrue(), assertThat(object1 != object2).isFalse());
}

@AfterTemplate
@UseImportPolicy(value = STATIC_IMPORT_ALWAYS)
ObjectAssert<T> after(T object1, T object2) {
return assertThat(object1).isSameAs(object2);
}
}

.

static final class AssertThatDoesNotExist {

@BeforeTemplate
AbstractBooleanAssert<?> before(Path actual) {
return assertThat(Files.exists(actual)).isFalse();
}

@AfterTemplate
AbstractPathAssert<?> after(Path actual) {
return assertThat(actual).doesNotExist();
}
}

.

static final class AssertThatEndsWithRaw {

@BeforeTemplate
AbstractBooleanAssert<?> before(Path actual, Path other) {
return assertThat(actual.endsWith(other)).isTrue();
}

@AfterTemplate
AbstractPathAssert<?> after(Path actual, Path other) {
return assertThat(actual).endsWithRaw(other);
}
}

.

static final class AssertThatExists {

@BeforeTemplate
AbstractBooleanAssert<?> before(Path actual) {
return assertThat(Files.exists(actual)).isTrue();
}

@AfterTemplate
AbstractPathAssert<?> after(Path actual) {
return assertThat(actual).exists();
}
}

.

static final class AssertThatHasFileName {

@BeforeTemplate
AbstractPathAssert<?> before(Path actual, String fileName) {
return assertThat(actual.getFileName()).hasToString(fileName);
}

@AfterTemplate
AbstractPathAssert<?> after(Path actual, String fileName) {
return assertThat(actual).hasFileName(fileName);
}
}

.

static final class AssertThatHasNoParent {

@BeforeTemplate
void before(Path actual) {
assertThat(actual.getParent()).isNull();
}

@AfterTemplate
void after(Path actual) {
assertThat(actual).hasNoParent();
}
}

.

static final class AssertThatHasParentRaw {

@BeforeTemplate
AbstractPathAssert<?> before(Path actual, Path expected) {
return assertThat(actual.getParent()).isEqualTo(expected);
}

@AfterTemplate
AbstractPathAssert<?> after(Path actual, Path expected) {
return assertThat(actual).hasParentRaw(expected);
}
}

.

static final class AssertThatIsAbsolute {

@BeforeTemplate
AbstractBooleanAssert<?> before(Path actual) {
return assertThat(actual.isAbsolute()).isTrue();
}

@AfterTemplate
AbstractPathAssert<?> after(Path actual) {
return assertThat(actual).isAbsolute();
}
}

.

static final class AssertThatIsDirectory {

@BeforeTemplate
AbstractBooleanAssert<?> before(Path actual) {
return assertThat(Files.isDirectory(actual)).isTrue();
}

@AfterTemplate
AbstractPathAssert<?> after(Path actual) {
return assertThat(actual).isDirectory();
}
}

.

static final class AssertThatIsExecutable {

@BeforeTemplate
AbstractBooleanAssert<?> before(Path actual) {
return assertThat(Files.isExecutable(actual)).isTrue();
}

@AfterTemplate
AbstractPathAssert<?> after(Path actual) {
return assertThat(actual).isExecutable();
}
}

.

static final class AssertThatIsReadable {

@BeforeTemplate
AbstractBooleanAssert<?> before(Path actual) {
return assertThat(Files.isReadable(actual)).isTrue();
}

@AfterTemplate
AbstractPathAssert<?> after(Path actual) {
return assertThat(actual).isReadable();
}
}

.

static final class AssertThatIsRegularFile {

@BeforeTemplate
AbstractBooleanAssert<?> before(Path actual) {
return assertThat(Files.isRegularFile(actual)).isTrue();
}

@AfterTemplate
AbstractPathAssert<?> after(Path actual) {
return assertThat(actual).isRegularFile();
}
}

.

static final class AssertThatIsRelative {

@BeforeTemplate
AbstractBooleanAssert<?> before(Path actual) {
return assertThat(actual.isAbsolute()).isFalse();
}

@AfterTemplate
AbstractPathAssert<?> after(Path actual) {
return assertThat(actual).isRelative();
}
}

.

static final class AssertThatIsSymbolicLink {

@BeforeTemplate
AbstractBooleanAssert<?> before(Path actual) {
return assertThat(Files.isSymbolicLink(actual)).isTrue();
}

@AfterTemplate
AbstractPathAssert<?> after(Path actual) {
return assertThat(actual).isSymbolicLink();
}
}

.

static final class AssertThatIsWritable {

@BeforeTemplate
AbstractBooleanAssert<?> before(Path actual) {
return assertThat(Files.isWritable(actual)).isTrue();
}

@AfterTemplate
AbstractPathAssert<?> after(Path actual) {
return assertThat(actual).isWritable();
}
}

.

static final class AssertThatStartsWithRaw {

@BeforeTemplate
AbstractBooleanAssert<?> before(Path actual, Path other) {
return assertThat(actual.startsWith(other)).isTrue();
}

@AfterTemplate
AbstractPathAssert<?> after(Path actual, Path other) {
return assertThat(actual).startsWithRaw(other);
}
}

.

static final class AssertThatStringDoesNotEndWith {

@BeforeTemplate
AbstractBooleanAssert<?> before(String string, String prefix) {
return assertThat(string.endsWith(prefix)).isFalse();
}

@AfterTemplate
@UseImportPolicy(value = STATIC_IMPORT_ALWAYS)
AbstractStringAssert<?> after(String string, String prefix) {
return assertThat(string).doesNotEndWith(prefix);
}
}

.

static final class AssertThatStringDoesNotStartWith {

@BeforeTemplate
AbstractBooleanAssert<?> before(String string, String prefix) {
return assertThat(string.startsWith(prefix)).isFalse();
}

@AfterTemplate
@UseImportPolicy(value = STATIC_IMPORT_ALWAYS)
AbstractStringAssert<?> after(String string, String prefix) {
return assertThat(string).doesNotStartWith(prefix);
}
}

.

static final class AssertThatStringEndsWith {

@BeforeTemplate
AbstractBooleanAssert<?> before(String string, String prefix) {
return assertThat(string.endsWith(prefix)).isTrue();
}

@AfterTemplate
@UseImportPolicy(value = STATIC_IMPORT_ALWAYS)
AbstractStringAssert<?> after(String string, String prefix) {
return assertThat(string).endsWith(prefix);
}
}

.

static final class AssertThatStringStartsWith {

@BeforeTemplate
AbstractBooleanAssert<?> before(String string, String prefix) {
return assertThat(string.startsWith(prefix)).isTrue();
}

@AfterTemplate
@UseImportPolicy(value = STATIC_IMPORT_ALWAYS)
AbstractStringAssert<?> after(String string, String prefix) {
return assertThat(string).startsWith(prefix);
}
}

.

static final class AbstractThrowableAssertCauseIsSameAs {

@BeforeTemplate
@SuppressWarnings(value = "deprecation")
AbstractThrowableAssert<?, ? extends Throwable> before(AbstractThrowableAssert<?, ? extends Throwable> throwableAssert, Throwable expected) {
return throwableAssert.hasCauseReference(expected);
}

@AfterTemplate
AbstractThrowableAssert<?, ? extends Throwable> after(AbstractThrowableAssert<?, ? extends Throwable> throwableAssert, Throwable expected) {
return throwableAssert.cause().isSameAs(expected);
}
}

.

Removed Recipes

  • io.moderne.devcenter.SecurityOriginalStarter: This is the same set of recipes as the original DevCenter security card.
  • org.openrewrite.java.testing.cleanup.AssertLiteralBooleanToFailRecipe: Using fail is more direct and clear.
  • org.openrewrite.java.testing.mockito.NoInitializationForInjectMock: Remove either the @InjectMocks annotation from fields, or the initializer, based on the initializer.
  • In the case of a no-args constructor, remove the initializer and retain the annotation.
  • In the case of any other initializer, remove the annotation and retain the initializer.
  • tech.picnic.errorprone.refasterrules.AssertJEnumerableRulesRecipes$EnumerableAssertIsEmptyRecipe: Recipe created for the following Refaster template:
static final class EnumerableAssertIsEmpty<E> {

@BeforeTemplate
void before(EnumerableAssert<?, E> enumAssert) {
Refaster.anyOf(enumAssert.hasSize(0), enumAssert.hasSizeLessThanOrEqualTo(0), enumAssert.hasSizeLessThan(1));
}

@BeforeTemplate
void before(AbstractIterableAssert<?, ?, E, ?> enumAssert) {
enumAssert.size().isNotPositive();
}

@AfterTemplate
void after(EnumerableAssert<?, E> enumAssert) {
enumAssert.isEmpty();
}
}

.

  • tech.picnic.errorprone.refasterrules.CollectionRulesRecipes$CollectionAddAllToCollectionBlockRecipe: Recipe created for the following Refaster template:
static final class CollectionAddAllToCollectionBlock<T, S extends T> {

@BeforeTemplate
void before(Collection<T> addTo, Collection<S> elementsToAdd) {
elementsToAdd.forEach(addTo::add);
}

@BeforeTemplate
void before2(Collection<T> addTo, Collection<S> elementsToAdd) {
for (T element : elementsToAdd) {
addTo.add(element);
}
}

@BeforeTemplate
void before3(Collection<T> addTo, Collection<S> elementsToAdd) {
for (S element : elementsToAdd) {
addTo.add(element);
}
}

@AfterTemplate
void after(Collection<T> addTo, Collection<S> elementsToAdd) {
addTo.addAll(elementsToAdd);
}
}

.

  • tech.picnic.errorprone.refasterrules.CollectionRulesRecipes$CollectionRemoveAllFromCollectionBlockRecipe: Recipe created for the following Refaster template:
static final class CollectionRemoveAllFromCollectionBlock<T, S extends T> {

@BeforeTemplate
void before(Collection<T> removeFrom, Collection<S> elementsToRemove) {
elementsToRemove.forEach(removeFrom::remove);
}

@BeforeTemplate
void before2(Collection<T> removeFrom, Collection<S> elementsToRemove) {
for (T element : elementsToRemove) {
removeFrom.remove(element);
}
}

@BeforeTemplate
void before3(Collection<T> removeFrom, Collection<S> elementsToRemove) {
for (S element : elementsToRemove) {
removeFrom.remove(element);
}
}

@AfterTemplate
void after(Collection<T> removeFrom, Collection<S> elementsToRemove) {
removeFrom.removeAll(elementsToRemove);
}
}

.

Changed Recipes

  • org.openrewrite.java.dependencies.DependencyVulnerabilityCheck was changed:
    • Old Options:
      • maximumUpgradeDelta: { type: UpgradeDelta, required: false }
      • overrideTransitive: { type: Boolean, required: false }
      • scope: { type: String, required: false }
    • New Options:
      • maximumUpgradeDelta: { type: UpgradeDelta, required: false }
      • overrideTransitive: { type: Boolean, required: false }
      • preferDirectUpgrade: { type: Boolean, required: false }
      • scope: { type: String, required: false }
  • org.openrewrite.java.logging.logback.ConfigureLoggerLevel was changed:
    • Old Options:
      • className: { type: String, required: true }
      • logLevel: { type: LogLevel, required: true }
    • New Options:
      • className: { type: String, required: true }
      • filePattern: { type: String, required: false }
      • logLevel: { type: LogLevel, required: true }