org.openrewrite
rewrite-cobol
License: Moderne Source Available License
7 recipes
- org.openrewrite.cobol.cleanup.RemoveWithDebuggingMode
- Remove with debugging mode
- Remove debugging mode from SOURCE-COMPUTER paragraphs.
- org.openrewrite.cobol.search.FindCopybook
- Find copybook usage
- Find all copy statements with the copybook name.
- org.openrewrite.cobol.search.FindIndicators
- Find indicators
- Find matching indicators. Currently, this recipe will not mark indicators on copybook code.
- org.openrewrite.cobol.search.FindReference
- Find matching identifiers in COBOL, copybooks, and JCL
- Finds an identifier by an exact match or regex pattern in COBOL, copybooks, and/or JCL.
- org.openrewrite.cobol.search.FindRelationships
- Find COBOL relationships
- Build a list of relationships for diagramming and exploration.
- org.openrewrite.cobol.search.FindWord
- Find matching words in the source code
- Search for COBOL words based on a search term.
- org.openrewrite.jcl.search.FindWord
- Find matching words in JCL source code
- Search for JCL words based on a search term.
rewrite-core
License: Apache License Version 2.0
29 recipes
- org.openrewrite.AddToGitignore
- Add entries to
.gitignore - Adds entries to the project's
.gitignorefile. If no.gitignorefile exists, one will be created. Existing entries that match will not be duplicated.
- Add entries to
- org.openrewrite.DeleteSourceFiles
- Delete files
- Delete files by source path.
- 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
GitProvenancemarker 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
ParseExceptionResultmarkers - 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.
- Find source files with
- org.openrewrite.FindQuarks
- Find instances of type
Quark Quarksource files are pointers to the existence of a file without capturing any of the contents of the file.
- Find instances of type
- org.openrewrite.FindSourceFiles
- Find files
- Find files by source path. Paths are always interpreted as relative to the repository root.
- 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.RenameFile
- Rename a file
- Rename a file while keeping it in the same directory.
- 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.Singletonas 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 withSingleton.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'sequals()andhashCode()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@Valueannotation on your recipe class, which automatically generates correctequals()andhashCode()implementations based on all fields.
- org.openrewrite.search.FindBuildMetadata
- Find build metadata
- Find source files with matching build metadata.
- org.openrewrite.search.FindCommitters
- Find committers on repositories
- List the committers on a repository.
- org.openrewrite.search.FindParseToPrintInequality
- Find parse to print inequality
- OpenRewrite
Parserimplementations should produceSourceFileobjects whoseprintAll()method should be byte-for-byte equivalent with the original source file. When this isn't true, recipes can still run on theSourceFileand even produce diffs, but the diffs would fail to apply as a patch to the original source file. MostParseruseParser#requirePrintEqualsInputto produce aParseErrorwhen they fail to produce aSourceFilethat 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
SearchResultmarker. If you want to get only the matching file as a search result, useFindSourceFilesinstead.
- 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
Quarkrather than plain text. In such case, use theplainTextMaskoption. 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
FindSourceFilesprecondition to limit which files are changed.
- org.openrewrite.text.CreateTextFile
- Create text file
- Creates a new plain text file.
- 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.Find
- Find text
- Textual search, optionally using Regular Expression (regex) to query.
- org.openrewrite.text.FindAndReplace
- Find and replace
- Textual find and replace, optionally interpreting the search query as a Regular Expression (regex). When operating on source files that are language-specific Lossless Semantic Tree, such as Java or XML, this operation converts the source file to plain text for the rest of the recipe run. So if you are combining this recipe with language-specific recipes in a single recipe run put all the language-specific recipes before this recipe.
- 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
License: Apache License Version 2.0
18 recipes
- org.openrewrite.docker.AddAptGetCleanup
- Add apt-get cleanup
- Adds cleanup commands to apt-get RUN instructions to reduce Docker image size. By default, adds 'rm -rf /var/lib/apt/lists/*' to remove cached package lists.
- org.openrewrite.docker.AddOciLabels
- Add OCI image labels
- Adds standard OCI (Open Container Initiative) image labels to a Dockerfile. These labels provide metadata about the image such as title, version, source, and license information. See https://github.com/opencontainers/image-spec/blob/main/annotations.md for the specification.
- org.openrewrite.docker.AddOrUpdateLabel
- Add Docker LABEL instruction
- Adds or updates a LABEL instruction in a Dockerfile. By default, adds to the final stage only.
- org.openrewrite.docker.AddUserInstruction
- Add
USERinstruction - Adds a
USERinstruction to run the container as a non-root user (CIS Docker Benchmark 4.1). By default, adds to the final stage only and skips if aUSERinstruction already exists.
- Add
- org.openrewrite.docker.ChangeFrom
- Change Docker FROM
- Change the base image in a Dockerfile FROM instruction. Each
*in anold*glob is a positional capture;$Nin the pairednew*substitutes capture N.$0substitutes the full original value;\$is a literal dollar.
- org.openrewrite.docker.CombineRunInstructions
- Combine consecutive
RUNinstructions - Combines consecutive
RUNinstructions into a single instruction to reduce image layers. Only shell formRUNinstructions without flags are combined.
- Combine consecutive
- org.openrewrite.docker.DockerBestPractices
- Apply Docker best practices
- Apply a set of Docker best practices to Dockerfiles. This recipe applies security hardening, build optimization, and maintainability improvements based on CIS Docker Benchmark and industry best practices.
- org.openrewrite.docker.DockerBuildOptimization
- Optimize Docker builds
- Apply build optimization best practices to Dockerfiles. This includes combining RUN instructions to reduce layers and adding cleanup commands to reduce image size.
- org.openrewrite.docker.DockerSecurityBestPractices
- Apply Docker security best practices
- Apply security-focused Docker best practices to Dockerfiles. This includes running as a non-root user (CIS 4.1) and using COPY instead of ADD where appropriate (CIS 4.9).
- org.openrewrite.docker.NormalizeDockerHubImageName
- Normalize Docker Hub image names
- Normalizes Docker Hub image names to their canonical short form by removing redundant registry prefixes like
docker.io/library/orindex.docker.io/.
- org.openrewrite.docker.ReplaceAddWithCopy
- Replace
ADDwithCOPY - Replaces
ADDinstructions withCOPYwhere appropriate.ADDis only kept when the source is a URL or a tar archive that should be auto-extracted. UsingCOPYis preferred for transparency (CIS Docker Benchmark 4.9).
- Replace
- org.openrewrite.docker.UseExecFormEntrypoint
- Use exec form for
ENTRYPOINTandCMD - Converts shell form
ENTRYPOINTandCMDinstructions to exec form (JSON array). Exec form is preferred because it runs the command as PID 1, allowing it to receive Unix signals properly. Shell form wraps commands in/bin/sh -cwhich can cause signal handling issues.
- Use exec form for
- org.openrewrite.docker.search.FindBaseImages
- Find Docker base images
- Find all base images (
FROMinstructions) in Dockerfiles.
- org.openrewrite.docker.search.FindEndOfLifeImages
- Find end-of-life Docker base images
- Identifies Docker base images that have reached end-of-life. Using EOL images poses security risks as they no longer receive security updates. Detected images include EOL versions of Debian, Ubuntu, Alpine, Python, and Node.js.
- org.openrewrite.docker.search.FindExposedPorts
- Find exposed ports
- Find all
EXPOSEinstructions in Dockerfiles and report the exposed ports.
- org.openrewrite.docker.search.FindMissingHealthcheck
- Find missing
HEALTHCHECK - Finds Dockerfiles where the final stage is missing a
HEALTHCHECKinstruction (CIS Docker Benchmark 4.6). Health checks help container orchestrators determine if a container is healthy and ready to receive traffic.
- Find missing
- org.openrewrite.docker.search.FindRootUser
- Find containers running as root
- Finds containers that run as root user (CIS Docker Benchmark 4.1). This includes explicit
USER rootorUSER 0instructions, and optionally containers with noUSERinstruction in the final stage (which default to root).
- org.openrewrite.docker.search.FindUnpinnedBaseImages
- Find unpinned base images
- Finds FROM instructions that use unpinned base images (CIS Docker Benchmark 4.2). Images without an explicit tag default to 'latest', which is not reproducible. Images pinned by digest are considered acceptable.
rewrite-gradle
License: Apache License Version 2.0
73 recipes
- org.openrewrite.gradle.AddDependency
- Add Gradle dependency
- Add a gradle dependency to a
build.gradlefile in the correct configuration based on where it is used.
- org.openrewrite.gradle.AddJUnitPlatformLauncher
- Add JUnit Platform Launcher
- Add the JUnit Platform Launcher to the buildscript dependencies.
- org.openrewrite.gradle.AddPlatformDependency
- Add Gradle platform dependency
- Add a gradle platform dependency to a
build.gradlefile in the correct configuration based on where it is used.
- org.openrewrite.gradle.AddProperty
- Add Gradle property
- Add a property to the
gradle.propertiesfile.
- org.openrewrite.gradle.ChangeDependency
- Change Gradle dependency
- Change a Gradle dependency coordinates. The
newGroupIdornewArtifactIdMUST be different from before.
- org.openrewrite.gradle.ChangeDependencyArtifactId
- Change Gradle dependency artifact
- Change the artifact of a specified Gradle dependency.
- org.openrewrite.gradle.ChangeDependencyClassifier
- Change a Gradle dependency classifier
- Changes classifier of an existing dependency declared in
build.gradlefiles.
- org.openrewrite.gradle.ChangeDependencyConfiguration
- Change a Gradle dependency configuration
- A common example is the need to change
compiletoapi/implementationas part of the move to Gradle 7.x and later.
- org.openrewrite.gradle.ChangeDependencyExtension
- Change a Gradle dependency extension
- Changes extension of an existing dependency declared in
build.gradlefiles.
- org.openrewrite.gradle.ChangeDependencyGroupId
- Change Gradle dependency group
- Change the group of a specified Gradle dependency.
- org.openrewrite.gradle.ChangeExtraProperty
- Change Extra Property
- Gradle's ExtraPropertiesExtension is a commonly used mechanism for setting arbitrary key/value pairs on a project. This recipe will change the value of a property with the given key name if that key can be found. It assumes that the value being set is a String literal. Does not add the value if it does not already exist.
- org.openrewrite.gradle.ChangeManagedDependency
- Change Gradle managed dependency
- Change a Gradle managed dependency coordinates. The
newGroupIdornewArtifactIdMUST be different from before. For now, only Spring Dependency Management Plugin entries are supported and no other forms of managed dependencies (yet).
- org.openrewrite.gradle.ChangeTaskToTasksRegister
- Change Gradle task eager creation to lazy registration
- Changes eager task creation
task exampleName(type: ExampleType)to lazy registrationtasks.register("exampleName", ExampleType). Also supports Kotlin DSL:task<ExampleType>("exampleName")totasks.register<ExampleType>("exampleName").
- org.openrewrite.gradle.DependencyConstraintToRule
- Dependency constraint to resolution rule
- Gradle dependency constraints are useful for managing the versions of transitive dependencies. Some plugins, such as the Spring Dependency Management plugin, do not respect these constraints. This recipe converts constraints into resolution rules, which can achieve similar effects to constraints but are harder for plugins to ignore.
- org.openrewrite.gradle.DependencyUseMapNotation
- Use
Mapnotation for Gradle dependency declarations - In Gradle, dependencies can be expressed as a
Stringlike"groupId:artifactId:version", or equivalently as aMaplikegroup: 'groupId', name: 'artifactId', version: 'version'(groovy) orgroup = "groupId", name = "artifactId", version = "version"(kotlin). This recipe replaces dependencies represented asStringswith an equivalent dependency represented as aMap.
- Use
- org.openrewrite.gradle.DependencyUseStringNotation
- Use
Stringnotation for Gradle dependency declarations - In Gradle, dependencies can be expressed as a
Stringlike"groupId:artifactId:version", or equivalently as aMaplikegroup: 'groupId', name: 'artifactId', version: 'version', or as positional parameters like("groupId", "artifactId", "version"). This recipe replaces dependencies represented asMapsor positional parameters with an equivalent dependency represented as aString, as recommended per the Gradle best practices for dependencies to use a single GAV.
- Use
- org.openrewrite.gradle.EnableDevelocityBuildCache
- Enable Develocity build cache
- Adds
buildCacheconfiguration todevelocitywhere not yet present.
- org.openrewrite.gradle.EnableGradleBuildCache
- Enable Gradle build cache
- Enable the Gradle build cache. By enabling build cache the build outputs are stored externally and fetched from the cache when it is determined that those inputs have no changed, avoiding the expensive work of regenerating them. See the Gradle Build Cache for more information.
- org.openrewrite.gradle.EnableGradleParallelExecution
- Enable Gradle parallel execution
- Most builds consist of more than one project and some of those projects are usually independent of one another. Yet Gradle will only run one task at a time by default, regardless of the project structure. By using the
--parallelswitch, you can force Gradle to execute tasks in parallel as long as those tasks are in different projects. See the Gradle performance documentation for more information.
- org.openrewrite.gradle.GradleBestPractices
- Apply Gradle best practices
- Apply a set of Gradle best practices to the build files, for more efficient and idiomatic builds.
- org.openrewrite.gradle.MigrateDependenciesToVersionCatalog
- Migrate Gradle project dependencies to version catalog
- Migrates Gradle project dependencies to use the version catalog feature. Supports migrating dependency declarations of various forms: *
Stringnotation:"group:artifact:version"*Mapnotation:group: 'group', name: 'artifact', version: 'version'* Property references:"group:artifact:$version"or"group:artifact:$\{version\}"The recipe will: * Create agradle/libs.versions.tomlfile with version declarations * Replace dependency declarations with catalog references (e.g.,libs.springCore) * Migrate version properties fromgradle.propertiesto the version catalog * Preserve project dependencies unchanged Note: If a version catalog already exists, the recipe will not modify it.
- org.openrewrite.gradle.MigrateToGradle5
- Migrate to Gradle 5 from Gradle 4
- Migrate to version 5.x. See the Gradle upgrade guide from version 4.x to 5.0 for more information.
- org.openrewrite.gradle.MigrateToGradle6
- Migrate to Gradle 6 from Gradle 5
- Migrate to version 6.x. See the Gradle upgrade guide from version 5.x to 6.0 for more information.
- org.openrewrite.gradle.MigrateToGradle7
- Migrate to Gradle 7 from Gradle 6
- Migrate to version 7.x. See the Gradle upgrade guide from version 6.x to 7.0 for more information.
- org.openrewrite.gradle.MigrateToGradle8
- Migrate to Gradle 8 from Gradle 7
- Migrate to version 8.x. See the Gradle upgrade guide from version 7.x to 8.0 and version 8.x to latest for more information.
- org.openrewrite.gradle.MigrateToGradle9
- Migrate to Gradle 9 from Gradle 8
- Migrate to version 9.x. See the Gradle upgrade guide from version 8.x to 9.0 for more information.
- org.openrewrite.gradle.RemoveDependency
- Remove a Gradle dependency
- Removes a single dependency from the dependencies section of the
build.gradle.
- org.openrewrite.gradle.RemoveEnableFeaturePreview
- Remove an enabled Gradle preview feature
- Remove an enabled Gradle preview feature from
settings.gradle.
- org.openrewrite.gradle.RemoveExtension
- Remove build extension by name
- Remove a Gradle build extension from
settings.gradle(.kts)orbuild.gradle(.kts)files.
- org.openrewrite.gradle.RemoveRedundantDependencyVersions
- Remove redundant explicit dependencies and versions
- Remove explicitly-specified dependency versions that are managed by a Gradle
platform,enforcedPlatformor theio.spring.dependency-managementplugin. Also removes redundant direct dependencies and dependency constraints that are already satisfied by transitive dependencies.
- org.openrewrite.gradle.RemoveRedundantSecurityResolutionRules
- Remove redundant security resolution rules
- Remove
resolutionStrategy.eachDependencyrules that pin dependencies to versions that are already being managed by a platform/BOM to equal or newer versions. Only removes rules that have a security advisory identifier (CVE or GHSA) in thebecauseclause, unless a custom pattern is specified.
- org.openrewrite.gradle.RemoveRepository
- Remove repository
- Removes a repository from Gradle build scripts. Named repositories include "jcenter", "mavenCentral", "mavenLocal", and "google".
- org.openrewrite.gradle.SortDependencies
- Sort Gradle dependencies
- Sort dependencies in
build.gradleandbuild.gradle.ktsfiles. Dependencies are sorted alphabetically by configuration name (e.g.api,implementation), then by groupId, then by artifactId.
- org.openrewrite.gradle.SyncGradleExtPropertiesWithBom
- Sync Gradle ext properties with BOM
- Downloads a BOM and compares its properties against Gradle ext properties. When the BOM defines a higher version for a property, the ext property is updated to match (or removed if
removeRedundantOverridesis enabled).
- org.openrewrite.gradle.UpdateGradleWrapper
- Update Gradle wrapper
- Update the version of Gradle used in an existing Gradle wrapper. Queries
downloads.gradle.orgto determine the available releases, but prefers the artifact repository URL which already exists within the wrapper properties file. If your artifact repository does not contain the same Gradle distributions asdownloads.gradle.org, then the recipe may suggest a version which is not available in your artifact repository.
- org.openrewrite.gradle.UpdateJavaCompatibility
- Update Gradle project Java compatibility
- Find and updates the Java compatibility for the Gradle project.
- org.openrewrite.gradle.UpgradeDependencyVersion
- Upgrade Gradle dependency versions
- Upgrade the version of a dependency in a build.gradle file. Supports updating dependency declarations of various forms: *
Stringnotation:"group:artifact:version"*Mapnotation:group: 'group', name: 'artifact', version: 'version'Can update version numbers which are defined earlier in the same file in variable declarations.
- org.openrewrite.gradle.UpgradeTransitiveDependencyVersion
- Upgrade transitive Gradle dependencies
- Upgrades the version of a transitive dependency in a Gradle build file. There are many ways to do this in Gradle, so the mechanism for upgrading a transitive dependency must be considered carefully depending on your style of dependency management.
- org.openrewrite.gradle.UseAssignmentForPropertySyntax
- Use
=assignment syntax for well-known Gradle properties - Converts deprecated Groovy DSL property assignment syntax from space/method-call form (e.g.,
description 'text'ordescription('text')) to assignment form (description = 'text') for well-known Gradle project and task properties. See the Gradle 8.14 upgrade guide for more information.
- Use
- org.openrewrite.gradle.UsePropertyAssignmentSyntax
- Use
=assignment syntax for Gradle properties - Converts deprecated Groovy DSL property assignment syntax from space/method-call form (e.g.,
description 'text'ordescription('text')) to assignment form (description = 'text'). Addresses Gradle 8.14 deprecation: "Properties should be assigned using the 'propName = value' syntax.".
- Use
- org.openrewrite.gradle.gradle8.JacocoReportDeprecations
- Replace Gradle 8 introduced deprecations in JaCoCo report task
- Set the
enabledtorequiredand thedestinationtooutputLocationfor Reports deprecations that were removed in gradle 8. See the gradle docs on this topic.
- org.openrewrite.gradle.gradle9.RewriteSpreadAllInConfigurationsBlock
- Replace spread-
all*calls inconfigurationsblocks withconfigurations.all \{ \} - Gradle 9 throws
Cannot mutate the dependencies of configuration ':all' after the configuration was resolved.when aconfigurations \{ \}closure uses Groovy's spread-dot formall*.<method>(args). Rewrite each such call to the closure formconfigurations.all \{ <method>(args) \}, which preserves eager-allsemantics but is accepted by Gradle 9. Only applied when every statement in theconfigurations \{ \}block uses the spread form; mixed blocks are left untouched for manual review.
- Replace spread-
- org.openrewrite.gradle.gradle9.UseJavaExtensionBlock
- Move
sourceCompatibilityandtargetCompatibilityinto thejava \{ \}extension block - Gradle 9 removed the
JavaPluginConvention(deprecated in 8.2). Top-levelsourceCompatibilityandtargetCompatibilityassignments in a Groovy build script previously delegated to that convention object and stop working in Gradle 9. Move them into thejava \{ \}extension block, normalizing values toJavaVersion.VERSION_<n>and adding the missing counterpart so both properties are set explicitly. See the Gradle upgrade guide for more information.
- Move
- org.openrewrite.gradle.gradle9.UseMainClassProperty
- Use
mainClassinstead ofmainforJavaExectasks - The
mainproperty onJavaExectasks was deprecated in Gradle 7.1 and removed in Gradle 9.0. Use themainClassproperty instead. See the Gradle upgrade guide for more information.
- Use
- org.openrewrite.gradle.gradle9.UseMainClassPropertyForApplication
- Use
application \{ mainClass \}instead ofmainClassName - The
mainClassNameproperty on theapplicationextension was deprecated in Gradle 6.4 and removed in Gradle 9.0. Useapplication \{ mainClass = ... \}instead. Top-levelmainClassNameassignments are wrapped in anapplicationblock. See the Gradle upgrade guide for more information.
- Use
- org.openrewrite.gradle.gradle9.UseVersionClosure
- Use
version \{ \}closure instead ofversion = \{ \}assignment - Converts
version = \{ ... \}assignment syntax toversion \{ ... \}closure call syntax in Gradle dependency declarations. The assignment form is not valid Gradle DSL; the closure form invokes the version spec method directly.
- Use
- org.openrewrite.gradle.plugins.AddBuildPlugin
- Add Gradle plugin
- Add a build plugin to a Gradle build file's
pluginsblock.
- org.openrewrite.gradle.plugins.AddDevelocityGradlePlugin
- Add the Develocity Gradle plugin
- Add the Develocity Gradle plugin to settings.gradle files.
- org.openrewrite.gradle.plugins.AddSettingsPlugin
- Add Gradle settings plugin
- Add plugin to Gradle settings file
pluginsblock by id.
- org.openrewrite.gradle.plugins.AddSettingsPluginRepository
- Add a Gradle settings repository
- Add a Gradle settings repository to
settings.gradle(.kts).
- org.openrewrite.gradle.plugins.ChangePlugin
- Change a Gradle plugin
- Changes the selected Gradle plugin to the new plugin.
- org.openrewrite.gradle.plugins.ChangePluginVersion
- Change a Gradle plugin version by id
- Change a Gradle plugin by id to a later version.
- org.openrewrite.gradle.plugins.MigrateGradleEnterpriseToDevelocity
- Migrate from Gradle Enterprise to Develocity
- Migrate from the Gradle Enterprise Gradle plugin to the Develocity Gradle plugin.
- org.openrewrite.gradle.plugins.RemoveBuildPlugin
- Remove Gradle plugin
- Remove plugin from Gradle
pluginsblock by its id. Does not remove plugins from thebuildscriptblock.
- org.openrewrite.gradle.plugins.RemoveDevelocity
- Remove Develocity
- Remove the Develocity plugin and configuration from the Gradle build and settings files.
- org.openrewrite.gradle.plugins.RemoveDevelocityConfiguration
- Remove Develocity configuration
- Remove the Develocity Gradle plugin and associated configuration.
- org.openrewrite.gradle.plugins.RemoveSettingsPlugin
- Remove Gradle settings plugin
- Remove plugin from Gradle settings file
pluginsblock by id.
- org.openrewrite.gradle.plugins.UpgradePluginVersion
- Update a Gradle plugin by id
- Update a Gradle plugin by id to a later version defined by the plugins DSL. To upgrade a plugin dependency defined by
buildscript.dependencies, use theUpgradeDependencyVersionrecipe instead.
- org.openrewrite.gradle.search.DependencyInsight
- Gradle dependency insight
- Find direct and transitive dependencies matching a group, artifact, resolved version, and optionally a configuration name. Results include dependencies that either directly match or transitively include a matching dependency.
- org.openrewrite.gradle.search.DoesNotIncludeDependency
- Does not include Gradle dependency
- A precondition which returns false if visiting a Gradle file 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.gradle.search.EffectiveGradlePluginRepositories
- List effective Gradle plugin repositories
- Lists the Gradle plugin repositories that would be used for plugin resolution, in order of precedence. This includes Maven repositories defined in the settings.gradle pluginManagement section and build.gradle buildscript repositories as determined when the LST was produced.
- org.openrewrite.gradle.search.EffectiveGradleRepositories
- List effective Gradle project repositories
- Lists the Gradle project repositories that would be used for dependency resolution, in order of precedence. This includes Maven repositories defined in the Gradle build files and settings as determined when the LST was produced.
- org.openrewrite.gradle.search.FindDependency
- Find Gradle dependency
- Finds dependencies declared in gradle build files. Each match is also recorded as a row in the
DependenciesDeclareddata table. See the reference on Gradle configurations or the diagram below for a description of what configuration to use. A project's compile and runtime classpath is based on these configurations. <img alt="Gradle compile classpath" src="https://docs.gradle.org/current/userguide/img/java-library-ignore-deprecated-main.png" width="200px"/> A project's test classpath is based on these configurations. <img alt="Gradle test classpath" src="https://docs.gradle.org/current/userguide/img/java-library-ignore-deprecated-test.png" width="200px"/>.
- org.openrewrite.gradle.search.FindDependencyHandler
- Find Gradle
dependenciesblocks - Find the dependency handler containing any number of dependency definitions.
- Find Gradle
- org.openrewrite.gradle.search.FindGradleProject
- Find Gradle projects
- Gradle projects are those with
build.gradleorbuild.gradle.ktsfiles.
- org.openrewrite.gradle.search.FindGradleWrapper
- Find Gradle wrappers
- Find Gradle wrappers.
- org.openrewrite.gradle.search.FindJVMTestSuites
- Find Gradle JVMTestSuite plugin configuration
- Find Gradle JVMTestSuite plugin configurations and produce a data table.
- org.openrewrite.gradle.search.FindPlugins
- Find Gradle plugin
- Find a Gradle plugin by id and/or class name. For best results both should be specified, as one cannot automatically be used to infer the other.
- org.openrewrite.gradle.search.FindRepository
- Find Gradle repository
- Find a Gradle repository by url.
- org.openrewrite.gradle.search.FindRepositoryOrder
- Gradle repository order
- Determine the order in which dependencies will be resolved for each
build.gradlebased on its defined repositories as determined when the LST was produced.
- org.openrewrite.gradle.search.ModuleHasDependency
- Module has dependency
- Searches for Gradle Projects (modules) that have a dependency matching the specified id or implementing class. Places a
SearchResultmarker on all sources within a project 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 that use the dependency, use theFindDependencyrecipe instead.
- org.openrewrite.gradle.search.ModuleHasPlugin
- Module has plugin
- Searches for Gradle Projects (modules) that have a plugin matching the specified id or implementing class. Places a
SearchResultmarker on all sources within a project 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 dependency management plugin, limiting unnecessary upgrading. If the search result you want is instead just the build.gradle(.kts) file applying the plugin, use theFindPluginsrecipe instead.
- org.openrewrite.gradle.security.UseHttpsForRepositories
- Use HTTPS for repositories
- Use HTTPS for repository URLs.
rewrite-groovy
License: Apache License Version 2.0
4 recipes
- org.openrewrite.groovy.format.AutoFormat
- Format Groovy code
- Format Groovy code using a standard comprehensive set of Groovy formatting recipes.
- org.openrewrite.groovy.format.GStringCurlyBraces
- Groovy GString curly braces
- In Groovy GStrings, curly braces are optional for single variable expressions. This recipe adds them, so that the expression is always surrounded by curly braces.
- org.openrewrite.groovy.format.OmitParenthesesForLastArgumentLambda
- Move a closure which is the last argument of a method invocation out of parentheses
- Groovy allows a shorthand syntax that allows a closure to be placed outside of parentheses.
- org.openrewrite.groovy.format.OmitParenthesesFormat
- Stylize Groovy code to omit parentheses
- Omit parentheses for last argument lambdas in Groovy code.
rewrite-hcl
License: Apache License Version 2.0
11 recipes
- org.openrewrite.hcl.DeleteContent
- Delete content
- Delete HCL content by path.
- org.openrewrite.hcl.MoveContentToFile
- Move content to another file
- Move content to another HCL file, deleting it in the original file.
- org.openrewrite.hcl.ReplaceLegacyAttributeIndexSyntax
- Replace legacy attribute index syntax
- Replace legacy attribute index syntax (
.0) with the new syntax ([0]).
- org.openrewrite.hcl.format.AutoFormat
- Format HCL code
- Format HCL code using a standard comprehensive set of HCL formatting recipes.
- org.openrewrite.hcl.format.BlankLines
- Blank lines
- Add and/or remove blank lines.
- org.openrewrite.hcl.format.NormalizeFormat
- Normalize format
- Move whitespace to the outermost LST element possible.
- org.openrewrite.hcl.format.RemoveTrailingWhitespace
- Remove trailing whitespace
- Remove any extra trailing whitespace from the end of each line.
- org.openrewrite.hcl.format.Spaces
- Spaces
- Format whitespace in HCL code.
- org.openrewrite.hcl.format.TabsAndIndents
- Tabs and indents
- Format tabs and indents in HCL code.
- org.openrewrite.hcl.search.FindAndReplaceLiteral
- Find and replace literals in HCL files
- Find and replace literal values in HCL files. This recipe parses the source files on which it runs as HCL, meaning you can execute HCL language-specific recipes before and after this recipe in a single recipe run.
- org.openrewrite.hcl.search.FindContent
- Find content
- Find HCL content by path.
rewrite-java
License: Apache License Version 2.0
101 recipes
- org.openrewrite.java.AddApache2LicenseHeader
- Add ASLv2 license header
- Adds the Apache Software License Version 2.0 to Java source files which are missing a license header.
- org.openrewrite.java.AddCommentToImport
- Add comment to import statement
- Add a comment to an import statement in a Java source file.
- org.openrewrite.java.AddCommentToMethod
- Add comment to method declarations
- Add a comment to method declarations in a Java source file.
- org.openrewrite.java.AddCommentToMethodInvocations
- Add comment to method invocations
- Add a comment to method invocations in a Java source file.
- org.openrewrite.java.AddLicenseHeader
- Add license header
- Adds license headers to Java source files when missing. Does not override existing license headers.
- org.openrewrite.java.AddLiteralMethodArgument
- Add a literal method argument
- Add a literal
Stringor primitive argument to method invocations.
- org.openrewrite.java.AddMethodParameter
- Add method parameter to a method declaration
- Adds a new method parameter to an existing method declaration.
- org.openrewrite.java.AddNullMethodArgument
- Add a
nullmethod argument - Add a
nullargument to method invocations.
- Add a
- org.openrewrite.java.AddOrUpdateAnnotationAttribute
- Add or update annotation attribute
- Some annotations accept arguments. This recipe sets an existing argument to the specified value, or adds the argument if it is not already set.
- org.openrewrite.java.ChangeAnnotationAttributeName
- Change annotation attribute name
- Some annotations accept arguments. This recipe renames an existing attribute.
- org.openrewrite.java.ChangeMethodAccessLevel
- Change method access level
- Change the access level (public, protected, private, package private) of a method.
- org.openrewrite.java.ChangeMethodInvocationReturnType
- Change method invocation return type
- Changes the return type of a method invocation.
- org.openrewrite.java.ChangeMethodName
- Change method name
- Rename a method.
- org.openrewrite.java.ChangeMethodTargetToStatic
- Change method target to static
- Change method invocations to static method calls.
- org.openrewrite.java.ChangeMethodTargetToVariable
- Change method target to variable
- Change method invocations to method calls on a variable.
- org.openrewrite.java.ChangePackage
- Rename package name
- A recipe that will rename a package name in package statements, imports, and fully-qualified types.
- org.openrewrite.java.ChangePackageInStringLiteral
- Rename package name in String literals
- A recipe that will rename a package name in String literals.
- org.openrewrite.java.ChangeStaticFieldToMethod
- Change static field access to static method access
- Migrate accesses to a static field to invocations of a static method.
- org.openrewrite.java.ChangeType
- Change type
- Change a given type to another.
- org.openrewrite.java.ChangeTypeInStringLiteral
- Change type in String literals
- Change a given type to another when used in a String literal.
- org.openrewrite.java.CreateEmptyJavaClass
- Create Java class
- Create a new, empty Java class.
- org.openrewrite.java.DeleteMethodArgument
- Delete method argument
- Delete an argument from method invocations.
- org.openrewrite.java.InlineMethodCalls
- Inline method calls
- Inline method calls using a template replacement pattern. Supports both method invocations and constructor calls, with optional imports.
- org.openrewrite.java.NoStaticImport
- Remove static import
- Removes static imports and replaces them with qualified references. For example,
emptyList()becomesCollections.emptyList().
- org.openrewrite.java.OrderImports
- Order imports
- Groups and orders import statements. If a style has been defined, this recipe will order the imports according to that style. If no style is detected, this recipe will default to ordering imports in the same way that IntelliJ IDEA does.
- org.openrewrite.java.RandomizeId
- Randomize tree IDs
- Scramble the IDs. This was intended as a utility to test en masse different techniques for UUID generation and compare their relative performance outside a microbenchmark.
- org.openrewrite.java.RecipeMarkupDemonstration
- Demonstrate rendering of
Markupmarkers - Tooling may decide to elide or display differently markup of different levels.
- Demonstrate rendering of
- org.openrewrite.java.RemoveAnnotation
- Remove annotation
- Remove matching annotations wherever they occur.
- org.openrewrite.java.RemoveAnnotationAttribute
- Remove annotation attribute
- Some annotations accept arguments. This recipe removes an existing attribute.
- org.openrewrite.java.RemoveImplements
- Remove interface implementations
- Removes
implementsclauses from classes implementing the specified interface. Removes@Overridesannotations from methods which no longer override anything.
- org.openrewrite.java.RemoveMethodInvocations
- Remove method invocations
- Remove method invocations if syntactically safe.
- org.openrewrite.java.RemoveMethodThrows
- Remove elements from a method declaration
throwsclause - Remove specific, or all exceptions from a method declaration
throwsclause.
- Remove elements from a method declaration
- org.openrewrite.java.RemoveObjectsIsNull
- Transform calls to
Objects.isNull(..)andObjects.nonNull(..) - Replace calls to
Objects.isNull(..)andObjects.nonNull(..)with a simple null check. Using these methods outside of stream predicates is not idiomatic.
- Transform calls to
- org.openrewrite.java.RemoveUnusedImports
- Remove unused imports
- Remove imports for types that are not referenced. As a precaution against incorrect changes no imports will be removed from any source where unknown types are referenced.
- org.openrewrite.java.ReorderMethodArguments
- Reorder method arguments
- Reorder method arguments into the specified order.
- org.openrewrite.java.ReplaceAnnotation
- Replace annotation
- Replace an Annotation with another one if the annotation pattern matches. Only fixed parameters can be set in the replacement.
- org.openrewrite.java.ReplaceConstant
- Replace constant with literal value
- Replace a named constant with a literal value when you wish to remove the old constant. A
Stringliteral must include escaped quotes.
- org.openrewrite.java.ReplaceConstantWithAnotherConstant
- Replace constant with another constant
- Replace a constant with another constant, adding/removing import on class if needed.
- org.openrewrite.java.ReplaceMethodInvocationWithConstant
- Replace method invocation with constant
- Replace all method invocations matching the method pattern with the specified constant.
- org.openrewrite.java.ReplaceStringLiteralValue
- Replace
Stringliteral - Replace the value of a complete
Stringliteral.
- Replace
- org.openrewrite.java.ReplaceStringLiteralWithConstant
- Replace String literal with constant
- Replace String literal with constant, adding import on class if needed.
- org.openrewrite.java.ShortenFullyQualifiedTypeReferences
- Add imports for fully qualified references to types
- Any fully qualified references to Java types will be replaced with corresponding simple names and import statements, provided that it doesn't result in any conflicts with other imports or types declared in the local compilation unit.
- org.openrewrite.java.SimplifyMethodChain
- Simplify a call chain
- Simplify
a.b().c()toa.d().
- org.openrewrite.java.SimplifySingleElementAnnotation
- Simplify single-element annotation
- This recipe will remove the attribute
valueon single-element annotations. According to JLS, a single-element annotation, is a shorthand designed for use with single-element annotation types.
- org.openrewrite.java.UpdateSourcePositions
- Update source positions
- Calculate start position and length for every LST element.
- org.openrewrite.java.UseStaticImport
- Use static import
- Removes unnecessary receiver types from static method invocations. For example,
Collections.emptyList()becomesemptyList().
- org.openrewrite.java.ai.ClassDefinitionLength
- Calculate token length of classes
- Locates class definitions and predicts the number of token in each.
- org.openrewrite.java.ai.MethodDefinitionLength
- Calculate token length of method definitions
- Locates method definitions and predicts the number of token in each.
- org.openrewrite.java.format.AutoFormat
- Format Java code
- Format Java code using a standard comprehensive set of Java formatting recipes.
- org.openrewrite.java.format.BlankLines
- Blank lines
- Add and/or remove blank lines.
- org.openrewrite.java.format.EmptyNewlineAtEndOfFile
- End files with a single newline
- Some tools work better when files end with an empty line.
- org.openrewrite.java.format.MethodParamPad
- Method parameter padding
- Fixes whitespace padding between the identifier of a method definition or method invocation and the left parenthesis of the parameter list. For example, when configured to remove spacing,
someMethodInvocation (x);becomessomeMethodInvocation(x).
- org.openrewrite.java.format.NoWhitespaceAfter
- No whitespace after
- Removes unnecessary whitespace appearing after a token. A linebreak after a token is allowed unless
allowLineBreaksis set tofalse, in which case it will be removed.
- org.openrewrite.java.format.NoWhitespaceBefore
- No whitespace before
- Removes unnecessary whitespace preceding a token. A linebreak before a token will be removed unless
allowLineBreaksis set totrue.
- org.openrewrite.java.format.NormalizeFormat
- Normalize format
- Move whitespace to the outermost LST element possible.
- org.openrewrite.java.format.NormalizeLineBreaks
- Normalize line breaks
- Consistently use either Windows style (CRLF) or Linux style (LF) line breaks. If no
GeneralFormatStyleis specified this will use whichever style of line endings are more common.
- org.openrewrite.java.format.NormalizeTabsOrSpaces
- Normalize to tabs or spaces
- Consistently use either tabs or spaces in indentation.
- org.openrewrite.java.format.PadEmptyForLoopComponents
- Pad empty
forloop components - Fixes padding on empty
forloop iterators and initializers to match Checkstyle policies.
- Pad empty
- org.openrewrite.java.format.RemoveTrailingWhitespace
- Remove trailing whitespace
- Remove any extra trailing whitespace from the end of each line.
- org.openrewrite.java.format.SingleLineComments
- Single line comments begin with a whitespace
- Write
// hiinstead of//hi.
- org.openrewrite.java.format.Spaces
- Spaces
- Format whitespace in Java code.
- org.openrewrite.java.format.TabsAndIndents
- Tabs and indents
- Format tabs and indents in Java code.
- org.openrewrite.java.format.TypecastParenPad
- Typecast parentheses padding
- Fixes whitespace padding between a typecast type identifier and the enclosing left and right parenthesis. For example, when configured to remove spacing,
( int ) 0L;becomes(int) 0L;.
- org.openrewrite.java.format.WrappingAndBraces
- Wrapping and braces
- Format line wraps and braces in Java code.
- org.openrewrite.java.search.ClasspathTypeCounts
- Study the size of the classpath by source set
- Emit one data table row per source set in a project, with the number of types in the source set.
- org.openrewrite.java.search.DoesNotUseType
- Check whether a type is not in use
- Useful as a precondition to skip over compilation units using the argument type.
- org.openrewrite.java.search.FindAnnotations
- Find annotations
- Find all annotations matching the annotation pattern.
- org.openrewrite.java.search.FindClassHierarchy
- Find class hierarchy
- Discovers all class declarations within a project, recording which files they appear in, their superclasses, and interfaces. That information is then recorded in a data table.
- org.openrewrite.java.search.FindComments
- Find within comments and literals
- Find regular expression matches within comments and literals. "Literals" includes string literals, character literals, and numeric literals.
- org.openrewrite.java.search.FindCompileErrors
- Find compile errors
- Compile errors result in a particular LST structure that can be searched for.
- org.openrewrite.java.search.FindDeprecatedClasses
- Find uses of deprecated classes
- Find uses of deprecated classes, optionally ignoring those classes that are inside deprecated scopes.
- org.openrewrite.java.search.FindDeprecatedFields
- Find uses of deprecated fields
- Find uses of deprecated fields in any API.
- org.openrewrite.java.search.FindDeprecatedMethods
- Find uses of deprecated methods
- Find uses of deprecated methods in any API.
- org.openrewrite.java.search.FindDeprecatedUses
- Find uses of deprecated classes, methods, and fields
- Find deprecated uses of methods, fields, and types. Optionally ignore those classes that are inside deprecated scopes.
- org.openrewrite.java.search.FindDistinctMethods
- Find distinct methods in use
- A sample of every distinct method in use in a repository. The code sample in the method calls data table will be a representative use of the method, though there may be many other such uses of the method.
- org.openrewrite.java.search.FindEmptyClasses
- Find empty classes
- Find empty classes without annotations that do not implement an interface or extend a class.
- org.openrewrite.java.search.FindEmptyMethods
- Find methods with empty bodies
- Find methods with empty bodies and single public no arg constructors.
- org.openrewrite.java.search.FindFields
- Find fields
- Find uses of a field.
- org.openrewrite.java.search.FindFieldsOfType
- Find fields of type
- Finds declared fields matching a particular class name.
- org.openrewrite.java.search.FindImplementations
- Find implementing classes
- Find class declarations which implement the specified type. If the specified type is a class, its subclasses will be matched. If the specified type is an interface, classes which implement it will be matched.
- org.openrewrite.java.search.FindImports
- Find source files with imports
- Locates source files that have imports matching the given type pattern, regardless of whether that import is used in the code.
- org.openrewrite.java.search.FindLiterals
- Find literals
- Find literals matching a pattern.
- org.openrewrite.java.search.FindMethodDeclaration
- Find method declaration
- Locates the declaration of a method.
- org.openrewrite.java.search.FindMethods
- Find method usages
- Find method calls by pattern.
- org.openrewrite.java.search.FindMissingTypes
- Find missing type information on Java LSTs
- This is a diagnostic recipe to highlight where LSTs are missing type attribution information.
- org.openrewrite.java.search.FindRepeatableAnnotations
- Find uses of
@Repeatableannotations - Java 8 introduced the concept of
@Repeatableannotations.
- Find uses of
- org.openrewrite.java.search.FindSecrets
- Find plain text secrets
- Find secrets stored in plain text in code.
- org.openrewrite.java.search.FindSymbols
- Find symbols
- Lists all symbols (classes, methods, fields, etc.) declared in the codebase. Results are emitted into a data table with symbol kind, name, parent type, signature, and visibility.
- org.openrewrite.java.search.FindTypeMappings
- Find type mappings
- Study the frequency of
Jtypes and theirJavaTypetype attribution.
- org.openrewrite.java.search.FindTypes
- Find types
- Find type references by name.
- org.openrewrite.java.search.HasBuildToolVersion
- Find files with a particular build tool version
- Finds Java source files built with a particular build tool. This is useful especially as a precondition for other recipes.
- org.openrewrite.java.search.HasJavaVersion
- Find files compiled at a specific Java version
- Finds Java source files matching a particular language level. This is useful especially as a precondition for other recipes.
- org.openrewrite.java.search.HasMethod
- Find files that have at least one use of a method
- Marks files that have at least one occurrence of a method matching a pattern.
- org.openrewrite.java.search.HasMinimumJavaVersion
- Find the oldest Java version in use
- The oldest Java version in use is the lowest Java 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 Java 8, but a test source set uses Java 17. In this case, the oldest Java version in use is Java 8.
- org.openrewrite.java.search.HasSourceSet
- Find files in a source set
- Source sets are a way to organize your source code into logical groups. For example, Java projects commonly have a
mainsource set for application code and atestsource set for test code. This recipe will find all files in a given source set.
- org.openrewrite.java.search.HasType
- Find files that have at least one use of a type
- Marks files that have at least one occurrence of a type, even if the name of that type doesn't appear in the source code.
- org.openrewrite.java.search.IsLikelyNotTest
- Find files that are likely not tests
- Sources that do not contain indicators of being, or being exclusively for the use in tests. This recipe is simply a negation of the
org.openrewrite.java.search.IsLikelyTestrecipe.
- org.openrewrite.java.search.IsLikelyTest
- Find sources that are likely tests
- Sources that contain indicators of being, or being exclusively for the use in tests. This recipe is not exhaustive, but is intended to be a good starting point for finding test sources. Looks at the source set name, and types in use; for example looks for uses of JUnit & TestNG annotations/assertions.
- org.openrewrite.java.search.ModuleContainsFile
- Module contains file
- Intended to be used primarily as a precondition for other recipes, this recipe checks if a module contains a specific file or files matching a pattern. Only files belonging to modules containing the specified file are marked with a
SearchResultmarker. This is more specific thanRepositoryContainsFilewhich marks all files in the repository if any file matches.
- org.openrewrite.java.search.ModuleUsesType
- Module uses type
- Intended to be used primarily as a precondition for other recipes, this recipe checks if a module uses a specified type. Only files belonging to modules that use the specified type are marked with a
SearchResultmarker. This is more specific thanUsesTypewhich only marks the files that directly use the type.
- org.openrewrite.java.search.ResultOfMethodCallIgnored
- Result of method call ignored
- Find locations where the result of the method call is being ignored.
rewrite-javascript
License: Moderne Source Available License
17 recipes
- org.openrewrite.javascript.change-import
- Change import
- Changes an import from one module/member to another, updating all type attributions.
- org.openrewrite.javascript.cleanup.add-parse-int-radix
- Add radix to
parseInt - Adds the radix parameter (base 10) to
parseInt()calls that are missing it, preventing potential parsing issues.
- Add radix to
- org.openrewrite.javascript.cleanup.async-callback-in-sync-array-method
- Detect async callbacks in synchronous array methods
- Detects async callbacks passed to array methods like .some(), .every(), .filter() which don't await promises. This is a common bug where Promise objects are always truthy.
- org.openrewrite.javascript.cleanup.order-imports
- Order imports
- Sort imports by category and module path. Categories: side-effect, namespace, default, named, type. Within each category, imports are sorted alphabetically by module path. Named specifiers within each import are also sorted alphabetically.
- org.openrewrite.javascript.cleanup.prefer-optional-chain
- Prefer optional chaining
- Converts ternary expressions like
foo ? foo.bar : undefinedto use optional chaining syntaxfoo?.bar.
- org.openrewrite.javascript.cleanup.use-object-property-shorthand
- Use object property shorthand
- Simplifies object properties where the property name and value/variable name are the same (e.g.,
\{ x: x \}becomes\{ x \}). Applies to both destructuring patterns and object literals.
- org.openrewrite.javascript.dependencies.add-dependency
- Add npm dependency
- Adds a new dependency to
package.jsonand updates the lock file by running the package manager.
- org.openrewrite.javascript.dependencies.find-dependency
- Find Node.js dependency
- Finds dependencies in a project's
package.json. Can find both direct dependencies and dependencies that transitively include the target package. This recipe is commonly used as a precondition for other recipes.
- org.openrewrite.javascript.dependencies.remove-dependency
- Remove npm dependency
- Removes a dependency from
package.jsonand updates the lock file by running the package manager.
- org.openrewrite.javascript.dependencies.upgrade-dependency-version
- Upgrade npm dependency version
- Upgrades the version of a direct dependency in
package.jsonand updates the lock file by running the package manager. EitherpackageNameorpackagePatternmust be specified.
- org.openrewrite.javascript.dependencies.upgrade-transitive-dependency-version
- Upgrade transitive npm dependency version
- Upgrades the version of a transitive dependency by adding override/resolution entries to
package.jsonand updates the lock file by running the package manager.
- org.openrewrite.javascript.format.auto-format
- Auto-format JavaScript/TypeScript code
- Format JavaScript and TypeScript code using formatting rules auto-detected from the project's existing code style.
- org.openrewrite.javascript.migrate.es6.modernize-octal-escape-sequences
- Modernize octal escape sequences
- Convert old-style octal escape sequences (e.g.,
\0,\123) to modern hex escape sequences (e.g.,\x00,\x53) or Unicode escape sequences (e.g.,\u0000,\u0053).
- org.openrewrite.javascript.migrate.es6.modernize-octal-literals
- Modernize octal literals
- Convert old-style octal literals (e.g.,
0777) to modern ES6 syntax (e.g.,0o777).
- org.openrewrite.javascript.migrate.es6.remove-duplicate-object-keys
- Remove duplicate object keys
- Remove duplicate keys in object literals, keeping only the last occurrence (last-wins semantics).
- org.openrewrite.javascript.migrate.typescript.export-assignment-to-export-default
- Convert
export =toexport default - Converts TypeScript
export =syntax to ES moduleexport defaultsyntax for compatibility with ECMAScript modules.
- Convert
- org.openrewrite.javascript.search.DependencyInsight
- Node.js dependency insight
- Find direct and transitive npm dependencies matching a package name pattern. Results include dependencies that either directly match or transitively include a matching dependency.
rewrite-json
License: Apache License Version 2.0
10 recipes
- org.openrewrite.json.AddKeyValue
- Add value to JSON Object
- Adds a
valueat the specifiedkeyPathwith the specifiedkey, if the key doesn't already exist.
- org.openrewrite.json.ChangeKey
- Change key
- Change a JSON mapping entry key, while leaving the value intact.
- org.openrewrite.json.ChangeValue
- Change value
- Change a JSON mapping entry value leaving the key intact.
- org.openrewrite.json.CopyValue
- Copy JSON value
- Copies a JSON value from one key to another. The existing key/value pair remains unaffected by this change. Attempts to create the new key if it does not exist.
- org.openrewrite.json.CreateJsonFile
- Create JSON file
- Create a new JSON file.
- org.openrewrite.json.DeleteKey
- Delete key
- Delete a JSON mapping entry key.
- org.openrewrite.json.format.AutoFormat
- Format JSON
- Format JSON code using a standard comprehensive set of JSON formatting recipes.
- org.openrewrite.json.format.Indents
- JSON indent
- Format tabs and indents in JSON.
- org.openrewrite.json.format.WrappingAndBraces
- JSON new lines
- Split members into separate lines in JSON.
- org.openrewrite.json.search.FindKey
- Find JSON object members
- Find JSON object members by JsonPath expression.
rewrite-kotlin
License: Apache License Version 2.0
11 recipes
- org.openrewrite.kotlin.FindKotlinSources
- Find Kotlin sources and collect data metrics
- Use data table to collect source files types and counts of files with extensions
.kt.
- org.openrewrite.kotlin.OrderImports
- Order Kotlin imports
- Groups and orders import statements. If a style has been defined, this recipe will order the imports according to that style. If no style is detected, this recipe will default to ordering imports in the same way that IntelliJ IDEA does.
- org.openrewrite.kotlin.RenameTypeAlias
- Rename type alias
- Change the name of a given type alias.
- org.openrewrite.kotlin.cleanup.EqualsMethodUsage
- Structural equality tests should use
==or!= - In Kotlin,
==means structural equality and!=structural inequality and both map to the left-side term’sequals()function. It is, therefore, redundant to callequals()as a function. Also,==and!=are more general thanequals()and!equals()because it allows either of both operands to benull. Developers usingequals()instead of==or!=is often the result of adapting styles from other languages like Java, where==means reference equality and!=means reference inequality. The==and!=operators are a more concise and elegant way to test structural equality than calling a function.
- Structural equality tests should use
- org.openrewrite.kotlin.cleanup.ImplicitParameterInLambda
itshouldn't be used as a lambda parameter nameitis a special identifier that allows you to refer to the current parameter being passed to a lambda expression without explicitly naming the parameter. Lambda expressions are a concise way of writing anonymous functions. Many lambda expressions have only one parameter, when this is true the compiler can determine the parameter type by context. Thus when using it with single parameter lambda expressions, you do not need to declare the type.
- org.openrewrite.kotlin.cleanup.RemoveLambdaArgumentParentheses
- Remove method invocation parentheses around single lambda argument
- For example, convert
1.let(\{ it + 1 \})to1.let \{ it + 1 \}.
- org.openrewrite.kotlin.cleanup.RemoveTrailingComma
- Remove trailing comma in Kotlin
- Remove trailing commas in variable, parameter, and class property lists.
- org.openrewrite.kotlin.cleanup.RemoveTrailingSemicolon
- Remove unnecessary trailing semicolon
- Some Java programmers may mistakenly add semicolons at the end when writing Kotlin code, but in reality, they are not necessary.
- org.openrewrite.kotlin.cleanup.ReplaceCharToIntWithCode
- Replace
Char#toInt()withChar#code - Replace the usage of the deprecated
Char#toInt()withChar#code. Please ensure that your Kotlin version is 1.5 or later to support theChar#codeproperty. Note that the current implementation does not perform a Kotlin version check.
- Replace
- org.openrewrite.kotlin.cleanup.UnnecessaryTypeParentheses
- Remove unnecessary parentheses on Kotlin types
- In Kotlin, it's possible to add redundant nested parentheses in type definitions. This recipe is designed to remove those unnecessary parentheses.
- org.openrewrite.kotlin.format.AutoFormat
- Format Kotlin code
- Format Kotlin code using a standard comprehensive set of Kotlin formatting recipes.
rewrite-maven
License: Apache License Version 2.0
90 recipes
- org.openrewrite.maven.AddAnnotationProcessor
- Add an annotation processor to
maven-compiler-plugin - Add an annotation processor path to the
maven-compiler-pluginconfiguration. For modules with an in-reactor parent, adds to the parent'sbuild/pluginManagement/pluginssection. For modules without a parent or with a parent outside the reactor, adds directly tobuild/plugins. Updates the annotation processor version if a newer version is specified.
- Add an annotation processor to
- org.openrewrite.maven.AddCommentToMavenDependency
- Add a comment to a
Mavendependency or plugin - Adds a comment as the first element in a
Mavendependency or plugin.
- Add a comment to a
- org.openrewrite.maven.AddDependency
- Add Maven dependency
- Add a Maven dependency to a
pom.xmlfile in the correct scope based on where it is used.
- org.openrewrite.maven.AddDevelocityMavenExtension
- Add the Develocity Maven extension
- To integrate the Develocity Maven extension into Maven projects, ensure that the
develocity-maven-extensionis added to the.mvn/extensions.xmlfile if not already present. Additionally, configure the extension by adding the.mvn/develocity.xmlconfiguration file.
- org.openrewrite.maven.AddManagedDependency
- Add managed Maven dependency
- Add a managed Maven dependency to a
pom.xmlfile.
- 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.AddPlugin
- Add Maven plugin
- Add the specified Maven plugin to the pom.xml.
- org.openrewrite.maven.AddPluginDependency
- Add Maven plugin dependencies
- Adds the specified dependencies to a Maven plugin. Will not add the plugin if it does not already exist in the pom.
- org.openrewrite.maven.AddProfile
- Add Maven profile
- Add a maven profile to a
pom.xmlfile.
- org.openrewrite.maven.AddProperty
- Add Maven project property
- Add a new property to the Maven project property. Prefers to add the property to the parent if the project has multiple modules.
- 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.BestPractices
- Apache Maven best practices
- Applies best practices to Maven POMs.
- org.openrewrite.maven.ChangeDependencyClassifier
- Change Maven dependency classifier
- Add or alter the classifier of the specified dependency.
- org.openrewrite.maven.ChangeDependencyGroupIdAndArtifactId
- Change Maven dependency
- Change a Maven dependency coordinates. The
newGroupIdornewArtifactIdMUST be different from before. Matching<dependencyManagement>coordinates are also updated if anewVersionorversionPatternis provided. Exclusions that reference the old dependency coordinates are preserved, and a sibling exclusion for the new coordinates is added alongside them.
- org.openrewrite.maven.ChangeDependencyScope
- Change Maven dependency scope
- Add or alter the scope of the specified dependency.
- 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.ChangeManagedDependencyGroupIdAndArtifactId
- Change Maven managed dependency groupId, artifactId and optionally the version
- Change the groupId, artifactId and optionally the version of a specified Maven managed dependency.
- org.openrewrite.maven.ChangePackaging
- Set Maven project packaging
- Sets the packaging type of Maven projects. Either adds the packaging tag if it is missing or changes its context if present.
- org.openrewrite.maven.ChangeParentPom
- Change Maven parent
- Change the parent pom of a Maven pom.xml by matching the existing parent via groupId and artifactId, and updating it to a new groupId, artifactId, version, and optional relativePath. Also updates the project to retain dependency management and properties previously inherited from the old parent that are no longer provided by the new parent. Removes redundant dependency versions already managed by the new parent.
- 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.ChangePluginExecutions
- Change Maven plugin executions
- Apply the specified executions to a Maven plugin. Will not add the plugin if it does not already exist in the pom.
- org.openrewrite.maven.ChangePluginGroupIdAndArtifactId
- Change Maven plugin group and artifact ID
- Change the groupId and/or the artifactId of a specified Maven plugin. Optionally update the plugin version. This recipe does not perform any validation and assumes all values passed are valid.
- 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.ChangePropertyValue
- Change Maven project property value
- Changes the specified Maven project property value leaving the key intact.
- 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.ExcludeDependency
- Exclude Maven dependency
- Exclude specified dependency from any dependency that transitively includes it.
- 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.ModernizeObsoletePoms
- Modernize obsolete Maven poms
- Very old Maven poms are no longer supported by current versions of Maven. This recipe updates poms with
<pomVersion>3</pomVersion>to<modelVersion>4.0.0</modelVersion>of the Maven pom schema. This does not attempt to upgrade old dependencies or plugins and is best regarded as the starting point of a migration rather than an end-point.
- org.openrewrite.maven.OrderPomElements
- Order POM elements
- Order POM elements according to the recommended order.
- org.openrewrite.maven.RemoveDependency
- Remove Maven dependency
- Removes a single dependency from the <dependencies> section of the pom.xml. Does not remove usage of the dependency classes, nor guard against the resulting compilation errors.
- org.openrewrite.maven.RemoveDuplicateDependencies
- Remove duplicate Maven dependencies
- Removes duplicated dependencies in the
<dependencies>and<dependencyManagement>sections of thepom.xml.
- org.openrewrite.maven.RemoveDuplicatePluginDeclarations
- Remove duplicate plugin declarations
- Maven 4 rejects duplicate plugin declarations (same groupId and artifactId) with an error. This recipe removes duplicate plugin declarations, keeping only the first occurrence.
- org.openrewrite.maven.RemoveExclusion
- Remove exclusion
- Remove any matching exclusion from any matching dependency.
- org.openrewrite.maven.RemoveManagedDependency
- Remove Maven managed dependency
- Removes a single managed dependency from the <dependencyManagement><dependencies> section of the pom.xml.
- org.openrewrite.maven.RemoveMavenWrapper
- Remove Maven wrapper
- Remove Maven wrapper files from a project. This includes the
mvnwandmvnw.cmdscripts, and the.mvn/wrapperdirectory.
- org.openrewrite.maven.RemovePlugin
- Remove Maven plugin
- Remove the specified Maven plugin from the POM.
- org.openrewrite.maven.RemovePluginDependency
- Remove Maven plugin dependency
- Removes a dependency from the <dependencies> section of a plugin in the pom.xml.
- org.openrewrite.maven.RemoveProperty
- Remove Maven project property
- Removes the specified Maven project property from the pom.xml.
- org.openrewrite.maven.RemoveRedundantDependencyVersions
- Remove redundant explicit dependency and plugin versions
- Remove explicitly-specified dependency/plugin versions when a parent POM's
dependencyManagement/pluginManagementspecifies the version.
- org.openrewrite.maven.RemoveRedundantProperties
- Remove redundant properties
- Remove properties when a parent POM specifies the same property.
- 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.RenamePropertyKey
- Rename Maven property key
- Rename the specified Maven project property key leaving the value unchanged.
- org.openrewrite.maven.ReplaceDeprecatedLifecyclePhases
- Replace deprecated lifecycle phases
- Maven 4 deprecated all
pre-*andpost-*lifecycle phases in favor of thebefore:andafter:syntax. This recipe updates plugin phase declarations to use the new syntax, includingpre-clean→before:clean,pre-site→before:site,pre-integration-test→before:integration-test, and theirpost-*equivalents.
- org.openrewrite.maven.ReplaceModulesWithSubprojects
- Replace modules with subprojects
- Maven 4 model version 4.1.0 deprecates the
<modules>element in favor of<subprojects>to eliminate confusion with Java's Platform Module System (JPMS). This recipe renames<modules>to<subprojects>and<module>children to<subproject>.
- org.openrewrite.maven.ReplaceRemovedRootDirectoryProperties
- Replace removed root directory properties
- Maven 4 removed support for deprecated root directory properties. This recipe replaces
$\{executionRootDirectory\}with$\{session.rootDirectory\}and$\{multiModuleProjectDirectory\}with$\{project.rootDirectory\}.
- org.openrewrite.maven.ReproducibleBuilds
- Apache Maven reproducible builds
- Configure a Maven project for reproducible builds: pin dependency and plugin versions, set
project.build.outputTimestamp, set explicit UTF-8 source encoding, and upgrade core plugins to versions that honor the output timestamp.
- org.openrewrite.maven.SortDependencies
- Sort dependencies
- Sort dependencies alphabetically by groupId then artifactId. Test-scoped dependencies are sorted after non-test dependencies. Applies to both
<dependencies>and<dependencyManagement>sections.
- org.openrewrite.maven.UpdateMavenProjectPropertyJavaVersion
- Update Maven Java project properties
- The Java version is determined by several project properties, including: *
java.version*jdk.version*javaVersion*jdkVersion*maven.compiler.source*maven.compiler.target*maven.compiler.release*release.versionIf none of these properties are in use and the maven compiler plugin is not otherwise configured, adds themaven.compiler.releaseproperty.
- org.openrewrite.maven.UpdateMavenWrapper
- Update Maven wrapper
- Update the version of Maven used in an existing Maven wrapper.
- org.openrewrite.maven.UpdateScmFromGitOrigin
- Update SCM with Git origin
- Updates or adds the Maven
<scm>tag based on the Git remote origin. By default, only existing Source Control Management (SCM) sections are updated. SetaddIfMissingtotrueto also add missing SCM sections to root POMs (POMs without a parent element).
- org.openrewrite.maven.UpgradeDependencyVersion
- Upgrade Maven dependency version
- Upgrade the version of a dependency by specifying a group and (optionally) an artifact using Node Semver advanced range selectors, allowing more precise control over version updates to patch or minor releases.
- org.openrewrite.maven.UpgradeParentVersion
- Upgrade Maven parent project version
- Set the parent pom version number according to a version selector or to a specific version number.
- org.openrewrite.maven.UpgradePluginVersion
- Upgrade Maven plugin version
- Upgrade the version of a plugin using Node Semver advanced range selectors, allowing more precise control over version updates to patch or minor releases.
- org.openrewrite.maven.UpgradeToModelVersion410
- Upgrade to Maven model version 4.1.0
- Upgrades Maven POMs from model version 4.0.0 to 4.1.0, enabling new Maven 4 features like
<subprojects>,bompackaging, and automatic version inference. This recipe updates the<modelVersion>element,xmlnsnamespace, andxsi:schemaLocationfrom 4.0.0 to 4.1.0.
- 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.UseMavenCompilerPluginReleaseConfiguration
- Use Maven compiler plugin release configuration
- Replaces any explicit
sourceortargetconfiguration (if present) on themaven-compiler-pluginwithrelease, and updates thereleasevalue if needed. WhentestSourceortestTargetdiffer from the main version, introducestestRelease. Will not downgrade the Java version if the current version is higher. Also removes stalemaven.compiler.source,maven.compiler.target,maven.compiler.testSource, andmaven.compiler.testTargetproperties that are no longer referenced.
- org.openrewrite.maven.UseParentInference
- Use Maven 4 parent inference
- Maven 4.1.0 supports automatic parent version inference when using a relative path. This recipe simplifies parent declarations by using the shorthand
<parent/>form when the parent is in the default location (..), removing the explicit<relativePath>,<groupId>,<artifactId>, and<version>elements. Maven automatically infers these values from the parent POM.
- org.openrewrite.maven.cleanup.AddProjectBuildOutputTimestamp
- Add
project.build.outputTimestampfor reproducible builds - Adds the
project.build.outputTimestampproperty, which Maven uses to make build outputs reproducible by stamping archive entries with a fixed timestamp instead of the current time. An existing value is preserved. See Configuring for Reproducible Builds.
- Add
- org.openrewrite.maven.cleanup.DependencyManagementDependencyRequiresVersion
- Dependency management dependencies should have a version
- If they don't have a version, they can't possibly affect dependency resolution anywhere, and can be safely removed.
- org.openrewrite.maven.cleanup.ExplicitDependencyVersion
- Add explicit dependency versions
- Add explicit dependency versions to POMs for reproducibility, as the
LATESTandRELEASEversion keywords are deprecated.
- org.openrewrite.maven.cleanup.ExplicitPluginGroupId
- Add explicit
groupIdto Maven plugins - Add the default
<groupId>org.apache.maven.plugins</groupId>to plugins for clarity.
- Add explicit
- org.openrewrite.maven.cleanup.ExplicitPluginVersion
- Add explicit plugin versions
- Add explicit plugin versions to POMs for reproducibility, as MNG-4173 removes automatic version resolution for POM plugins.
- org.openrewrite.maven.cleanup.NoSystemScopeDependencies
- Dependencies should not have
systemscope - Replaces
<scope>system</scope>with the default compile scope and removes<systemPath>for dependencies that are available in configured repositories.
- Dependencies should not have
- org.openrewrite.maven.cleanup.PrefixlessExpressions
- Drop prefixless expressions in POM
- MNG-7404 drops support for prefixless in POMs. This recipe will add the
project.prefix where missing.
- org.openrewrite.maven.plugin.DependencyPluginGoalResolveSources
- Migrate to
maven-dependency-plugingoalresolve-sources - Migrate from
sourcestoresolve-sourcesfor themaven-dependency-plugin.
- Migrate to
- org.openrewrite.maven.search.DependencyInsight
- Maven dependency insight
- Find direct and transitive dependencies matching a group, artifact, and scope. Results include dependencies that either directly match or transitively include a matching dependency.
- 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.FindDependency
- Find Maven dependency
- Finds first-order dependency uses, i.e. dependencies that are defined directly in a project. Each match is also recorded as a row in the
DependenciesDeclareddata table.
- 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.xmlfiles with aMavenResolutionResultmarker.
- 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.xmlbased on its defined repositories and effectivesettings.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
SearchResultmarker 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 theFindDependencyrecipe 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
SearchResultmarker 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 theFindPluginsrecipe instead.
- org.openrewrite.maven.search.ParentPomInsight
- Maven parent insight
- Find Maven parents matching a
groupIdandartifactId.
- org.openrewrite.maven.security.UseHttpsForRepositories
- Use HTTPS for repositories
- Use HTTPS for repository URLs.
- org.openrewrite.maven.utilities.PrintMavenAsDot
- Print Maven dependency hierarchy in DOT format
- The DOT language format is specified here.
rewrite-properties
License: Apache License Version 2.0
8 recipes
- 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.ChangePropertyKey
- Change property key
- Change a property key leaving the value intact.
- org.openrewrite.properties.ChangePropertyValue
- Change property value
- Change a property value leaving the key intact.
- 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.
- org.openrewrite.properties.DeleteProperty
- Delete property by key
- Deletes key/value pairs from properties files, as well as any comments that immediately precede the key/value pair. Comments separated by two or more newlines from the deleted key/value pair are preserved.
- org.openrewrite.properties.search.FindProperties
- Find property
- Finds occurrences of a property key.
rewrite-python
License: Moderne Proprietary License
15 recipes
- org.openrewrite.python.AddDependency
- Add Python dependency
- Add a dependency to a Python project. Supports
pyproject.toml(with scope/group targeting),requirements.txt, andPipfile. When the matching package manager (uvorpipenv) is available, the corresponding lock file (uv.lockorPipfile.lock) is regenerated. Not safe to use as a precondition: invokes the package manager and publishes per-project state shared with other dependency recipes.
- org.openrewrite.python.AddLiteralMethodArgument
- Add literal method argument
- Add a literal argument to method invocations matching a pattern.
- org.openrewrite.python.ChangeDependency
- Change Python dependency
- Change a dependency to a different package. Supports
pyproject.toml,requirements.txt, andPipfile. Searches all dependency scopes. When the matching package manager (uvorpipenv) is available, the corresponding lock file (uv.lockorPipfile.lock) is regenerated. Not safe to use as a precondition: invokes the package manager and publishes per-project state shared with other dependency recipes.
- org.openrewrite.python.ChangeImport
- Change import
- Change a Python import from one module/name to another, updating all type attributions.
- org.openrewrite.python.ChangeMethodName
- Change method name
- Rename method invocations matching a pattern.
- org.openrewrite.python.ChangePackage
- Change package
- Change package/module references from one name to another.
- org.openrewrite.python.ChangeType
- Change type
- Change a type reference from one fully qualified name to another.
- org.openrewrite.python.DeleteMethodArgument
- Delete method argument
- Remove an argument from method invocations matching a pattern.
- org.openrewrite.python.RemoveDependency
- Remove Python dependency
- Remove a dependency from a Python project. Supports
pyproject.toml(with scope/group targeting),requirements.txt, andPipfile. When the matching package manager (uvorpipenv) is available, the corresponding lock file (uv.lockorPipfile.lock) is regenerated. Not safe to use as a precondition: invokes the package manager and publishes per-project state shared with other dependency recipes.
- org.openrewrite.python.RemovePass
- Remove redundant pass statements
- Remove redundant
passstatements from Python code when there are other executable statements in the block.
- org.openrewrite.python.ReorderMethodArguments
- Reorder method arguments
- Reorder arguments in method invocations matching a pattern.
- org.openrewrite.python.UpgradeDependencyVersion
- Upgrade Python dependency version
- Upgrade the version constraint for a dependency. Supports
pyproject.toml(with scope/group targeting),requirements.txt, andPipfile. When the matching package manager (uvorpipenv) is available, the corresponding lock file (uv.lockorPipfile.lock) is regenerated. Not safe to use as a precondition: invokes the package manager and publishes per-project state shared with other dependency recipes.
- org.openrewrite.python.UpgradeTransitiveDependencyVersion
- Upgrade transitive Python dependency version
- Pin a transitive dependency version using the strategy appropriate for the file type and package manager. For
pyproject.toml: uv uses[tool.uv].constraint-dependencies, PDM uses[tool.pdm.overrides], and other managers add a direct dependency. Forrequirements.txtandPipfile: appends the dependency. Not safe to use as a precondition: invokes the package manager and publishes per-project state shared with other dependency recipes.
- org.openrewrite.python.format.PythonSpaces
- Formats spaces in Python code
- Standardizes spaces in Python code. Currently limited to formatting method arguments.
- org.openrewrite.python.search.DependencyInsight
- Python dependency insight
- Find direct and transitive Python dependencies matching a package name pattern. Results include dependencies that either directly match or transitively include a matching dependency.
rewrite-toml
License: Apache License Version 2.0
10 recipes
- org.openrewrite.toml.ChangeKey
- Change TOML key
- Change a TOML key, while leaving the value intact.
- org.openrewrite.toml.ChangeTableRowValue
- Change TOML table row value
- Change a value in a TOML table row when the identifying property matches the specified matcher.
- org.openrewrite.toml.ChangeValue
- Change TOML value
- Change the value of a TOML key.
- org.openrewrite.toml.CreateTomlFile
- Create TOML file
- Create a new TOML file.
- org.openrewrite.toml.DeleteKey
- Delete TOML key
- Delete a TOML key-value pair.
- org.openrewrite.toml.DeleteTable
- Delete TOML table
- Delete a TOML table.
- org.openrewrite.toml.DeleteTableRow
- Delete TOML table row
- Delete a TOML table row when one of its values matches the specified matcher.
- org.openrewrite.toml.FindKey
- Find TOML keys
- Find TOML keys matching a path expression.
- org.openrewrite.toml.MergeTableRow
- Merge TOML table row
- Merge a TOML row into an array table. If a row with the same identifying property exists, merge the values. Otherwise, insert a new row.
- org.openrewrite.toml.ReplaceTableRow
- Replace TOML table row
- Replace a TOML table row with new content. If a row with the same identifying property exists, replace it entirely.
rewrite-xml
License: Apache License Version 2.0
28 recipes
- org.openrewrite.xml.AddCommentToXmlTag
- Add a comment to an XML tag
- Adds a comment as the first element in an XML tag.
- org.openrewrite.xml.AddOrUpdateChildTag
- Add or update child tag
- Adds or updates a child element below the parent(s) matching the provided
parentXPathexpression. If a child with the same name already exists, it will be replaced by default. Otherwise, a new child will be added. This ensures idempotent behaviour.
- org.openrewrite.xml.AddTagAttribute
- Add new XML attribute for an Element
- Add new XML attribute with value on a specified element.
- org.openrewrite.xml.ChangeNamespaceValue
- Change XML attribute of a specific resource version
- Alters XML Attribute value within specified element of a specific resource versions.
- org.openrewrite.xml.ChangeTagAttribute
- Change XML attribute
- Alters XML attribute value on a specified element.
- org.openrewrite.xml.ChangeTagAttributeKey
- Change XML attribute key
- Change an attributes key on XML elements using an XPath expression.
- org.openrewrite.xml.ChangeTagName
- Change XML tag name
- Alters the name of XML tags matching the provided expression.
- org.openrewrite.xml.ChangeTagValue
- Change XML tag value
- Alters the value of XML tags matching the provided expression. When regex is enabled the replacement happens only for text nodes provided the pattern matches.
- org.openrewrite.xml.CreateXmlFile
- Create XML file
- Create a new XML file.
- org.openrewrite.xml.RemoveEmptyXmlTags
- Remove empty XML Tag
- Removes XML tags that do not have attributes or children, including self closing tags.
- org.openrewrite.xml.RemoveTrailingWhitespace
- Remove trailing whitespace
- Remove any extra trailing whitespace from the end of each line.
- org.openrewrite.xml.RemoveXmlTag
- Remove XML tag
- Removes XML tags matching the provided expression.
- org.openrewrite.xml.XsltTransformation
- XSLT transformation
- Apply the specified XSLT transformation on matching files. Note that there are no format matching guarantees when running this recipe.
- org.openrewrite.xml.format.AutoFormat
- Format XML
- Indents XML using the most common indentation size and tabs or space choice in use in the file.
- org.openrewrite.xml.format.LineBreaks
- Blank lines
- Add line breaks at appropriate places between XML syntax elements.
- org.openrewrite.xml.format.NormalizeFormat
- Normalize format
- Move whitespace to the outermost LST element possible.
- org.openrewrite.xml.format.NormalizeLineBreaks
- Normalize line breaks
- Consistently use either Windows style (CRLF) or Linux style (LF) line breaks. If no
GeneralFormatStyleis specified this will use whichever style of line endings are more common.
- org.openrewrite.xml.format.NormalizeTabsOrSpaces
- Normalize to tabs or spaces
- Consistently use either tabs or spaces in indentation.
- org.openrewrite.xml.format.TabsAndIndents
- Tabs and indents
- Format tabs and indents in XML code.
- org.openrewrite.xml.search.DoesNotUseNamespaceUri
- Find files without Namespace URI
- Find XML root elements that do not have a specific Namespace URI, optionally restricting the search by an XPath expression.
- org.openrewrite.xml.search.FindNamespacePrefix
- Find XML namespace prefixes
- Find XML namespace prefixes, optionally restricting the search by a XPath expression.
- org.openrewrite.xml.search.FindTags
- Find XML tags
- Find XML tags by XPath expression.
- org.openrewrite.xml.search.HasNamespaceUri
- Find XML namespace URIs
- Find XML namespace URIs, optionally restricting the search by a XPath expression.
- org.openrewrite.xml.security.AddOwaspDateBoundSuppressions
- Add date bounds to OWASP suppressions
- Adds an expiration date to all OWASP suppressions in order to ensure that they are periodically reviewed. For use with the OWASP
dependency-checktool. More details: https://jeremylong.github.io/DependencyCheck/general/suppression.html.
- org.openrewrite.xml.security.IsOwaspSuppressionsFile
- Find OWASP vulnerability suppression XML files
- These files are used to suppress false positives in OWASP Dependency Check.
- org.openrewrite.xml.security.RemoveOwaspSuppressions
- Remove out-of-date OWASP suppressions
- Remove all OWASP suppressions with a suppression end date in the past, as these are no longer valid. For use with the OWASP
dependency-checktool. More details on OWASP suppression files can be found here.
- org.openrewrite.xml.security.UpdateOwaspSuppressionDate
- Update OWASP suppression date bounds
- Updates the expiration date for OWASP suppressions having a matching cve tag. For use with the OWASP
dependency-checktool. More details: https://jeremylong.github.io/DependencyCheck/general/suppression.html.
- org.openrewrite.xml.style.AutodetectDebug
- XML style Auto-detection debug
- Runs XML Autodetect and records the results in data tables and search markers. A debugging tool for figuring out why XML documents get styled the way they do.
rewrite-yaml
License: Apache License Version 2.0
18 recipes
- org.openrewrite.yaml.AddCommentToProperty
- Add comment to a YAML property
- Add a comment to a YAML property. The comment will be added on the line before the property.
- org.openrewrite.yaml.AppendToSequence
- Append to sequence
- Append item to YAML sequence.
- org.openrewrite.yaml.ChangeKey
- Change key
- Change a YAML mapping entry key while leaving the value intact.
- org.openrewrite.yaml.ChangePropertyKey
- Change property key
- Change a YAML property key while leaving the value intact. Expects dot notation for nested YAML mappings, similar to how Spring Boot interprets
application.ymlfiles.
- org.openrewrite.yaml.ChangePropertyValue
- Change YAML property
- Change a YAML property. Expects dot notation for nested YAML mappings, similar to how Spring Boot interprets
application.ymlfiles.
- org.openrewrite.yaml.ChangeValue
- Change value
- Change a YAML mapping entry value while leaving the key intact.
- org.openrewrite.yaml.CoalesceProperties
- Coalesce YAML properties
- Simplify nested map hierarchies into their simplest dot separated property form, similar to how Spring Boot interprets
application.ymlfiles.
- org.openrewrite.yaml.CommentOutProperty
- Comment out property
- Comment out a YAML property and add a comment in front.
- org.openrewrite.yaml.CopyValue
- Copy YAML value
- Copies a YAML value from one key to another. The existing key/value pair remains unaffected by this change. Attempts to merge the copied value into the new key if it already exists. By default, attempts to create the new key if it does not exist.
- org.openrewrite.yaml.CreateYamlFile
- Create YAML file
- Create a new YAML file.
- org.openrewrite.yaml.DeleteKey
- Delete key
- Delete a YAML mapping entry key.
- org.openrewrite.yaml.DeleteProperty
- Delete property
- Delete a YAML property. Nested YAML mappings are interpreted as dot separated property names, i.e. as Spring Boot interprets application.yml files like
a.b.c.dora.b.c:d.
- org.openrewrite.yaml.MergeYaml
- Merge YAML snippet
- Merge a YAML snippet with an existing YAML document.
- org.openrewrite.yaml.UnfoldProperties
- Unfold YAML properties
- Transforms dot-separated property keys in YAML files into nested map hierarchies to enhance clarity and readability, or for compatibility with tools expecting structured YAML.
- org.openrewrite.yaml.cleanup.RemoveUnused
- Remove unused YAML
- Remove YAML mappings and sequence keys that have no value.
- org.openrewrite.yaml.format.Indents
- YAML indent
- Format tabs and indents in YAML.
- org.openrewrite.yaml.search.FindKey
- Find YAML entries
- Find YAML entries that match the specified JsonPath expression.
- org.openrewrite.yaml.search.FindProperty
- Find YAML properties
- Find YAML properties that match the specified
propertyKey. Expects dot notation for nested YAML mappings, similar to how Spring Boot interpretsapplication.ymlfiles.