openrewrite / rewrite

Automated mass refactoring of source code.
https://docs.openrewrite.org
Apache License 2.0
2.09k stars 312 forks source link

Issue discovered with `azure-gradle-plugins-common/build.gradle` #2100

Closed jkschneider closed 2 years ago

jkschneider commented 2 years ago

Problem

Describe the issue you are experiencing.

Expected behavior

Describe what you expected to see.

Example diff

-ext {
+/*~~(java.lang.IllegalStateException: Expected to find a matching parent for Cursor{CompilationUnit->root}
+  org.openrewrite.Cursor.dropParentUntil(Cursor.java:171)
+  org.openrewrite.java.cleanup.UnnecessaryExplicitTypeArguments$1.visitMethodInvocation(UnnecessaryExplicitTypeArguments.java:47)
+  org.openrewrite.java.cleanup.UnnecessaryExplicitTypeArguments$1.visitMethodInvocation(UnnecessaryExplicitTypeArguments.java:41)
+  org.openrewrite.java.cleanup.UnnecessaryExplicitTypeArguments_1_GroovyVisitor.visitMethodInvocation(UnnecessaryExplicitTypeArguments_1_GroovyVisitor.zig:54)
+  org.openrewrite.java.tree.J$MethodInvocation.acceptJava(J.java:3409)
+  org.openrewrite.java.tree.J.accept(J.java:55)
+  org.openrewrite.TreeVisitor.visit(TreeVisitor.java:206)
+  org.openrewrite.TreeVisitor.visitAndCast(TreeVisitor.java:285)
+  ...)~~>*//*~~(java.lang.IllegalStateException: Expected to find a matching parent for Cursor{CompilationUnit->root}
+  org.openrewrite.Cursor.dropParentUntil(Cursor.java:171)
+  org.openrewrite.java.cleanup.UnnecessaryParenthesesVisitor.visitIdentifier(UnnecessaryParenthesesVisitor.java:56)
+  org.openrewrite.java.cleanup.UnnecessaryParenthesesVisitor_GroovyVisitor.visitIdentifier(UnnecessaryParenthesesVisitor_GroovyVisitor.zig:96)
+  org.openrewrite.java.tree.J$Identifier.acceptJava(J.java:2144)
+  org.openrewrite.java.tree.J.accept(J.java:55)
+  org.openrewrite.TreeVisitor.visit(TreeVisitor.java:206)
+  org.openrewrite.TreeVisitor.visitNonNull(TreeVisitor.java:164)
+  org.openrewrite.java.JavaVisitor.visitMethodInvocation(JavaVisitor.java:853)
+  ...)~~>*/ext {
     projectShortName = "azure-gradle-plugins-common"
     projectName = "Common Lib for Azure Gradle Plugins"
     projectDescription = "A common lib for sharing code among azure gradle plugins"
 }

 dependencies {
-    compile gradleApi()
+    compile gradleApi(/*~~(java.lang.IllegalStateException: Expected to find a matching parent for Cursor{CompilationUnit->root}
+  org.openrewrite.Cursor.dropParentUntil(Cursor.java:171)
+  org.openrewrite.java.cleanup.RemoveExtraSemicolons$1.visitEmpty(RemoveExtraSemicolons.java:58)
+  org.openrewrite.java.cleanup.RemoveExtraSemicolons$1.visitEmpty(RemoveExtraSemicolons.java:55)
+  org.openrewrite.java.cleanup.RemoveExtraSemicolons_1_GroovyVisitor.visitEmpty(RemoveExtraSemicolons_1_GroovyVisitor.zig:54)
+  org.openrewrite.java.tree.J$Empty.acceptJava(J.java:1520)
+  org.openrewrite.java.tree.J.accept(J.java:55)
+  org.openrewrite.TreeVisitor.visit(TreeVisitor.java:206)
+  org.openrewrite.TreeVisitor.visitAndCast(TreeVisitor.java:285)
+  ...)~~>*/)

     implementation 'commons-io:commons-io:2.10.0'
     implementation 'org.apache.commons:commons-lang3:3.12.0'
     annotationProcessor 'org.projectlombok:lombok:1.18.20'
 }

-publishing {
-    publications {
-        mavenJava(MavenPublication) {
+publishing {publications {mavenJava(MavenPublication) {
             from components.java
             artifact sourceJar
             artifact javadocJar
                 name = projectName
                 description = projectDescription
                 url = "https://github.com/microsoft/azure-gradle-plugins/tree/master/" + projectShortName
-                licenses {
-                    license {
+                licenses {license {
                         name = "MIT License"
                         url = "https://opensource.org/licenses/MIT"
                         distribution = "repo"
-                    }
-                }
+                    }}
                 developers {
                     developer {
                         id = "andxu"
                     url = "https://github.com/microsoft/azure-gradle-plugins/tree/master/" + projectShortName
                 }
             }
-        }
-    }
-}
\ No newline at end of file
+        }}}
\ No newline at end of file

Recipes in example diff:

References:

tkvangorder commented 2 years ago

"Common static analysis" runs cleanly on this project now.