Tags: openrewrite/rewrite-static-analysis
Tags
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
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>
Update Gradle wrapper 9.5.1 Use this link to re-run the recipe: https://app.moderne.io/recipes/org.openrewrite.gradle.UpdateGradleWrapper?organizationId=QUxML01vZGVybmUgKyBPcGVuUmV3cml0ZS9PcGVuUmV3cml0ZQ%3D%3D#defaults=W3sidmFsdWUiOiI5LjUuMSIsIm5hbWUiOiJ2ZXJzaW9uIn0seyJ2YWx1ZSI6ImJpbiIsIm5hbWUiOiJkaXN0cmlidXRpb24ifSx7InZhbHVlIjoiYmFmYzE0MWI2MTlhZDYzNTBmZDk3NWZjOTAzMTU2ZGQ1YzE1MTk5OGNjOGIwNThlOGMxMDQ0YWI1ZjdiMDMxZiIsIm5hbWUiOiJkaXN0cmlidXRpb25DaGVja3N1bSJ9XQ== Co-authored-by: Moderne <team@moderne.io>
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
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;`.
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>
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>
PreviousNext