openrewrite / rewrite-gradle-plugin

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

Reduce stacktrace noise in the output when running with info mode #240

Open vlsi opened 10 months ago

vlsi commented 10 months ago

What version of OpenRewrite are you using?

org.openrewrite.rewrite.gradle.plugin:6.4.3

How are you running OpenRewrite?

plugins {
    id("org.openrewrite.rewrite")
}

dependencies {
    rewrite(platform("org.openrewrite.recipe:rewrite-recipe-bom:2.4.1"))
    rewrite("org.openrewrite.recipe:rewrite-static-analysis")
}

rewrite {
    activeRecipe("org.openrewrite.java.OrderImports")
    activeRecipe("org.openrewrite.staticanalysis.MissingOverrideAnnotation")
}

What is the smallest, simplest way to reproduce the problem?

The project should have files that OpenRewrite can't parse.

What did you expect to see?

Running the build with --info should not be extremely verbose.

What did you see instead?

Running ./gradlew rewriteRun produces 187 lines for pgjdbc/pgjdbc. There are 52 lines starting with 'There were problems parsing...'

Running the same build with ./gradlew rewriteRun produces 2 megabyte with 21781 lines. That makes --info virtually unusable.

I suggest that "debugging" openrewrite should be hidden under a special flag as people can rarely deal with OpenRewrite parser failures.

What is the full stack trace of any errors you encountered?

rewriteRun.info.txt

Are you interested in contributing a fix to OpenRewrite?

I might probably work on that

A workaround might probably be excluding the problematic files until OpenRewrite parser is fixed.

timtebeek commented 10 months ago

That's indeed a lot of output with little in the sense of actionable stack traces. From a spot check a few of those parser errors are related to the issue you've reported:

Our best bet to reduce the output is the resolve those parser errrors, which are rare, in openrewrite/rewrite#3464 as indicated. I suspect you'll then end up with far less output, and are able to narrow down any remaining issues more easily.

That said, if you see any good ways to push some of the current --info further down then we're open to (and much appreciate) suggestions!

koppor commented 3 weeks ago

Alternatively, it would be nice if the line number or the concrete issue at "There were problems parsing...". Maybe adding the reason of the exception?

2024-08-28T12:33:45.572+0200 [WARN] [org.openrewrite.gradle.isolated.DefaultProjectParser] There were problems parsing src\main\java\org\jabref\logic\ai\chathistory\BibDatabaseChatHistoryManager.java
2024-08-28T12:33:45.572+0200 [DEBUG] [org.openrewrite.gradle.isolated.DefaultProjectParser] java.lang.IllegalStateException: src\main\java\org\jabref\logic\ai\chathistory\BibDatabaseChatHistoryManager.java is not print idempotent.

New:

2024-08-28T12:33:45.572+0200 [WARN] [org.openrewrite.gradle.isolated.DefaultProjectParser] There were problems at parsing: src\main\java\org\jabref\logic\ai\chathistory\BibDatabaseChatHistoryManager.java is not print idempotent.

Update: The concrete error is https://github.com/openrewrite/rewrite/issues/4223