Skip to main content

Standalone Recipes

This doc contains recipes that are not included as part of any larger composite recipe. These recipes can be run independently and are not bundled with other recipes.

Total standalone recipes: 958

org.openrewrite

rewrite-cobol

rewrite-core

  • org.openrewrite.AddToGitignore
    • Add entries to .gitignore
    • Adds entries to the project's .gitignore file. If no .gitignore file exists, one will be created. Existing entries that match will not be duplicated.
  • org.openrewrite.ExcludeFileFromGitignore
    • Remove ignoral of files or directories from .gitignore
    • This recipe will remove a file or directory from the .gitignore file. If the file or directory is already in the .gitignore file, it will be removed or negated. If the file or directory is not in the .gitignore file, no action will be taken.
  • org.openrewrite.FindCollidingSourceFiles
    • Find colliding source files
    • Finds source files which share a path with another source file. There should always be exactly one source file per path within a repository. This is a diagnostic for finding problems in OpenRewrite parsers/build plugins.
  • org.openrewrite.FindDeserializationErrors
    • Find deserialization errors
    • Produces a data table collecting all deserialization errors of serialized LSTs.
  • org.openrewrite.FindGitProvenance
    • Show Git source control metadata
    • List out the contents of each unique GitProvenance marker in the set of source files. When everything is working correctly, exactly one such marker should be printed as all source files are expected to come from the same repository / branch / commit hash.
  • org.openrewrite.FindLstProvenance
    • Find LST provenance
    • Produces a data table showing what versions of OpenRewrite/Moderne tooling was used to produce a given LST.
  • org.openrewrite.FindParseFailures
    • Find source files with ParseExceptionResult markers
    • This recipe explores parse failures after an LST is produced for classifying the types of failures that can occur and prioritizing fixes according to the most common problems.
  • org.openrewrite.FindQuarks
    • Find instances of type Quark
    • Quark source files are pointers to the existence of a file without capturing any of the contents of the file.
  • org.openrewrite.FindStyles
    • Find styles
    • Find and report the styles attached to each source file. Styles are output as valid OpenRewrite style YAML that can be used directly in rewrite.yml configuration.
  • org.openrewrite.IsInRepository
    • Is in repository
    • A search recipe which marks files that are in a repository with one of the supplied names. Intended for use as a precondition for other recipes being run over many different repositories.
  • org.openrewrite.ListRuntimeClasspath
    • List runtime classpath
    • A diagnostic utility which emits the runtime classpath to a data table.
  • org.openrewrite.MoveFile
    • Move a file
    • Move a file to a different directory. The file name will remain the same.
  • org.openrewrite.SetFilePermissions
    • Set file permission attributes
    • Set a file's read, write and executable permission attributes.
  • org.openrewrite.Singleton
    • Singleton
    • Used as a precondition to ensure that a recipe attempts to make changes only once. Accidentally including multiple copies/instances of the same large composite recipes is a common mistake. If those recipes are marked with this precondition the performance penalty is limited. This recipe does nothing useful run on its own. ## Usage in YAML recipes Add org.openrewrite.Singleton as a precondition: yaml --- type: specs.openrewrite.org/v1beta/recipe name: com.example.Append displayName: My recipe preconditions: - org.openrewrite.Singleton recipeList: - org.openrewrite.text.AppendToTextFile: relativeFileName: report.txt content: 'Recipe executed' ## Usage in Java recipes Wrap visitors with Singleton.singleton(this, visitor) to ensure only the first equivalent recipe instance makes changes: java @Override public TreeVisitor<?, ExecutionContext> getVisitor(Accumulator acc) \{ return singleton(this, new TreeVisitor<Tree, ExecutionContext>() \{ @Override public Tree visit(@Nullable Tree tree, ExecutionContext ctx) \{ // Your transformation logic return tree; \} \}); \} @Override public Collection<SourceFile> generate(Accumulator acc, ExecutionContext ctx) \{ if (!isSingleton(this, ctx)) \{ return Collections.emptyList(); \} // Generate new sources return results; \} @Override public TreeVisitor<?, ExecutionContext> getVisitor(Accumulator acc) \{ return singleton(this, new TreeVisitor<Tree, ExecutionContext>() \{ // Visitor logic \}); \} Note: Singleton status is determined by the recipe's equals() and hashCode() methods. If equivalent instances of a recipe are not considered singletons, ensure your recipe class correctly implements these methods. The easiest way is to use Lombok's @Value annotation on your recipe class, which automatically generates correct equals() and hashCode() implementations based on all fields.
  • org.openrewrite.search.FindBuildMetadata
    • Find build metadata
    • Find source files with matching build metadata.
  • org.openrewrite.search.FindParseToPrintInequality
    • Find parse to print inequality
    • OpenRewrite Parser implementations should produce SourceFile objects whose printAll() method should be byte-for-byte equivalent with the original source file. When this isn't true, recipes can still run on the SourceFile and even produce diffs, but the diffs would fail to apply as a patch to the original source file. Most Parser use Parser#requirePrintEqualsInput to produce a ParseError when they fail to produce a SourceFile that is print idempotent.
  • org.openrewrite.search.RepositoryContainsFile
    • Repository contains file
    • Intended to be used primarily as a precondition for other recipes, this recipe checks if a repository contains a specific file or files matching a pattern. If present all files in the repository are marked with a SearchResult marker. If you want to get only the matching file as a search result, use FindSourceFiles instead.
  • org.openrewrite.text.AppendToTextFile
    • Append to text file
    • Appends or replaces content of an existing plain text file, or creates a new one if it doesn't already exist. Please note that this recipes requires existing plain text files' format to be successfully parsable by OpenRewrite. If a file is left unchanged, it might be parsed as a Quark rather than plain text. In such case, use the plainTextMask option. See the Gradle or Maven plugin configuration page.
  • org.openrewrite.text.ChangeText
    • Change text
    • Completely replaces the contents of the text file with other text. Use together with a FindSourceFiles precondition to limit which files are changed.
  • org.openrewrite.text.EndOfLineAtEndOfFile
    • End of Line @ End of File (EOL @ EOF)
    • Ensure that the file ends with the newline character. Note: If this recipe modifies a file, it converts the file into plain text. As such, this recipe should be run after any recipe that modifies the language-specific LST.
  • org.openrewrite.text.FindMultiselect
    • Experimental find text with multiselect
    • Search for text, treating all textual sources as plain text. This version of the recipe exists to experiment with multiselect recipe options.
  • org.openrewrite.text.RemoveByteOrderMark
    • Remove byte order mark (BOM)
    • Removes UTF-8 byte order marks from the beginning of files. The BOM character (U+FEFF) is generally unnecessary in UTF-8 files and can cause issues with some tools.

rewrite-docker

rewrite-gradle

rewrite-groovy

rewrite-hcl

rewrite-java

rewrite-javascript

rewrite-json

rewrite-kotlin

rewrite-maven

  • org.openrewrite.maven.AddCommentToMavenDependency
    • Add a comment to a Maven dependency or plugin
    • Adds a comment as the first element in a Maven dependency or plugin.
  • org.openrewrite.maven.AddDevelocityMavenExtension
    • Add the Develocity Maven extension
    • To integrate the Develocity Maven extension into Maven projects, ensure that the develocity-maven-extension is added to the .mvn/extensions.xml file if not already present. Additionally, configure the extension by adding the .mvn/develocity.xml configuration file.
  • org.openrewrite.maven.AddManagedPlugin
    • Add Managed Maven plugin
    • Add the specified Maven plugin to the Plugin Managed of the pom.xml.
  • org.openrewrite.maven.AddParentPom
    • Add Maven parent
    • Add a parent pom to a Maven pom.xml. Does nothing if a parent pom is already present.
  • org.openrewrite.maven.AddRepository
    • Add repository
    • Adds a new Maven Repository or updates a matching repository.
  • org.openrewrite.maven.AddRuntimeConfig
    • Add a configuration option for the Maven runtime
    • Add a new configuration option for the Maven runtime if not already present.
  • org.openrewrite.maven.ChangeExclusion
    • Change Maven dependency exclusion
    • Modify Maven dependency exclusions, changing the group ID, artifact Id, or both. Useful when an excluded dependency has been renamed and references to it must be updated.
  • org.openrewrite.maven.ChangePluginConfiguration
    • Change Maven plugin configuration
    • Apply the specified configuration to a Maven plugin. Will not add the plugin if it does not already exist in the pom.
  • org.openrewrite.maven.ChangePluginDependencies
    • Change Maven plugin dependencies
    • Applies the specified dependencies to a Maven plugin. Will not add the plugin if it does not already exist in the pom.
  • org.openrewrite.maven.ChangeProjectVersion
    • Change Maven Project Version
    • Change the project version of a Maven pom.xml. Identifies the project to be changed by its groupId and artifactId. If the version is defined as a property, this recipe will only change the property value if the property exists within the same pom.
  • org.openrewrite.maven.EnableDevelocityBuildCache
    • Enable Develocity build cache
    • Add Develocity build cache configuration to any .mvn/ Develocity configuration file that lack existing configuration.
  • org.openrewrite.maven.IncrementProjectVersion
    • Increment Maven project version
    • Increase Maven project version by incrementing either the major, minor, or patch version as defined by semver. Other versioning schemes are not supported.
  • org.openrewrite.maven.ManageDependencies
    • Manage dependencies
    • Make existing dependencies managed by moving their version to be specified in the dependencyManagement section of the POM.
  • org.openrewrite.maven.ManagedToRuntimeDependencies
    • Convert managed dependencies to runtime dependencies
    • This recipe processes Maven POMs, converting all <dependencyManagement> entries into runtime scoped <dependencies> entries. Import scoped BOMs (like jackson-bom) are left unmodified in <dependencyManagement>. Some style guidelines prefer that <dependencyManagement> be used only for BOMs. This maintain that style while avoiding introducing new symbols onto the compile classpath unintentionally.
  • org.openrewrite.maven.MigrateToMaven4
    • Migrate to Maven 4
    • Migrates Maven POMs from Maven 3 to Maven 4, addressing breaking changes and deprecations. This recipe updates property expressions, lifecycle phases, removes duplicate plugin declarations, and replaces removed properties to ensure compatibility with Maven 4.
  • org.openrewrite.maven.RemoveMavenWrapper
    • Remove Maven wrapper
    • Remove Maven wrapper files from a project. This includes the mvnw and mvnw.cmd scripts, and the .mvn/wrapper directory.
  • org.openrewrite.maven.RemoveRepository
    • Remove repository
    • Removes a matching Maven repository.
  • org.openrewrite.maven.RemoveUnusedProperties
    • Remove unused properties
    • Detect and remove Maven property declarations which do not have any usage within the project.
  • org.openrewrite.maven.UpdateMavenWrapper
    • Update Maven wrapper
    • Update the version of Maven used in an existing Maven wrapper.
  • org.openrewrite.maven.UpgradeTransitiveDependencyVersion
    • Upgrade transitive Maven dependencies
    • Upgrades the version of a transitive dependency in a Maven pom file. Leaves direct dependencies unmodified. Can be paired with the regular Upgrade Dependency Version recipe to upgrade a dependency everywhere, regardless of whether it is direct or transitive.
  • org.openrewrite.maven.search.DoesNotIncludeDependency
    • Does not include Maven dependency
    • A precondition which returns false if visiting a Maven pom which includes the specified dependency in the classpath of some scope. For compatibility with multimodule projects, this should most often be applied as a precondition.
  • org.openrewrite.maven.search.EffectiveDependencies
    • Effective dependencies
    • Emit the data of binary dependency relationships.
  • org.openrewrite.maven.search.EffectiveManagedDependencies
    • Effective managed dependencies
    • Emit the data of binary dependency relationships.
  • org.openrewrite.maven.search.EffectiveMavenRepositories
    • List effective Maven repositories
    • Lists the Maven repositories that would be used for dependency resolution, in order of precedence. This includes Maven repositories defined in the Maven settings file (and those contributed by active profiles) as determined when the LST was produced.
  • org.openrewrite.maven.search.FindManagedDependency
    • Find Maven dependency management entry
    • Finds first-order dependency management entries, i.e. dependencies that are defined directly in a project.
  • org.openrewrite.maven.search.FindMavenProject
    • Find Maven projects
    • Maven projects are pom.xml files with a MavenResolutionResult marker.
  • org.openrewrite.maven.search.FindMavenSettings
    • Find effective maven settings
    • List the effective maven settings file for the current project.
  • org.openrewrite.maven.search.FindPlugin
    • Find Maven plugin
    • Finds a Maven plugin within a pom.xml.
  • org.openrewrite.maven.search.FindProperties
    • Find Maven project properties
    • Finds the specified Maven project properties within a pom.xml.
  • org.openrewrite.maven.search.FindRepositoryOrder
    • Maven repository order
    • Determine the order in which dependencies will be resolved for each pom.xml based on its defined repositories and effective settings.xml.
  • org.openrewrite.maven.search.FindScm
    • Find SCM tag
    • Finds any <scm> tag directly inside the <project> root of a Maven pom.xml file.
  • org.openrewrite.maven.search.ModuleHasDependency
    • Module has dependency
    • Searches for Maven modules that have a dependency matching the specified groupId and artifactId. Places a SearchResult marker on all sources within a module with a matching dependency. This recipe is intended to be used as a precondition for other recipes. For example this could be used to limit the application of a spring boot migration to only projects that use spring-boot-starter, limiting unnecessary upgrading. If the search result you want is instead just the build.gradle(.kts) file applying the plugin, use the FindDependency recipe instead.
  • org.openrewrite.maven.search.ModuleHasPlugin
    • Module has plugin
    • Searches for Maven modules that have a plugin matching the specified groupId and artifactId. Places a SearchResult marker on all sources within a module with a matching plugin. This recipe is intended to be used as a precondition for other recipes. For example this could be used to limit the application of a spring boot migration to only projects that apply the spring boot plugin, limiting unnecessary upgrading. If the search result you want is instead just the build.gradle(.kts) file applying the plugin, use the FindPlugins recipe instead.
  • org.openrewrite.maven.search.ParentPomInsight
    • Maven parent insight
    • Find Maven parents matching a groupId and artifactId.
  • org.openrewrite.maven.utilities.PrintMavenAsDot
    • Print Maven dependency hierarchy in DOT format
    • The DOT language format is specified here.

rewrite-properties

  • org.openrewrite.properties.AddProperty
    • Add a new property
    • Adds a new property to a property file. Attempts to place the new property in alphabetical order by the property keys. Whitespace before and after the = must be included in the property and value.
  • org.openrewrite.properties.AddPropertyComment
    • Add comment before property key
    • Add a new comment before a property key if not already present, optionally commenting out the property.
  • org.openrewrite.properties.CopyValue
    • Copy property value
    • Copies a property value from one key to another. The existing key/value pair remains unaffected by this change. If the destination key already exists, its value will be replaced. By default, creates the destination key if it does not exist.
  • org.openrewrite.properties.CreatePropertiesFile
    • Create Properties file
    • Create a new Properties file.

rewrite-toml

rewrite-xml

rewrite-yaml

org.openrewrite.meta

rewrite-analysis

org.openrewrite.recipe

rewrite-all

  • org.openrewrite.FindCallGraph
    • Find call graph
    • Produces a data table where each row represents a method call.
  • org.openrewrite.FindDuplicateSourceFiles
    • Find duplicate source files
    • Record the presence of LSTs with duplicate paths, indicating that the same file was parsed more than once.
  • org.openrewrite.LanguageComposition
    • Language composition report
    • Counts the number of lines of the various kinds of source code and data formats parsed by OpenRewrite. Comments are not included in line counts. This recipe emits its results as two data tables, making no changes to any source file. One data table is per-file, the other is per-repository.

rewrite-apache

rewrite-codemods

rewrite-cucumber-jvm

rewrite-feature-flags

rewrite-github-actions

rewrite-gitlab

rewrite-hibernate

rewrite-jackson

rewrite-java-dependencies

  • org.openrewrite.java.dependencies.DependencyResolutionDiagnostic
    • Dependency resolution diagnostic
    • Recipes which manipulate dependencies must be able to successfully access the artifact repositories and resolve dependencies from them. This recipe produces two data tables used to understand the state of dependency resolution. The Repository accessibility report lists all the artifact repositories known to the project and whether respond to network access. The network access is attempted while the recipe is run and so is representative of current conditions. The Gradle dependency configuration errors lists all the dependency configurations that failed to resolve one or more dependencies when the project was parsed. This is representative of conditions at the time the LST was parsed.
  • org.openrewrite.java.dependencies.FindDependency
    • Find Maven and Gradle dependencies
    • Finds direct dependencies declared in Maven and Gradle build files. This does not search transitive dependencies. To detect both direct and transitive dependencies use org.openrewrite.java.dependencies.DependencyInsight This recipe works for both Maven and Gradle projects.
  • org.openrewrite.java.dependencies.FindRepositoryOrder
    • Maven repository order
    • Determine the order in which dependencies will be resolved for each pom.xml or build.gradle based on its defined repositories and effective settings.
  • org.openrewrite.java.dependencies.RelocatedDependencyCheck
    • Find relocated dependencies
    • Find Maven and Gradle dependencies and Maven plugins that have relocated to a new groupId or artifactId. Relocation information comes from the oga-maven-plugin maintained by Jonathan Lermitage, Filipe Roque and others. This recipe makes no changes to any source file by default. Add changeDependencies=true to change dependencies, but note that you might need to run additional recipes to update imports and adopt other breaking changes.
  • org.openrewrite.java.dependencies.UpgradeTransitiveDependencyVersion
    • Upgrade transitive Gradle or Maven dependencies
    • Upgrades the version of a transitive dependency in a Maven pom.xml or Gradle build.gradle. Leaves direct dependencies unmodified. Can be paired with the regular Upgrade Dependency Version recipe to upgrade a dependency everywhere, regardless of whether it is direct or transitive.
  • org.openrewrite.java.dependencies.search.DoesNotIncludeDependency
    • Does not include dependency for Gradle and Maven
    • A precondition which returns false if visiting a Gradle file / Maven pom which includes the specified dependency in the classpath of some Gradle configuration / Maven scope. For compatibility with multimodule projects, this should most often be applied as a precondition.
  • org.openrewrite.java.dependencies.search.FindDuplicateClasses
    • Find duplicate classes on the classpath
    • Detects classes that appear in multiple dependencies on the classpath. This is similar to what the Maven duplicate-finder-maven-plugin does. Duplicate classes can cause runtime issues when different versions of the same class are loaded.
  • org.openrewrite.java.dependencies.search.FindMinimumDependencyVersion
    • Find the oldest matching dependency version in use
    • The oldest dependency version in use is the lowest dependency version in use in any source set of any subproject of a repository. It is possible that, for example, the main source set of a project uses Jackson 2.11, but a test source set uses Jackson 2.16. In this case, the oldest Jackson version in use is Java 2.11.
  • org.openrewrite.java.dependencies.search.FindMinimumJUnitVersion
    • Find minimum JUnit version
    • A recipe to find the minimum version of JUnit dependencies. This recipe is designed to return the minimum version of JUnit in a project. It will search for JUnit 4 and JUnit 5 dependencies in the project. If both versions are found, it will return the minimum version of JUnit 4. If a minimumVersion is provided, the recipe will search to see if the minimum version of JUnit used by the project is no lower than the minimumVersion. For example: if the minimumVersion is 4, and the project has JUnit 4.12 and JUnit 5.7, the recipe will return JUnit 4.12. If the project has only JUnit 5.7, the recipe will return JUnit 5.7. Another example: if the minimumVersion is 5, and the project has JUnit 4.12 and JUnit 5.7, the recipe will not return any results.
  • org.openrewrite.java.dependencies.search.RepositoryHasDependency
    • Repository has dependency
    • Searches for both Gradle and Maven modules that have a dependency matching the specified groupId and artifactId. Places a SearchResult marker on all sources within a repository with a matching dependency. This recipe is intended to be used as a precondition for other recipes. For example this could be used to limit the application of a spring boot migration to only projects that use a springframework dependency, limiting unnecessary upgrading. If the search result you want is instead just the build.gradle(.kts) or pom.xml file applying the plugin, use the FindDependency recipe instead.

rewrite-jenkins

rewrite-liberty

rewrite-logging-frameworks

rewrite-micrometer

rewrite-micronaut

rewrite-migrate-java

rewrite-netty

rewrite-okhttp

rewrite-quarkus

rewrite-rewrite

rewrite-spring

  • org.openrewrite.gradle.spring.AddSpringDependencyManagementPlugin
    • Add io.spring.dependency-management plugin, if in use
    • Prior to Spring Boot 2.0 the dependency management plugin was applied automatically as part of the overall spring boot plugin. Afterwards the dependency-management plugin must be applied explicitly, or Gradle's platform() feature may be used instead. This recipe makes usage of io-spring.dependency-management explicit in anticipation of upgrade to Spring Boot 2.0 or later.
  • org.openrewrite.java.spring.ExpandProperties
    • Expand Spring YAML properties
    • Expand YAML properties to not use the dot syntax shortcut.
  • org.openrewrite.java.spring.ImplicitWebAnnotationNames
    • Remove implicit web annotation names
    • Removes implicit web annotation names.
  • org.openrewrite.java.spring.NoHttpExchangeAnnotation
    • Remove HttpExchange annotations
    • Replace method declaration @HttpExchange annotations with @GetExchange, @PostExchange, etc.
  • org.openrewrite.java.spring.RenameBean
    • Rename bean
    • Renames a Spring bean, both declaration and references.
  • org.openrewrite.java.spring.UpdateApiManifest
    • Update the API manifest
    • Keep a consolidated manifest of the API endpoints that this application exposes up-to-date.
  • org.openrewrite.java.spring.boot2.search.FindUpgradeRequirementsSpringBoot_2_5
    • Find patterns that require updating for Spring Boot 2.5
    • Looks for a series of patterns that have not yet had auto-remediation recipes developed for.
  • org.openrewrite.java.spring.boot2.search.IntegrationSchedulerPoolRecipe
    • Integration scheduler pool size
    • Spring Integration now reuses an available TaskScheduler rather than configuring its own. In a typical application setup relying on the auto-configuration, this means that Spring Integration uses the auto-configured task scheduler that has a pool size of 1. To restore Spring Integration’s default of 10 threads, use the spring.task.scheduling.pool.size property.
  • org.openrewrite.java.spring.boot3.AddRouteTrailingSlash
    • Add trailing slash to Spring routes
    • This is part of Spring MVC and WebFlux URL Matching Changes, as of Spring Framework 6.0, the trailing slash matching configuration option has been deprecated and its default value set to false. This means that previously, a controller @GetMapping("/some/greeting") would match both GET /some/greeting and GET /some/greeting/, but it doesn't match GET /some/greeting/ anymore by default and will result in an HTTP 404 error. This recipe is to add declaration of additional route explicitly on the controller handler (like @GetMapping("/some/greeting", "/some/greeting/").
  • org.openrewrite.java.spring.boot3.AddSetUseTrailingSlashMatch
    • Add SetUseTrailingSlashMatch() in configuration
    • This is part of Spring MVC and WebFlux URL Matching Changes, as of Spring Framework 6.0, the trailing slash matching configuration option has been deprecated and its default value set to false. This means that previously, a controller @GetMapping("/some/greeting") would match both GET /some/greeting and GET /some/greeting/, but it doesn't match GET /some/greeting/ anymore by default and will result in an HTTP 404 error. This recipe is change the default with the global Spring MVC or Webflux configuration.
  • org.openrewrite.java.spring.boot3.MaintainTrailingSlashURLMappings
    • Maintain trailing slash URL mappings
    • This is part of Spring MVC and WebFlux URL Matching Changes, as of Spring Framework 6.0, the trailing slash matching configuration option has been deprecated and its default value set to false. This means that previously, a controller @GetMapping("/some/greeting") would match both GET /some/greeting and GET /some/greeting/, but it doesn't match GET /some/greeting/ anymore by default and will result in an HTTP 404 error. This recipe is to maintain trailing slash in all HTTP url mappings.
  • org.openrewrite.java.spring.boot3.SpringBoot33BestPractices
    • Spring Boot 3.3 best practices
    • Applies best practices to Spring Boot 3 applications.
  • org.openrewrite.java.spring.http.SpringWebDependency
    • Find Spring Web dependency
    • Find compile scoped Spring Web dependency for Maven and Gradle, both direct and transitive.
  • org.openrewrite.java.spring.opentelemetry.MigrateToOpenTelemetry
    • Complete migration to OpenTelemetry
    • Comprehensive migration to OpenTelemetry including dependencies, configuration properties, and Java code changes. This recipe handles migration from Spring Cloud Sleuth, Brave/Zipkin, and OpenTracing to OpenTelemetry.
  • org.openrewrite.java.spring.search.FindApiCalls
    • Find HTTP API calls via RestTemplate
    • Find outbound HTTP API calls made via Spring's RestTemplate class.
  • org.openrewrite.java.spring.search.FindApiEndpoints
    • Find Spring API endpoints
    • Find all HTTP API endpoints exposed by Spring applications. More specifically, this marks method declarations annotated with @RequestMapping, @GetMapping, @PostMapping, @PutMapping, @DeleteMapping, and @PatchMapping as search results.
  • org.openrewrite.java.spring.search.FindConfigurationProperties
    • Find Spring @ConfigurationProperties
    • Find all classes annotated with @ConfigurationProperties and extract their prefix values. This is useful for discovering all externalized configuration properties in Spring Boot applications.
  • org.openrewrite.java.spring.search.FindSpringComponents
    • Find Spring components
    • Find Spring components, including controllers, services, repositories, return types of @Bean annotated methods, etc.
  • org.openrewrite.java.spring.security6.RemoveOauth2LoginConfig
    • Remove unneeded oauth2Login config when upgrading to Spring Security 6
    • oauth2Login() is a Spring Security feature that allows users to authenticate with an OAuth2 or OpenID Connect 1.0 provider. When a user is authenticated using this feature, they are granted a set of authorities that determines what actions they are allowed to perform within the application. In Spring Security 5, the default authority given to a user authenticated with an OAuth2 or OpenID Connect 1.0 provider via oauth2Login() is ROLE_USER. This means that the user is allowed to access the application's resources as a regular user. However, in Spring Security 6, the default authority given to a user authenticated with an OAuth2 provider is OAUTH2_USER, and the default authority given to a user authenticated with an OpenID Connect 1.0 provider is OIDC_USER. These authorities are more specific and allow for better customization of the user's permissions within the application. If you are upgrading to Spring Security 6 and you have previously configured a GrantedAuthoritiesMapper to handle the authorities of users authenticated via oauth2Login(), you can remove it completely as the new default authorities should be sufficient.
  • org.openrewrite.java.spring.ws.UpgradeSpringWs_4_0
    • Migrate to Spring WS 4.0
    • Migrate applications to Spring WS 4.0. This recipe handles the removal of Apache Axiom support in Spring WS 4.0.x by migrating Axiom-based SOAP message handling to SAAJ (SOAP with Attachments API for Java). Note that Spring WS 4.1+ restores Axiom support if upgrading to that version is preferred.
  • org.openrewrite.maven.spring.UpgradeExplicitSpringBootDependencies
    • Upgrade Spring dependencies
    • Upgrades dependencies according to the specified version of spring boot. Spring boot has many direct and transitive dependencies. When a module has an explicit dependency on one of these it may also need to be upgraded to match the version used by spring boot.

rewrite-spring-to-quarkus

rewrite-static-analysis

  • org.openrewrite.recipe.rewrite-static-analysis.InlineDeprecatedMethods
    • Inline deprecated delegating methods
    • Automatically generated recipes to inline deprecated method calls that delegate to other methods in the same class.
  • org.openrewrite.staticanalysis.AddSerialVersionUidToSerializable
    • Add serialVersionUID to a Serializable class when missing
    • A serialVersionUID field is strongly recommended in all Serializable classes. If this is not defined on a Serializable class, the compiler will generate this value. If a change is later made to the class, the generated value will change and attempts to deserialize the class will fail. Explicitly declaring this field gives you control over binary compatibility across versions.
  • org.openrewrite.staticanalysis.AvoidBoxedBooleanExpressions
    • Avoid boxed boolean expressions
    • Under certain conditions the java.lang.Boolean type is used as an expression, and it may throw a NullPointerException if the value is null. Using Boolean.TRUE.equals(...) guards against unboxing a null reference in control flow positions like if conditions and ternary operators.
  • org.openrewrite.staticanalysis.CodeCleanup
    • Code cleanup
    • Automatically cleanup code, e.g. remove unnecessary parentheses, simplify expressions.
  • org.openrewrite.staticanalysis.CommonDeclarationSiteTypeVariances
    • Properly use declaration-site type variance for well-known types
    • When using a method parameter like Function<IN, OUT>, it should rather be Function<? super IN, ? extends OUT>. This recipe checks for method parameters of well-known types.
  • org.openrewrite.staticanalysis.CommonStaticAnalysis
    • Common static analysis issues
    • Resolve common static analysis issues (also known as SAST issues).
  • org.openrewrite.staticanalysis.ControlFlowIndentation
    • Control flow statement indentation
    • Program flow control statements like if, while, and for can omit curly braces when they apply to only a single statement. This recipe ensures that any statements which follow that statement are correctly indented to show they are not part of the flow control statement. Misleading indentation can give the false impression that a line executes conditionally when it actually runs unconditionally, which is a common source of logic errors.
  • org.openrewrite.staticanalysis.ExplicitCharsetOnStringGetBytes
    • Set charset encoding explicitly when calling String#getBytes
    • This makes the behavior of the code platform neutral. It will not override any existing explicit encodings, even if they don't match the default encoding option. Relying on the platform default charset can produce different results across environments, leading to subtle data corruption bugs.
  • org.openrewrite.staticanalysis.ExplicitLambdaArgumentTypes
    • Use explicit types on lambda arguments
    • Adds explicit types on lambda arguments, which are otherwise optional. This can make the code clearer and easier to read. This does not add explicit types on arguments when the lambda has one or two parameters and does not have a block body, as things are considered more readable in those cases. For example, stream.map((a, b) -> a.length); will not have explicit types added.
  • org.openrewrite.staticanalysis.ExplicitThis
    • Use explicit this.field and this.method()
    • Add explicit 'this.' prefix to field and method access.
  • org.openrewrite.staticanalysis.FinalizeLocalVariables
    • Finalize local variables
    • Adds the final modifier keyword to local variables which are not reassigned.
  • org.openrewrite.staticanalysis.FinalizeMethodArguments
    • Finalize method arguments
    • Adds the final modifier keyword to method parameters.
  • org.openrewrite.staticanalysis.HiddenField
    • Hidden field
    • Refactor local variables or parameters which shadow a field defined in the same class. Shadowing a field with a local variable of the same name makes it easy to accidentally reference the wrong one, leading to confusing bugs.
  • org.openrewrite.staticanalysis.InterruptedExceptionHandling
    • Restore interrupted state in catch blocks
    • When InterruptedException is caught, Thread.currentThread().interrupt() should be called to restore the thread's interrupted state. Failing to do so can suppress the interruption signal and prevent proper thread cancellation.
  • org.openrewrite.staticanalysis.JavaApiBestPractices
    • Java API best practices
    • Use the Java standard library in a way that is most idiomatic.
  • org.openrewrite.staticanalysis.LowercasePackage
    • Rename packages to lowercase
    • By convention all Java package names should contain only lowercase letters, numbers, and dashes. This recipe converts any uppercase letters in package names to be lowercase. Consistent package naming prevents confusion and potential issues on case-insensitive file systems.
  • org.openrewrite.staticanalysis.MaskCreditCardNumbers
    • Mask credit card numbers
    • When encountering string literals which appear to be credit card numbers, mask the last eight digits with the letter 'X'.
  • org.openrewrite.staticanalysis.MemberNameCaseInsensitiveDuplicates
    • Members should not have names differing only by capitalization
    • Looking at the set of methods and fields in a class and all of its parents, no two members should have names that differ only in capitalization. This rule will not report if a method overrides a parent method. Members with near-identical names are easily confused, leading to bugs where the wrong field or method is referenced.
  • org.openrewrite.staticanalysis.MoveConditionsToWhile
    • Convert while (true) with initial if break to loop condition
    • Simplifies while (true) loops where the first statement is an if statement that only contains a break. The condition is inverted and moved to the loop condition for better readability.
  • org.openrewrite.staticanalysis.NoFinalizedLocalVariables
    • Don't use final on local variables
    • Remove the final modifier keyword from local variables regardless of whether they are used within a local class or an anonymous class.
  • org.openrewrite.staticanalysis.OnlyCatchDeclaredExceptions
    • Replace catch(Exception) with specific declared exceptions thrown in the try block
    • Replaces catch(Exception e) blocks with a multi-catch block (catch (SpecificException1 | SpecificException2 e)) containing only the exceptions declared thrown by method or constructor invocations within the try block that are not already caught by more specific catch clauses. Catching a broad Exception type can unintentionally swallow runtime exceptions that indicate programming errors, making bugs harder to detect and diagnose.
  • org.openrewrite.staticanalysis.PreferEqualityComparisonOverDifferenceCheck
    • Prefer direct comparison of numbers
    • Replace a - b == 0 with a == b, a - b != 0 with a != b, a - b < 0 with a < b, and similar transformations for all comparison operators to improve readability and avoid overflow issues.
  • org.openrewrite.staticanalysis.PreferIncrementOperator
    • Prefer increment/decrement and compound assignment operators
    • Prefer the use of increment and decrement operators (++, --, +=, -=) over their more verbose equivalents.
  • org.openrewrite.staticanalysis.ReferentialEqualityToObjectEquals
    • Replace referential equality operators with Object equals method invocations when the operands both override Object.equals(Object obj)
    • Using == or != compares object references, not the equality of two objects. This modifies code where both sides of a binary operation (== or !=) override Object.equals(Object obj) except when the comparison is within an overridden Object.equals(Object obj) method declaration itself. The resulting transformation must be carefully reviewed since any modifications change the program's semantics. When a class defines its own notion of equality through equals, using reference comparison is almost always a bug that causes logically identical objects to be treated as different.
  • org.openrewrite.staticanalysis.RemoveEmptyJavaDocParameters
    • Remove JavaDoc @param, @return, and @throws with no description
    • Removes @param, @return, and @throws with no description from JavaDocs.
  • org.openrewrite.staticanalysis.RemoveInstanceOfPatternMatch
    • Removes from code Java 14's instanceof pattern matching
    • Adds an explicit variable declaration at the beginning of if statement instead of instanceof pattern matching.
  • org.openrewrite.staticanalysis.RemoveJavaDocAuthorTag
    • Remove author tags from JavaDocs
    • Removes author tags from JavaDocs to reduce code maintenance.
  • org.openrewrite.staticanalysis.RemoveUnneededAssertion
    • Remove unneeded assertions
    • Remove unneeded assertions like assert true, assertTrue(true), or assertFalse(false).
  • org.openrewrite.staticanalysis.RemoveUnneededBlock
    • Remove unneeded block
    • Flatten blocks into inline statements when possible. Unnecessary nested blocks add indentation and scope boundaries that obscure the control flow, often indicating code that should be extracted into its own method.
  • org.openrewrite.staticanalysis.RenameExceptionInEmptyCatch
    • Rename caught exceptions in empty catch blocks to ignored
    • Renames caught exceptions in empty catch blocks to ignored. ignored will be incremented by 1 if a namespace conflict exists.
  • org.openrewrite.staticanalysis.RenameLocalVariablesToCamelCase
    • Reformat local variable names to camelCase
    • Reformat local variable and method parameter names to camelCase to comply with Java naming convention. The recipe will not rename variables declared in for loop controls or catches with a single character. The first character is set to lower case and existing capital letters are preserved. Special characters that are allowed in java field names $ and _ are removed (unless the name starts with one). If a special character is removed the next valid alphanumeric will be capitalized. Currently, does not support renaming members of classes. The recipe will not rename a variable if the result already exists in the class, conflicts with a java reserved keyword, or the result is blank. Consistent naming conventions improve readability and reduce friction when navigating unfamiliar code.
  • org.openrewrite.staticanalysis.RenamePrivateFieldsToCamelCase
    • Reformat private field names to camelCase
    • Reformat private field names to camelCase to comply with Java naming convention. The recipe will not rename fields with default, protected or public access modifiers. The recipe will not rename private constants. The first character is set to lower case and existing capital letters are preserved. Special characters that are allowed in java field names $ and _ are removed. If a special character is removed the next valid alphanumeric will be capitalized. The recipe will not rename a field if the result already exists in the class, conflicts with a java reserved keyword, or the result is blank. Consistent naming conventions improve code readability and help developers quickly understand the purpose and scope of fields.
  • org.openrewrite.staticanalysis.ReorderAnnotationAttributes
    • Reorder annotation attributes alphabetically
    • Reorder annotation attributes to be alphabetical. Positional arguments (those without explicit attribute names) are left in their original position.
  • org.openrewrite.staticanalysis.ReplaceApacheCommonsLang3ValidateNotNullWithObjectsRequireNonNull
    • Replace org.apache.commons.lang3.Validate#notNull with Objects#requireNonNull
    • Replace org.apache.commons.lang3.Validate.notNull(..) with Objects.requireNonNull(..).
  • org.openrewrite.staticanalysis.ReplaceCollectionToArrayArgWithEmptyArray
    • Use Empty Array for Collection.toArray()
    • Changes new array creation with Collection#toArray(T[]) to use an empty array argument, which is better for performance. According to the Collection#toArray(T[]) documentation: > If the collection fits in the specified array, it is returned therein. However, although it's not intuitive, allocating a right-sized array ahead of time to pass to the API appears to be generally worse for performance according to benchmarking and JVM developers due to a number of implementation details in both Java and the virtual machine. H2 achieved significant performance gains by switching to empty arrays instead pre-sized ones.
  • org.openrewrite.staticanalysis.ReplaceDuplicateStringLiterals
    • Replace duplicate String literals
    • Replaces String literals with a length of 5 or greater repeated a minimum of 3 times. Qualified String literals include final Strings, method invocations, and new class invocations. Adds a new private static final String or uses an existing equivalent class field. A new variable name will be generated based on the literal value if an existing field does not exist. The generated name will append a numeric value to the variable name if a name already exists in the compilation unit. Centralizing repeated string values into constants makes refactoring safer and reduces the risk of inconsistent updates.
  • org.openrewrite.staticanalysis.ReplaceOptionalIsPresentWithIfPresent
    • Replace Optional#isPresent() with Optional#ifPresent()
    • Replace Optional#isPresent() with Optional#ifPresent(). Please note that this recipe is only suitable for if-blocks that lack an Else-block and have a single condition applied.
  • org.openrewrite.staticanalysis.ReplaceRedundantFormatWithPrintf
    • Replace redundant String format invocations that are wrapped with PrintStream operations
    • Replaces PrintStream.print(String.format(format, ...args)) with PrintStream.printf(format, ...args) (and for println, appends a newline to the format string).
  • org.openrewrite.staticanalysis.ReplaceTextBlockWithString
    • Replace text block with regular string
    • Replace text block with a regular multi-line string. Text blocks that fit on a single line without concatenation or escaped newlines gain no readability benefit from the triple-quote syntax and are clearer as plain string literals.
  • org.openrewrite.staticanalysis.SillyEqualsCheck
    • Silly equality checks should not be made
    • Detects .equals() calls that compare incompatible types and will always return false. Replaces .equals(null) with == null and array .equals() with Arrays.equals(). Flags comparisons between unrelated types or between arrays and non-arrays.
  • org.openrewrite.staticanalysis.SimplifyBooleanExpressionWithDeMorgan
    • Simplify boolean expressions using De Morgan's laws
    • Applies De Morgan's laws to simplify boolean expressions with negation. Transforms !(a && b) to !a || !b and !(a || b) to !a && !b. Distributing negations inward eliminates the outer ! and makes each individual condition's polarity immediately visible, which aids comprehension.
  • org.openrewrite.staticanalysis.SimplifyCompoundStatement
    • Simplify compound statement
    • Fixes or removes useless compound statements. For example, removing b &= true, and replacing b &= false with b = false.
  • org.openrewrite.staticanalysis.SimplifyConsecutiveAssignments
    • Simplify consecutive assignments
    • Combine consecutive assignments into a single statement where possible.
  • org.openrewrite.staticanalysis.SimplifyDurationCreationUnits
    • Simplify java.time.Duration units
    • Simplifies java.time.Duration units to be more human-readable.
  • org.openrewrite.staticanalysis.SimplifyElseBranch
    • Simplify else branch if it only has a single if
    • Simplify else branch if it only has a single if.
  • org.openrewrite.staticanalysis.SimplifyForLoopBoundaryComparison
    • Simplify for loop boundary comparisons
    • Replace <= with < in for loop conditions by adjusting the comparison operands. For example, i <= n - 1 simplifies to i < n, and i <= n becomes i < n + 1.
  • org.openrewrite.staticanalysis.SimplifyTernaryRecipes
    • Simplify ternary expressions
    • Simplifies various types of ternary expressions to improve code readability. Ternaries that simply select between true and false are redundant wrappers around the condition itself and add unnecessary complexity.
  • org.openrewrite.staticanalysis.SingleLineCommentSpacing
    • Add space after // in single-line comments
    • Ensures there is exactly one space after // in single-line comments when missing.
  • org.openrewrite.staticanalysis.SortedSetStreamToLinkedHashSet
    • Sorted set stream should be collected to LinkedHashSet
    • Converts set.stream().sorted().collect(Collectors.toSet()) to set.stream().sorted().collect(LinkedHashSet::new).
  • org.openrewrite.staticanalysis.StaticAccessViaInstance
    • Static members should be accessed via the class name
    • Accessing static fields or calling static methods on an instance reference is misleading. Static members should be accessed using the declaring class name instead.
  • org.openrewrite.staticanalysis.TernaryOperatorsShouldNotBeNested
    • Ternary operators should not be nested
    • Nested ternary operators can be hard to read quickly. Prefer simpler constructs for improved readability. If supported, this recipe will try to replace nested ternaries with switch expressions. Deeply nested conditional expressions obscure the branching logic and make it easy to misread which value corresponds to which condition.
  • org.openrewrite.staticanalysis.UnwrapRepeatableAnnotations
    • Unwrap @Repeatable annotations
    • Java 8 introduced the concept of @Repeatable annotations, making the wrapper annotation unnecessary. Using the repeatable form directly reduces nesting and makes the individual annotations easier to scan.
  • org.openrewrite.staticanalysis.UseAsBuilder
    • Chain calls to builder methods
    • Chain calls to builder methods that are on separate lines into one chain of builder calls.
  • org.openrewrite.staticanalysis.UseForEachRemoveInsteadOfSetRemoveAll
    • Replace java.util.Set#removeAll(java.util.Collection) with java.util.Collection#forEach(Set::remove)
    • Using java.util.Collection#forEach(Set::remove) rather than java.util.Set#removeAll(java.util.Collection) may improve performance due to a possible O(n^2) complexity.
  • org.openrewrite.staticanalysis.UseLambdaForFunctionalInterface
    • Use lambda expressions instead of anonymous classes
    • Instead of anonymous class declarations, use a lambda where possible. Using lambdas to replace anonymous classes can lead to more expressive and maintainable code, improve code readability, reduce code duplication, and achieve better performance in some cases.
  • org.openrewrite.staticanalysis.maven.MavenJavadocNonAsciiRecipe
    • Remove non-ASCII characters from Javadoc
    • Maven's javadoc-plugin configuration does not support non-ASCII characters. What makes it tricky is the error is very ambiguous and doesn't help in any way. This recipe removes those non-ASCII characters.

rewrite-testing-frameworks

rewrite-third-party