Skip to content

Tags: openrewrite/rewrite-static-analysis

Tags

v2.39.0

Toggle v2.39.0's commit message
Extract documentation examples from tests

Use this link to re-run the recipe: https://app.moderne.io/recipes/org.openrewrite.java.recipes.ExamplesExtractor?organizationId=QUxML01vZGVybmUgKyBPcGVuUmV3cml0ZQ%3D%3D

Co-authored-by: Moderne <team@moderne.io>

v2.38.0

Toggle v2.38.0's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Use unnamed variable for unused try-with-resources resource on Java 2…

…1+ (#930)

UseTryWithResources always emitted a named resource variable, even when
the resource is never referenced in the try body. Under -Xlint:all -Werror
that unused variable fails the build.

When the resource is unused in the try body and the target Java version is
>= 21, emit the unnamed variable _ (JEP 443/456) instead.

Fixes #927

v2.37.0

Toggle v2.37.0's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Fix false positive in `AnnotateNullableParameters` when parameter der… (

#868)

* Fix false positive in `AnnotateNullableParameters` when parameter dereferenced before null check

* Simplify `NullCheckAndDereferenceVisitor` in `AnnotateNullableParameters`

Replace cursor-message state with plain instance fields keyed by
`JavaType.Variable` so scope-shadowed identifiers stay distinct, drop
the redundant method-invocation/unary arms of `handleCondition` (now
reached via the standard visitor traversal), and remove the narrative
comments that duplicated what the code already says.

* Document lexical dereference tracking and add guard-clause test in AnnotateNullableParameters

---------

Co-authored-by: stefanod <stefano.dallapalma@adyen.com>
Co-authored-by: Tim te Beek <tim@moderne.io>

v2.35.0

Toggle v2.35.0's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Replace `var` with interface type in `UseLambdaForFunctionalInterface` (

#896)

* Replace `var` with interface type in `UseLambdaForFunctionalInterface`

A lambda is a poly expression and needs an explicit target type from
the declaration (JLS 14.4.1, 15.27.1), but `var` borrows its type from
the right-hand side. Converting `var x = new Foo() {...}` to a lambda
while keeping `var` produced code that no longer compiles.

When the initializer of a `var` local is converted to a lambda, replace
the `var` token with the anonymous class's interface type. Diamonds on
the right-hand side are expanded from the resolved lambda type so the
emitted declaration compiles without unchecked warnings.

Fixes #895

* Refactor: use JavaVarKeyword marker and dedupe diamond resolution

Detect `var` via the `JavaVarKeyword` marker the parser attaches, rather
than string-comparing the identifier name — avoids tripping on a user
identifier literally named `var`.

Extract the diamond-to-resolved-type rebuild that `maybeAddCast` and the
new `visitVariableDeclarations` share into a `resolveDiamond` helper, and
inline the single-use `isVarType` predicate.

* Return directly instead of reassigning the result

v2.34.1

Toggle v2.34.1's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Skip `SimplifyConsecutiveAssignments` when initializer would self-ref…

…erence (#882)

When the first statement is a variable declaration and the following
compound assignment's right-hand side references the variable being
declared, folding produced an initializer that read the variable before
it was assigned, e.g. `int result = state ^ result >>> 1;`.

v2.34.0

Toggle v2.34.0's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
bugfix: false positive in AnnotateNullableParameters when parameter … (

…#865)

* bugfix:  false positive in AnnotateNullableParameters when parameter is dereferenced before null check

* Check all arguments for null-checked parameters

Addresses review feedback: custom null-checkers may accept the parameter in a position other than first (e.g., `assertNotNull(message, param)`).

---------

Co-authored-by: stefanod <stefano.dallapalma@adyen.com>
Co-authored-by: Tim te Beek <tim@moderne.io>

v2.33.1

Toggle v2.33.1's commit message
Extract documentation examples from tests

Use this link to re-run the recipe: https://app.moderne.io/recipes/org.openrewrite.java.recipes.ExamplesExtractor?organizationId=QUxML09wZW4gU291cmNlL09wZW5SZXdyaXRl

Co-authored-by: Moderne <team@moderne.io>

v2.33.0

Toggle v2.33.0's commit message
Extract documentation examples from tests

Use this link to re-run the recipe: https://app.moderne.io/recipes/org.openrewrite.java.recipes.ExamplesExtractor?organizationId=QUxML09wZW4gU291cmNlL09wZW5SZXdyaXRl

Co-authored-by: Moderne <team@moderne.io>

v2.32.0

Toggle v2.32.0's commit message
OpenRewrite recipe best practices

Use this link to re-run the recipe: https://app.moderne.io/recipes/org.openrewrite.recipes.rewrite.OpenRewriteRecipeBestPractices?organizationId=QUxML01vZGVybmUvTW9kZXJuZSArIE9wZW5SZXdyaXRl

Co-authored-by: Moderne <team@moderne.io>