Skip to content

Commit

Permalink
Merge branch 'main' into java-template-id
Browse files Browse the repository at this point in the history
  • Loading branch information
timtebeek authored Jul 28, 2024
2 parents cd9b0f2 + 98b720b commit 10490fc
Show file tree
Hide file tree
Showing 1,029 changed files with 44,520 additions and 26,990 deletions.
4 changes: 0 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,8 @@ concurrency:
jobs:
build:
uses: openrewrite/gh-automation/.github/workflows/ci-gradle.yml@main
with:
java_version: 21
secrets:
gradle_enterprise_access_key: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
gradle_enterprise_cache_username: ${{ secrets.GRADLE_ENTERPRISE_CACHE_USERNAME }}
gradle_enterprise_cache_password: ${{ secrets.GRADLE_ENTERPRISE_CACHE_PASSWORD }}
ossrh_username: ${{ secrets.OSSRH_USERNAME }}
ossrh_token: ${{ secrets.OSSRH_TOKEN }}
ossrh_signing_key: ${{ secrets.OSSRH_SIGNING_KEY }}
Expand Down
15 changes: 15 additions & 0 deletions .github/workflows/comment-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: comment-pr

# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#using-data-from-the-triggering-workflow
on:
workflow_run:
workflows: ["receive-pr"]
types:
- completed

# https://securitylab.github.com/research/github-actions-preventing-pwn-requests/
# Since this pull request has write permissions on the target repo, we should **NOT** execute any untrusted code.
jobs:
post-suggestions:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
uses: openrewrite/gh-automation/.github/workflows/comment-pr.yml@main
20 changes: 0 additions & 20 deletions .github/workflows/dependency-check.yml

This file was deleted.

24 changes: 24 additions & 0 deletions .github/workflows/dependency-submission.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Dependency Submission

on:
workflow_run:
workflows: ["publish"]
types:
- completed

permissions:
contents: write

jobs:
dependency-submission:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Generate and submit dependency graph
uses: gradle/actions/dependency-submission@v3
env:
# Exclude all dependencies that originate solely in the 'buildSrc' project
DEPENDENCY_GRAPH_EXCLUDE_PROJECTS: ':buildSrc'
# Exclude dependencies that are only resolved in test classpaths
DEPENDENCY_GRAPH_EXCLUDE_CONFIGURATIONS: '.*[Tt]est(Compile|Runtime)Classpath'
2 changes: 0 additions & 2 deletions .github/workflows/nightly-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ jobs:
uses: openrewrite/gh-automation/.github/workflows/ci-gradle.yml@main
secrets:
gradle_enterprise_access_key: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
gradle_enterprise_cache_username: ${{ secrets.GRADLE_ENTERPRISE_CACHE_USERNAME }}
gradle_enterprise_cache_password: ${{ secrets.GRADLE_ENTERPRISE_CACHE_PASSWORD }}
ossrh_username: ${{ secrets.OSSRH_USERNAME }}
ossrh_token: ${{ secrets.OSSRH_TOKEN }}
ossrh_signing_key: ${{ secrets.OSSRH_SIGNING_KEY }}
Expand Down
84 changes: 84 additions & 0 deletions .github/workflows/receive-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: receive-pr

on:
pull_request:
types: [opened, synchronize]
branches:
- main

concurrency:
group: '${{ github.workflow }} @ ${{ github.ref }}'
cancel-in-progress: true

# https://securitylab.github.com/research/github-actions-preventing-pwn-requests/
# Since this pull request receives untrusted code, we should **NOT** have any secrets in the environment.
jobs:
upload-patch:
uses: openrewrite/gh-automation/.github/workflows/receive-pr.yml@main
with:
recipe: 'org.openrewrite.recipes.OpenRewriteBestPracticesSubset'
rewrite_yml: |
---
type: specs.openrewrite.org/v1beta/recipe
name: org.openrewrite.recipes.OpenRewriteBestPracticesSubset
displayName: OpenRewrite best practices
description: Best practices for OpenRewrite recipe development.
recipeList:
- org.openrewrite.recipes.JavaRecipeBestPracticesSubset
- org.openrewrite.recipes.RecipeTestingBestPracticesSubset
- org.openrewrite.recipes.RecipeNullabilityBestPracticesSubset
#- org.openrewrite.java.OrderImports
- org.openrewrite.java.format.EmptyNewlineAtEndOfFile
- org.openrewrite.staticanalysis.InlineVariable
- org.openrewrite.staticanalysis.MissingOverrideAnnotation
- org.openrewrite.staticanalysis.UseDiamondOperator
---
type: specs.openrewrite.org/v1beta/recipe
name: org.openrewrite.recipes.JavaRecipeBestPracticesSubset
displayName: Java Recipe best practices
description: Best practices for Java recipe development.
preconditions:
- org.openrewrite.java.search.FindTypes:
fullyQualifiedTypeName: org.openrewrite.Recipe
checkAssignability: true
recipeList:
- org.openrewrite.java.recipes.BlankLinesAroundFieldsWithAnnotations
- org.openrewrite.java.recipes.ExecutionContextParameterName
- org.openrewrite.java.recipes.MissingOptionExample
- org.openrewrite.java.recipes.RecipeEqualsAndHashCodeCallSuper
- org.openrewrite.java.recipes.UseTreeRandomId
- org.openrewrite.staticanalysis.NeedBraces
#- org.openrewrite.staticanalysis.RemoveSystemOutPrintln
---
type: specs.openrewrite.org/v1beta/recipe
name: org.openrewrite.recipes.RecipeTestingBestPracticesSubset
displayName: Recipe testing best practices
description: Best practices for testing recipes.
preconditions:
- org.openrewrite.java.search.FindTypes:
fullyQualifiedTypeName: org.openrewrite.test.RewriteTest
checkAssignability: true
recipeList:
- org.openrewrite.java.recipes.RewriteTestClassesShouldNotBePublic
#- org.openrewrite.java.recipes.SelectRecipeExamples
- org.openrewrite.java.recipes.SourceSpecTextBlockIndentation
- org.openrewrite.java.testing.cleanup.RemoveTestPrefix
- org.openrewrite.java.testing.cleanup.TestsShouldNotBePublic
- org.openrewrite.staticanalysis.NeedBraces
- org.openrewrite.staticanalysis.RemoveSystemOutPrintln
---
type: specs.openrewrite.org/v1beta/recipe
name: org.openrewrite.recipes.RecipeNullabilityBestPracticesSubset
displayName: Recipe nullability best practices
description: Use OpenRewrite internal nullability annotations; drop JetBrains annotations; use `package-info.java` instead.
recipeList:
- org.openrewrite.java.ChangeType:
oldFullyQualifiedTypeName: org.jetbrains.annotations.Nullable
newFullyQualifiedTypeName: org.openrewrite.internal.lang.Nullable
- org.openrewrite.java.ChangeType:
oldFullyQualifiedTypeName: jakarta.annotation.Nullable
newFullyQualifiedTypeName: org.openrewrite.internal.lang.Nullable
- org.openrewrite.java.RemoveAnnotation:
annotationPattern: '@org.jetbrains.annotations.NotNull'
- org.openrewrite.java.RemoveAnnotation:
annotationPattern: '@jakarta.annotation.Nonnull'
Binary file added .idea/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion IDE.properties.tmp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ rewrite-java
rewrite-java-test
rewrite-java-tck
rewrite-java-17
rewrite-java-21

# Other language modules

Expand All @@ -42,4 +43,4 @@ rewrite-bom

# Tools that are used less frequently to, for example, build new language parsers.

tools
#tools
38 changes: 25 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
<h1 align="center">OpenRewrite</h1>
<p align="center"><i><b>🎉 Automate software refactoring 🎉</b></i></p>

---

<p align="center">
<img src="doc/OpenRewrite.gif" alt="OpenRewrite"/>
<img src="./doc/logo-oss.png" alt="OpenRewrite"/>
</p>

<div align="center">
Expand All @@ -17,21 +12,38 @@
[![Contributing Guide](https://img.shields.io/badge/Contributing-Guide-informational)](https://github.com/openrewrite/.github/blob/main/CONTRIBUTING.md)
</div>

## More tech. Less debt.
<h1 align="center">Fast, repeatable refactoring for developers</h1>

The OpenRewrite project is an automated refactoring ecosystem for source code, enabling developers to effectively eliminate technical debt within their repositories.

It consists of an auto-refactoring engine that runs prepackaged, open source refactoring recipes for common framework migrations, security fixes, and stylistic consistency tasks—reducing your coding effort from hours or days to minutes. Build tool plugins like [OpenRewrite Gradle Plugin](https://docs.openrewrite.org/reference/gradle-plugin-configuration) and [OpenRewrite Maven Plugin](https://docs.openrewrite.org/reference/rewrite-maven-plugin) help you run these recipes on one repository at a time.

The OpenRewrite project is a mass source code refactoring ecosystem. Reduce 1000s of hours of static code analysis fixes to minutes. Turn a four-month migration project into four hours of work. Patch security vulnerabilities across 100s of repositories at once. OpenRewrite automates code refactoring and remediation tasks for you, enabling developers to deliver more business value.
OpenRewrite recipes have bench strength in Java and are part of a growing community of languages, frameworks, and tech. It’s thousands of great individuals and teams working to make software seamless to update and continuously secure. You can also easily customize recipes for your code.

Start with our [quickstart guide](https://docs.openrewrite.org/running-recipes/getting-started) and let OpenRewrite start handling the boring parts of software development for you. Full documentation available at [docs.openrewrite.org](https://docs.openrewrite.org/).
Start with our [quickstart guide](https://docs.openrewrite.org/running-recipes/getting-started) and let OpenRewrite handle the boring parts of software development for you.

Feel free to join us on [Slack](https://join.slack.com/t/rewriteoss/shared_invite/zt-nj42n3ea-b~62rIHzb3Vo0E1APKCXEA) or [Discord](https://discord.gg/xk3ZKrhWAb)! We're happy to answer your questions directly. Also, follow us on [Twitter](https://twitter.com/moderneinc) and [LinkedIn](https://www.linkedin.com/company/moderneinc).
Get and stay informed:
* Read the [documentation](http://docs.openrewrite.org).
* Join us on [Slack](https://join.slack.com/t/rewriteoss/shared_invite/zt-nj42n3ea-b~62rIHzb3Vo0E1APKCXEA) or [Discord](https://discord.gg/xk3ZKrhWAb)! We're happy to answer your questions directly.
* Check out [Community Office Hours](https://www.youtube.com/@moderne-auto-remediation/streams) where we deep dive topics and answer questions.
* Subscribe to our [YouTube](https://www.youtube.com/@moderne-auto-remediation) channel for great videos on OpenRewrite recipes.
* Follow us on [Twitter](https://twitter.com/openrewrite) and [LinkedIn](https://www.linkedin.com/company/moderneinc).

See this [doc page](https://docs.openrewrite.org/reference/building-openrewrite-from-source) for more on building this repository from source.
OpenRewrite is Apache2 licensed and maintained by Moderne. OpenRewrite's refactoring engine and recipes will always be open source.

## Refactoring at scale with Moderne

OpenRewrite's refactoring engine and recipes will always be open source. Build tool plugins like [OpenRewrite Gradle Plugin](https://docs.openrewrite.org/reference/gradle-plugin-configuration) and [OpenRewrite Maven Plugin](https://docs.openrewrite.org/reference/rewrite-maven-plugin) help you run these recipes on one repository at a time. Moderne is a complementary product that executes OpenRewrite recipes at scale on hundreds of millions of lines of code and enables mass-committing of results. Moderne freely runs a [public service](https://public.moderne.io) for the benefit of thousands of open source projects.
[Moderne](https://www.moderne.io/) is a commercial platform designed to run the OpenRewrite recipe catalog with incredible efficiency, supporting large codebases and multiple repositories. It’s a place where platform teams and developers can collaborate to drive migrations across their codebases, mass-commit code fixes, and perform large-scale impact analyses.

See how Moderne and OpenRewrite work in different ways to transform your code.

[![Moderne](./doc/openrewrite_v_moderne.png)](https://www.youtube.com/watch?v=Q-ej2lCJHRs)

Moderne freely runs an [open public service](https://www.moderne.io/try-moderne) for the benefit of tens of thousands of open source projects. The platform can streamline your recipe customization and creation, enabling quick assembly and testing. It also includes a multi-repo command line interface (CLI) to enable developers to run and customize recipes locally.

[![Moderne](./doc/moderne_cli.png)](https://www.youtube.com/watch?v=cs-6FJ_mtro)

[![Moderne](./doc/video_preview.png)](https://youtu.be/Mq6bKAeGCz0)
To understand better how Moderne can help your team, [contact us](https://www.moderne.io/contact-us).

## Contributing

Expand Down
Binary file removed doc/OpenRewrite.gif
Binary file not shown.
14 changes: 14 additions & 0 deletions doc/adr/0005-parser-lst-conventions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# 5. Parser and LST Design Conventions and Best Practices

## Status

Draft

## Context

As we have developed parsers for more programming languages and data formats a number of conventions and best practices
have emerged. This document is intended to capture and codify those conventions and best practices.

## Decision


Binary file added doc/moderne_cli.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/openrewrite_v_moderne.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed doc/video_preview.png
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/licenseHeader.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright 2023 the original author or authors.
Copyright ${year} the original author or authors.
<p>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionSha256Sum=d725d707bfabd4dfdc958c624003b3c80accc03f7037b5122c4b1d0ef15cecab
6 changes: 4 additions & 2 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#

##############################################################################
#
Expand Down Expand Up @@ -55,7 +57,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand Down Expand Up @@ -84,7 +86,7 @@ done
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down
22 changes: 12 additions & 10 deletions gradlew.bat
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem

@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
Expand Down Expand Up @@ -43,11 +45,11 @@ set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand All @@ -57,11 +59,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto execute

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand Down
2 changes: 1 addition & 1 deletion rewrite-benchmarks/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
plugins {
id("org.openrewrite.build.java-base")
id("org.openrewrite.build.recipe-repositories")
id("me.champeau.gradle.jmh") version "0.5.2"
}

dependencies {
jmh("org.eclipse.jgit:org.eclipse.jgit:5.13.+")
jmh("com.google.code.findbugs:jsr305:latest.release")
jmh("org.projectlombok:lombok:latest.release")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public void setup() throws URISyntaxException {

sourceFiles = JavaParser.fromJavaVersion()
.classpath("jsr305", "classgraph", "jackson-annotations", "micrometer-core", "slf4j-api",
"org.eclipse.jgit")
"org.openrewrite.jgit")
// .logCompilationWarningsAndErrors(true)
.build()
.parse(inputs, null, new InMemoryExecutionContext(Throwable::printStackTrace))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,12 @@

import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.infra.Blackhole;
import org.openrewrite.InMemoryExecutionContext;
import org.openrewrite.java.JavaParser;
import org.openrewrite.java.tree.J;

import java.io.IOException;
import java.net.URISyntaxException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

@State(Scope.Benchmark)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import org.openjdk.jmh.runner.options.Options;
import org.openjdk.jmh.runner.options.OptionsBuilder;
import org.openrewrite.java.JavaParser;
import org.openrewrite.java.UseStaticImport;

import java.util.concurrent.TimeUnit;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import org.openrewrite.TreeVisitor;
import org.openrewrite.internal.TreeVisitorAdapter;
import org.openrewrite.java.JavaVisitor;
import org.openrewrite.java.tree.J;

import java.util.concurrent.TimeUnit;

Expand Down
Loading

0 comments on commit 10490fc

Please sign in to comment.