Skip to content

Commit

Permalink
refactor: OpenRewrite best practices
Browse files Browse the repository at this point in the history
Use this link to re-run the recipe: https://app.moderne.io/recipes/org.openrewrite.recipes.OpenRewriteBestPractices?organizationId=T3BlblJld3JpdGU%3D

Co-authored-by: Moderne <team@moderne.io>
  • Loading branch information
timtebeek and TeamModerne committed Jun 10, 2024
1 parent 99ffd02 commit 3378baa
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/main/java/org/openrewrite/jenkins/UpgradeJavaVersion.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ public String getDescription() {
public TreeVisitor<?, ExecutionContext> getVisitor() {
return Preconditions.check(new FindSourceFiles("**/Jenkinsfile"), new GroovyIsoVisitor<ExecutionContext>() {
@Override
public J.Assignment visitAssignment(J.Assignment assignment, ExecutionContext executionContext) {
J.Assignment a = super.visitAssignment(assignment, executionContext);
public J.Assignment visitAssignment(J.Assignment assignment, ExecutionContext ctx) {
J.Assignment a = super.visitAssignment(assignment, ctx);
if (!(a.getVariable() instanceof J.Identifier) || !(a.getAssignment() instanceof J.Literal)) {
return a;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,26 @@
package org.openrewrite.jenkins;

import org.junit.jupiter.api.Test;
import org.openrewrite.DocumentExample;
import org.openrewrite.test.RecipeSpec;
import org.openrewrite.test.RewriteTest;

import static org.openrewrite.groovy.Assertions.groovy;

public class UpgradeJavaVersionTest implements RewriteTest {
class UpgradeJavaVersionTest implements RewriteTest {

@Override
public void defaults(RecipeSpec spec) {
spec.recipe(new UpgradeJavaVersion(17, null));
}

@DocumentExample
@Test
void openJdk() {
rewriteRun(
//language=groovy
groovy("""
groovy(
"""
#!/usr/bin/env groovy
stage("Checkout") {
Expand Down Expand Up @@ -61,7 +64,8 @@ void jdk() {
rewriteRun(
spec -> spec.recipe(new UpgradeJavaVersion(17, "openjdk")),
//language=groovy
groovy("""
groovy(
"""
node('cicd-build') {
stage ("Titan") {
titan {
Expand Down

0 comments on commit 3378baa

Please sign in to comment.