Recipes with data tables

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.table.CollidingSourceFiles: Source files that have the same relative path.

Find deserialization errors: Produces a data table collecting all deserialization errors of serialized LSTs.

  • org.openrewrite.table.DeserializationErrorTable: Table collecting any LST deserialization errors.

Show Git source control metadata: List out the contents of each unique GitProvenance marker in the set of source files. When everything is working correctly, exactly one such marker should be printed as all source files are expected to come from the same repository / branch / commit hash.

  • org.openrewrite.table.DistinctGitProvenance: List out the contents of each unique GitProvenance marker in the set of source files. When everything is working correctly, exactly one such marker should be printed as all source files are expected to come from the same repository / branch / commit hash.

Find LST provenance: Produces a data table showing what versions of OpenRewrite/Moderne tooling was used to produce a given LST.

  • org.openrewrite.table.LstProvenanceTable: Table showing which tools were used to produce LSTs.

Find source files with ParseExceptionResult markers: This recipe explores parse failures after an LST is produced for classifying the types of failures that can occur and prioritizing fixes according to the most common problems.

  • org.openrewrite.table.ParseFailures: A list of files that failed to parse along with stack traces of their failures.

Find files: Find files by source path.

  • org.openrewrite.table.SourcesFiles: Source files that matched some criteria.

List runtime classpath: A diagnostic utility which emits the runtime classpath to a data table.

  • org.openrewrite.table.ClasspathReport: Contains a report of the runtime classpath and any other jars found inside each classpath entry.

Find committers on repositories: List the committers on a repository.

  • org.openrewrite.table.DistinctCommitters: The distinct set of committers per repository.

  • org.openrewrite.table.CommitsByDay: The commit activity by day by committer.

Find parse to print inequality: OpenRewrite Parser implementations should produce SourceFile objects whose printAll() method should be byte-for-byte equivalent with the original source file. When this isn't true, recipes can still run on the SourceFile and even produce diffs, but the diffs would fail to apply as a patch to the original source file. Most Parser use Parser#requirePrintEqualsInput to produce a ParseError when they fail to produce a SourceFile that is print idempotent.

  • org.openrewrite.table.ParseToPrintInequalities: A list of files that parsers produced SourceFile which, when printed, didn't match the original source code.

Find text: Textual search, optionally using Regular Expression (regex) to query.

  • org.openrewrite.table.TextMatches: Lines matching simple text search.

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.maven.table.MavenMetadataFailures: Attempts to resolve maven metadata that failed.

Add the Develocity Gradle plugin: Add the Develocity Gradle plugin to settings.gradle files.

  • org.openrewrite.maven.table.MavenMetadataFailures: Attempts to resolve maven metadata that failed.

Gradle dependency insight: Find direct and transitive dependencies matching a group, artifact, and optionally a configuration name. Results include dependencies that either directly match or transitively include a matching dependency.

  • org.openrewrite.maven.table.DependenciesInUse: Direct and transitive dependencies in use.

Find Gradle wrappers: Find Gradle wrappers.

  • org.openrewrite.gradle.table.GradleWrappersInUse: Gradle wrappers in use.

Add Gradle dependency: Add a gradle dependency to a build.gradle file in the correct configuration based on where it is used.

  • org.openrewrite.maven.table.MavenMetadataFailures: Attempts to resolve maven metadata that failed.

Upgrade Gradle dependency versions: Upgrade the version of a dependency in a build.gradle file. Supports updating dependency declarations of various forms:

  • String notation: "group:artifact:version"

  • Map notation: group: 'group', name: 'artifact', version: 'version' Can update version numbers which are defined earlier in the same file in variable declarations.

    • org.openrewrite.maven.table.MavenMetadataFailures: Attempts to resolve maven metadata that failed.

Calculate token length of classes: Locates class definitions and predicts the number of token in each.

  • org.openrewrite.java.table.TokenCount: The number of tokens from a code snippet

Calculate token length of method definitions: Locates method definitions and predicts the number of token in each.

  • org.openrewrite.java.table.TokenCount: The number of tokens from a code snippet

Find OpenRewrite recipes: This recipe finds all OpenRewrite recipes, primarily to produce a data table that is being used to experiment with fine-tuning a large language model to produce more recipes.

  • org.openrewrite.table.RewriteRecipeSource: This table contains the source code of recipes along with their metadata for use in an experiment fine-tuning large language models to produce more recipes.

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.table.ClassHierarchy: Record the classes

Find uses of deprecated methods: Find uses of deprecated methods in any API.

  • org.openrewrite.java.table.MethodCalls: The text of matching method invocations.

Find method usages: Find method calls by pattern.

  • org.openrewrite.java.table.MethodCalls: The text of matching method invocations.

Find type mappings: Study the frequency of J types and their JavaType type attribution.

  • org.openrewrite.java.table.TypeMappings: The types mapped to J trees.

Add Maven parent: Add a parent pom to a Maven pom.xml. Does nothing if a parent pom is already present.

  • org.openrewrite.maven.table.MavenMetadataFailures: Attempts to resolve maven metadata that failed.

Change Maven dependency: Change a Maven dependency coordinates. The newGroupId or newArtifactId MUST be different from before. Matching <dependencyManagement> coordinates are also updated if a newVersion or versionPattern is provided.

  • org.openrewrite.maven.table.MavenMetadataFailures: Attempts to resolve maven metadata that failed.

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.table.MavenMetadataFailures: Attempts to resolve maven metadata that failed.

Change Maven parent: Change the parent pom of a Maven pom.xml. Identifies the parent pom to be changed by its groupId and artifactId.

  • org.openrewrite.maven.table.MavenMetadataFailures: Attempts to resolve maven metadata that failed.

Change Maven plugin group and artifact ID: Change the groupId and/or the artifactId of a specified Maven plugin.

  • org.openrewrite.maven.table.MavenMetadataFailures: Attempts to resolve maven metadata that failed.

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.table.MavenMetadataFailures: Attempts to resolve maven metadata that failed.

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.table.DependenciesInUse: Direct and transitive dependencies in use.

Effective dependencies: Emit the data of binary dependency relationships.

  • org.openrewrite.maven.table.DependenciesInUse: Relationships between dependencies.

Effective managed dependencies: Emit the data of binary dependency relationships.

  • org.openrewrite.maven.table.DependenciesInUse: Relationships between POMs and their ancestors that define managed dependencies.

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.EffectiveMavenRepositoriesTable: Table showing which Maven repositories were used in dependency resolution for this POM.

Find effective maven settings: List the effective maven settings file for the current project.

  • org.openrewrite.maven.table.EffectiveMavenSettings: The maven settings file used by each pom.

Find Maven project properties: Finds the specified Maven project properties within a pom.xml.

  • org.openrewrite.maven.table.MavenProperties: Property and value.

Maven repository order: Determine the order in which dependencies will be resolved for each pom.xml based on its defined repositories and effective settings.xml.

  • org.openrewrite.maven.table.MavenRepositoryOrder: The order in which dependencies will be resolved for each pom.xml based on its defined repositories and effective settings.xml.

Maven parent insight: Find Maven parents matching a groupId and artifactId.

  • org.openrewrite.maven.table.ParentPomsInUse: Projects, GAVs and relativePaths for Maven parent POMs in use.

Add Maven dependency: Add a Maven dependency to a pom.xml file in the correct scope based on where it is used.

  • org.openrewrite.maven.table.MavenMetadataFailures: Attempts to resolve maven metadata that failed.

Add managed Maven dependency: Add a managed Maven dependency to a pom.xml file.

  • org.openrewrite.maven.table.MavenMetadataFailures: Attempts to resolve maven metadata that failed.

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.table.MavenMetadataFailures: Attempts to resolve maven metadata that failed.

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.table.MavenMetadataFailures: Attempts to resolve maven metadata that failed.

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.table.KotlinSourceFile: Kotlin sources present in LSTs on the SAAS.

Find method usages: Find method usages by pattern.

  • org.openrewrite.java.table.MethodCalls: The text of matching method invocations.

Find comments' language distribution: Finds all comments and uses AI to predict which language the comment is in.

  • io.moderne.ai.table.LanguageDistribution: Shows the distribution of language in comments

List all methods used: List all methods used in any Java source file.

  • io.moderne.ai.table.MethodInUse: Methods used in any Java source file.

Get embeddings for code snippets in code: This recipe calls an AI model to get an embedding for either classes or methods which can then be used for downstream tasks.

  • io.moderne.ai.table.Embeddings: Collects the embeddings for either each classes or methods.

Find method invocations that resemble a pattern: This recipe uses two phase AI approach to find a method invocation that resembles a search string.

  • io.moderne.ai.table.CodeSearch: Searches for method invocations that resemble a natural language query.

  • io.moderne.ai.table.EmbeddingPerformance: Latency characteristics of uses of embedding models.

Get recommendations: This recipe calls an AI model to get recommendations for modernizing the code base by looking at a sample of method declarations.

  • io.moderne.ai.table.Recommendations: Collects the recommendations based on sampled methods.

Dependency insight for Gradle and Maven: Finds dependencies, including transitive dependencies, in both Gradle and Maven projects. Matches within all Gradle dependency configurations and Maven scopes.

  • org.openrewrite.maven.table.DependenciesInUse: Direct and transitive dependencies in use.

Dependency report: Emits a data table detailing all Gradle and Maven dependencies.This recipe makes no changes to any source file.

  • org.openrewrite.java.dependencies.table.DependencyListReport: Lists all Gradle and Maven dependencies

Find licenses in use in third-party dependencies: Locates and reports on all licenses in use.

  • org.openrewrite.java.dependencies.table.LicenseReport: Contains a license report of third-party dependencies.

Dependency resolution diagnostic: Recipes which manipulate dependencies must be able to successfully access the artifact repositories and resolve dependencies from them. This recipe produces two data tables used to understand the state of dependency resolution.

The Repository accessibility report lists all the artifact repositories known to the project and whether respond to network access. The network access is attempted while the recipe is run and so is representative of current conditions.

The Gradle dependency configuration errors lists all the dependency configurations that failed to resolve one or more dependencies when the project was parsed. This is representative of conditions at the time the LST was parsed.

  • org.openrewrite.java.dependencies.table.RepositoryAccessibilityReport: Listing of all dependency repositories and whether they are accessible.

  • org.openrewrite.java.dependencies.table.GradleDependencyConfigurationErrors: Records Gradle dependency configurations which failed to resolve during parsing. Partial success/failure is common, a failure in this list does not mean that every dependency failed to resolve.

Find and fix vulnerable dependencies: This software composition analysis (SCA) tool detects and upgrades dependencies with publicly disclosed vulnerabilities. This recipe both generates a report of vulnerable dependencies and upgrades to newer versions with fixes. This recipe only upgrades to the latest patch version. If a minor or major upgrade is required to reach the fixed version, this recipe will not make any changes. Vulnerability information comes from the GitHub Security Advisory Database, which aggregates vulnerability data from several public databases, including the National Vulnerability Database maintained by the United States government. Dependencies following Semantic Versioning will see their patch version updated where applicable.

  • org.openrewrite.java.dependencies.table.VulnerabilityReport: A vulnerability report that includes detailed information about the affected artifact and the corresponding CVEs.

Find relocated dependencies: Find Maven and Gradle dependencies and Maven plugins that have relocated to a new groupId or artifactId. Relocation information comes from the oga-maven-plugin maintained by Jonathan Lermitage, Filipe Roque and others.

This recipe makes no changes to any source file by default. Add changeDependencies=true to change dependencies, but note that you might need to run additional recipes to update imports and adopt other breaking changes.

  • org.openrewrite.java.dependencies.table.RelocatedDependencyReport: A list of dependencies in use that have relocated.

Find the oldest matching dependency version in use: The oldest dependency version in use is the lowest dependency version in use in any source set of any subproject of a repository. It is possible that, for example, the main source set of a project uses Jackson 2.11, but a test source set uses Jackson 2.16. In this case, the oldest Jackson version in use is Java 2.11.

  • org.openrewrite.maven.table.DependenciesInUse: Direct and transitive dependencies in use.

Find sensitive API endpoints: Find data models exposed by REST APIs that contain sensitive information like PII and secrets.

  • org.openrewrite.java.security.table.SensitiveApiEndpoints: The API endpoints that expose sensitive data.

Find Dropwizard metrics: Find uses of Dropwizard metrics that could be converted to a more modern metrics instrumentation library.

  • org.openrewrite.micrometer.table.DropwizardMetricsInUse: These metrics should be converted to a more moderne metrics instrumentation library.

Find which Java version is in use: A diagnostic for studying the distribution of Java language version levels (both source and target compatibility across files and source sets).

  • org.openrewrite.java.migrate.table.JavaVersionPerSourceSet: A per-source set view of Java version in use.

Find data used on DTOs: Find data elements used on DTOs. This is useful to provide information where data over-fetching may be a problem.

  • org.openrewrite.java.migrate.table.DtoDataUses: The use of the data elements of a DTO by the method declaration using it.

Find Java versions in use: Finds Java versions in use.

  • org.openrewrite.java.migrate.table.JavaVersionTable: Records versions of Java in use

Node.js dependency insight: Identify the direct and transitive Node.js dependencies used in a project.

  • org.openrewrite.nodejs.table.DependenciesInUse: Direct and transitive dependencies in use.

Find Node.js projects: Find Node.js projects and summarize data about them.

  • org.openrewrite.nodejs.table.NodeProjects: Summary information about Node.js projects.

Find HTTP API calls via RestTemplate: Find outbound HTTP API calls made via Spring's RestTemplate class.

  • org.openrewrite.java.spring.table.ApiCalls: The API endpoints that applications expose.

Find Spring API endpoints: Find all HTTP API endpoints exposed by Spring applications. More specifically, this marks method declarations annotated with @RequestMapping, @GetMapping, @PostMapping, @PutMapping, @DeleteMapping, and @PatchMapping as search results.

  • org.openrewrite.java.spring.table.ApiEndpoints: The API endpoints that applications expose.

Find Spring components: Find Spring components, including controllers, services, repositories, return types of @Bean annotated methods, etc.

  • org.openrewrite.java.spring.table.SpringComponents: Classes defined with a form of a Spring @Component stereotype and types returned from @Bean annotated methods.

  • org.openrewrite.java.spring.table.SpringComponentRelationships: A table of relationships between Spring components.

Change a SQL function name: When migrating between dialects, often one name can be substituted for another. For example, Oracle's NVL function can be replaced with Postgres COALESCE.

  • org.openrewrite.sql.table.DatabaseQueries: Shows matching SQL queries.

  • org.openrewrite.sql.table.DatabaseFunctions: Shows matching SQL functions and the queries that contain them.

Find SQL in code and resource files: Find SQL in code (e.g. in string literals) and in resources like those ending with .sql.

  • org.openrewrite.sql.table.DatabaseColumnsUsed: Shows which database columns are read/written by a SQL statement.

Find SQL function: Find SQL functions by name.

  • org.openrewrite.sql.table.DatabaseQueries: Shows matching SQL queries.

  • org.openrewrite.sql.table.DatabaseFunctions: Shows matching SQL functions and the queries that contain them.

Find Struts actions: Find actions and their associated definitions.

  • org.openrewrite.java.struts.table.StrutsActions: Definition of struts action.

Change Maven Compiler plugin annotation processor groupId, artifactId and/or the version: Change the groupId, artifactId and/or the version of a specified Maven Compiler plugin annotation processor.

  • org.openrewrite.maven.table.MavenMetadataFailures: Attempts to resolve maven metadata that failed.

Sync Maven Compiler plugin annotation processor version with the one provided by the BOM: Sync Maven Compiler plugin annotation processor version with the one provided by the BOM.

  • org.openrewrite.maven.table.MavenMetadataFailures: Attempts to resolve maven metadata that failed.

Last updated