@@ -453,6 +453,64 @@ examples:
453453 language: java
454454 ---
455455type : specs.openrewrite.org/v1beta/example
456+ recipeName : org.openrewrite.staticanalysis.CombineSemanticallyEqualCatchBlocks
457+ examples :
458+ - description : ' `CombineSemanticallyEqualCatchBlocksTest#blocksContainSameComments`'
459+ sources :
460+ - before : class A extends RuntimeException {}
461+ language : java
462+ - before : class B extends RuntimeException {}
463+ language : java
464+ - before : |
465+ class Test {
466+ void method() {
467+ try {
468+ } catch (A ex) {
469+ // Same
470+ } catch (B ex) {
471+ // Same
472+ }
473+ }
474+ }
475+ after: |
476+ class Test {
477+ void method() {
478+ try {
479+ } catch (A | B ex) {
480+ // Same
481+ }
482+ }
483+ }
484+ language: java
485+ ---
486+ type : specs.openrewrite.org/v1beta/example
487+ recipeName : org.openrewrite.staticanalysis.CompareEnumsWithEqualityOperator
488+ examples :
489+ - description : ' `CompareEnumsWithEqualityOperatorTest#changeEnumEquals`'
490+ sources :
491+ - before : |
492+ import a.A;
493+ class Test {
494+ void method(A arg0) {
495+ if (A.FOO.equals(arg0)) {
496+ }
497+ if (arg0.equals(A.FOO)) {
498+ }
499+ }
500+ }
501+ after: |
502+ import a.A;
503+ class Test {
504+ void method(A arg0) {
505+ if (A.FOO == arg0) {
506+ }
507+ if (arg0 == A.FOO) {
508+ }
509+ }
510+ }
511+ language: java
512+ ---
513+ type : specs.openrewrite.org/v1beta/example
456514recipeName : org.openrewrite.staticanalysis.ControlFlowIndentation
457515examples :
458516- description : ' `ControlFlowIndentationTest#removesIndentationFromStatementAfterIfElse`'
@@ -1344,6 +1402,26 @@ examples:
13441402 language: java
13451403 ---
13461404type : specs.openrewrite.org/v1beta/example
1405+ recipeName : org.openrewrite.staticanalysis.MethodNameCasing
1406+ examples :
1407+ - description : ' `MethodNameCasingTest#changeMethodDeclaration`'
1408+ parameters :
1409+ - ' false'
1410+ - ' false'
1411+ sources :
1412+ - before : |
1413+ class Test {
1414+ void MyMethod_with_über() {
1415+ }
1416+ }
1417+ after: |
1418+ class Test {
1419+ void myMethodWithUber() {
1420+ }
1421+ }
1422+ language: java
1423+ ---
1424+ type : specs.openrewrite.org/v1beta/example
13471425recipeName : org.openrewrite.staticanalysis.MinimumSwitchCases
13481426examples :
13491427- description : ' `MinimumSwitchCasesTest#caseWithReturnInsteadOfBreak`'
@@ -2286,6 +2364,34 @@ examples:
22862364 language: java
22872365 ---
22882366type : specs.openrewrite.org/v1beta/example
2367+ recipeName : org.openrewrite.staticanalysis.RemoveInstanceOfPatternMatch
2368+ examples :
2369+ - description : ' `RemoveInstanceOfPatternMatchTest#blockOfStatements`'
2370+ sources :
2371+ - before : |
2372+ package com.example;
2373+
2374+ class Example {
2375+ public void test(Object obj) {
2376+ if (obj instanceof String str) {
2377+ System.out.println(str);
2378+ }
2379+ }
2380+ }
2381+ after: |
2382+ package com.example;
2383+
2384+ class Example {
2385+ public void test(Object obj) {
2386+ if (obj instanceof String) {
2387+ String str = (String) obj;
2388+ System.out.println(str);
2389+ }
2390+ }
2391+ }
2392+ language: java
2393+ ---
2394+ type : specs.openrewrite.org/v1beta/example
22892395recipeName : org.openrewrite.staticanalysis.RemoveJavaDocAuthorTag
22902396examples :
22912397- description : ' `RemoveJavaDocAuthorTagTest#preserveDocsBeforeTag`'
@@ -2799,6 +2905,43 @@ examples:
27992905 language: java
28002906 ---
28012907type : specs.openrewrite.org/v1beta/example
2908+ recipeName : org.openrewrite.staticanalysis.ReplaceDeprecatedRuntimeExecMethods
2909+ examples :
2910+ - description : ' `ReplaceDeprecatedRuntimeExecMethodsTest#rawString`'
2911+ sources :
2912+ - before : |
2913+ import java.io.File;
2914+ import java.io.IOException;
2915+
2916+ class A {
2917+ void method() throws IOException {
2918+ Runtime runtime = Runtime.getRuntime();
2919+ String[] envp = { "E1=1", "E2=2"};
2920+ File dir = new File("/tmp");
2921+
2922+ Process process1 = runtime.exec("ls -a -l");
2923+ Process process2 = runtime.exec("ls -a -l", envp);
2924+ Process process3 = runtime.exec("ls -a -l", envp, dir);
2925+ }
2926+ }
2927+ after: |
2928+ import java.io.File;
2929+ import java.io.IOException;
2930+
2931+ class A {
2932+ void method() throws IOException {
2933+ Runtime runtime = Runtime.getRuntime();
2934+ String[] envp = { "E1=1", "E2=2"};
2935+ File dir = new File("/tmp");
2936+
2937+ Process process1 = runtime.exec(new String[]{"ls", "-a", "-l"});
2938+ Process process2 = runtime.exec(new String[]{"ls", "-a", "-l"}, envp);
2939+ Process process3 = runtime.exec(new String[]{"ls", "-a", "-l"}, envp, dir);
2940+ }
2941+ }
2942+ language: java
2943+ ---
2944+ type : specs.openrewrite.org/v1beta/example
28022945recipeName : org.openrewrite.staticanalysis.ReplaceDuplicateStringLiterals
28032946examples :
28042947- description : ' `ReplaceDuplicateStringLiteralsTest#replaceRedundantFinalStrings`'
@@ -2868,6 +3011,37 @@ examples:
28683011 }
28693012 }
28703013 language: java
3014+ - description : ' `ReplaceLambdaWithMethodReferenceTest#toQualifiedMethodReference`'
3015+ sources :
3016+ - before : |
3017+ fun main() {
3018+ val pets = listOf(Cat(), Dog())
3019+ pets.forEach { it.move() }
3020+ }
3021+ after: |
3022+ fun main() {
3023+ val pets = listOf(Cat(), Dog())
3024+ pets.forEach ( Pet::move )
3025+ }
3026+ language: kotlin
3027+ - before : |
3028+ interface Pet {
3029+ fun move() {
3030+ }
3031+ }
3032+
3033+ class Cat : Pet {
3034+ override fun move() {
3035+ println("Cat is moving")
3036+ }
3037+ }
3038+
3039+ class Dog : Pet {
3040+ override fun move() {
3041+ println("Dog is moving")
3042+ }
3043+ }
3044+ language: kotlin
28713045 ---
28723046type : specs.openrewrite.org/v1beta/example
28733047recipeName : org.openrewrite.staticanalysis.ReplaceOptionalIsPresentWithIfPresent
@@ -3837,6 +4011,52 @@ examples:
38374011 language: java
38384012 ---
38394013type : specs.openrewrite.org/v1beta/example
4014+ recipeName : org.openrewrite.staticanalysis.UseAsBuilder
4015+ examples :
4016+ - description : ' `UseAsBuilderTest#useAsBuilder`'
4017+ parameters :
4018+ - Buildable.Builder
4019+ - ' true'
4020+ - Buildable builder()
4021+ sources :
4022+ - before : |
4023+ class Buildable {
4024+ public static Builder builder() {
4025+ return new Builder();
4026+ }
4027+
4028+ public static class Builder {
4029+ public Builder option(String option) {
4030+ return this;
4031+ }
4032+ }
4033+ }
4034+ language: java
4035+ - before : |
4036+ class Test {
4037+ void test() {
4038+ int a = 0;
4039+ Buildable.Builder builder = Buildable.builder();
4040+ String b = "rewrite-java";
4041+ int c = 0;
4042+ builder = builder.option(b);
4043+ int d = 0;
4044+ }
4045+ }
4046+ after: |
4047+ class Test {
4048+ void test() {
4049+ int a = 0;
4050+ String b = "rewrite-java";
4051+ int c = 0;
4052+ Buildable.Builder builder = Buildable.builder()
4053+ .option(b);
4054+ int d = 0;
4055+ }
4056+ }
4057+ language: java
4058+ ---
4059+ type : specs.openrewrite.org/v1beta/example
38404060recipeName : org.openrewrite.staticanalysis.UseCollectionInterfaces
38414061examples :
38424062- description : ' `UseCollectionInterfacesTest#rawReturnType`'
0 commit comments