Skip to content

Commit 6547c82

Browse files
OpenRewrite recipe best practices
Use this link to re-run the recipe: https://app.moderne.io/recipes/org.openrewrite.recipes.rewrite.OpenRewriteRecipeBestPractices?organizationId=ODQ2MGExMTUtNDg0My00N2EwLTgzMGMtNGE1NGExMTBmZDkw Co-authored-by: Moderne <team@moderne.io>
1 parent c4c5941 commit 6547c82

1 file changed

Lines changed: 47 additions & 0 deletions

File tree

src/main/resources/META-INF/rewrite/examples.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1397,6 +1397,34 @@ examples:
13971397
language: java
13981398
---
13991399
type: specs.openrewrite.org/v1beta/example
1400+
recipeName: org.openrewrite.staticanalysis.MoveConditionsToWhile
1401+
examples:
1402+
- description: ''
1403+
sources:
1404+
- before: |
1405+
class Test {
1406+
void foo(int counter) {
1407+
while (true) {
1408+
if (counter >= 5) {
1409+
break;
1410+
}
1411+
System.out.println("Counter: " + counter);
1412+
counter++;
1413+
}
1414+
}
1415+
}
1416+
after: |
1417+
class Test {
1418+
void foo(int counter) {
1419+
while (counter < 5) {
1420+
System.out.println("Counter: " + counter);
1421+
counter++;
1422+
}
1423+
}
1424+
}
1425+
language: java
1426+
---
1427+
type: specs.openrewrite.org/v1beta/example
14001428
recipeName: org.openrewrite.staticanalysis.MultipleVariableDeclarations
14011429
examples:
14021430
- description: ''
@@ -1921,6 +1949,25 @@ examples:
19211949
language: java
19221950
---
19231951
type: specs.openrewrite.org/v1beta/example
1952+
recipeName: org.openrewrite.staticanalysis.PreferEqualityComparisonOverDifferenceCheck
1953+
examples:
1954+
- description: ''
1955+
sources:
1956+
- before: |
1957+
class Test {
1958+
boolean test(int a, int b) {
1959+
return a - b == 0;
1960+
}
1961+
}
1962+
after: |
1963+
class Test {
1964+
boolean test(int a, int b) {
1965+
return a == b;
1966+
}
1967+
}
1968+
language: java
1969+
---
1970+
type: specs.openrewrite.org/v1beta/example
19241971
recipeName: org.openrewrite.staticanalysis.PreferIncrementOperator
19251972
examples:
19261973
- description: ''

0 commit comments

Comments
 (0)