openrewrite / rewrite-gradle-plugin

OpenRewrite's Gradle plugin.
Apache License 2.0
60 stars 37 forks source link

8.13-SNAPSHOT can't parse file and it does not tell why: There were problems parsing ... #253

Closed vlsi closed 8 months ago

vlsi commented 8 months ago

What version of OpenRewrite are you using?

latest.integration

Here's a relevant bit of --debug output:

024-01-02T13:08:47.263+0300 [DEBUG] [org.openrewrite.shaded.jgit.internal.storage.file.FileSnapshot] file=/Users/vlsi/Documents/code/pgjdbc/.git/config, is unmodified
2024-01-02T13:08:47.816+0300 [WARN] [org.openrewrite.gradle.isolated.DefaultProjectParser] There were problems parsing some source files, run with --info to see full stack traces
2024-01-02T13:08:47.816+0300 [WARN] [org.openrewrite.gradle.isolated.DefaultProjectParser] There were problems parsing pgjdbc/src/main/java/org/postgresql/core/QueryExecutor.java
2024-01-02T13:08:47.891+0300 [WARN] [org.openrewrite.gradle.isolated.DefaultProjectParser] There were problems parsing pgjdbc/src/main/java/org/postgresql/core/QueryExecutorBase.java
2024-01-02T13:08:49.553+0300 [LIFECYCLE] [org.openrewrite.gradle.isolated.DefaultProjectParser] All sources parsed, running active recipes: io.github.pgjdbc.staticanalysis.CodeCleanup, io.github.pgjdbc.staticanalysis.CommonStaticAnalysis, org.openrewrite.java.testing.junit5.JUnit5BestPractices, org.openrewrite.java.testing.junit5.CleanupAssertions

The code is at https://github.com/pgjdbc/pgjdbc/pull/2979

timtebeek commented 8 months ago

Hi! I've moved this issue to the Gradle plugin specifically, as that's what you appear to be use for pgjdbc; we recently added a small diagnostic help to the rewrite-maven-plugin. Looks like the Gradle plugin could use the same.

vlsi commented 8 months ago

I updated openrewrite-snapshot today, and it somehow fixed the parsing issue. The issue seems to be fixed now.

> The following files have format violations. Execute ./gradlew :postgresql:rewriteRun to apply the changes:
  diff --git a/pgjdbc/src/main/java/org/postgresql/core/QueryExecutorBase.java b/pgjdbc/src/main/java/org/postgresql/core/QueryExecutorBase.java
  index 9e84236..fff8807 100644
  --- a/pgjdbc/src/main/java/org/postgresql/core/QueryExecutorBase.java
  +++ b/pgjdbc/src/main/java/org/postgresql/core/QueryExecutorBase.java
  @@ -45,7 +45,7 @@ org.openrewrite.config.CompositeRecipe
     private int cancelKey;
     protected final QueryExecutorCloseAction closeAction;
     private @MonotonicNonNull String serverVersion;
  -  private int serverVersionNum = 0;
  +  private int serverVersionNum;
     private TransactionState transactionState = TransactionState.IDLE;
     private final boolean reWriteBatchedInserts;
     private final boolean columnSanitiserDisabled;
  @@ -57,17 +57,17 @@
     protected final boolean logServerErrorDetail;

     // default value for server versions that don't report standard_conforming_strings
  -  private boolean standardConformingStrings = false;
  +  private boolean standardConformingStrings;

     private @Nullable SQLWarning warnings;
  -  private final ArrayList<PGNotification> notifications = new ArrayList<PGNotification>();
  +  private final ArrayList<PGNotification> notifications = new ArrayList<>();
timtebeek commented 8 months ago

Glad to hear the problem has been resolved, and thanks for checking again and closing the issue yourself. Really helps us!