You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jmeter.apache.org by Milamber <br...@gmail.com> on 2024/04/15 17:21:56 UTC

com.github.autostyle.FormatterException: Error while formatting

Hi Vlad,

In 
src/components/src/main/java/org/apache/jmeter/assertions/gui/AssertionGui.java, 
line 160

Before:

     public void modifyTestElement(TestElement args) {
         GuiUtils.stopTableEditing(table);
         if (args instanceof Arguments) {
             Arguments arguments = (Arguments) args;
             arguments.clear();

After:
     public void modifyTestElement(TestElement args) {
         GuiUtils.stopTableEditing(table);
         if (args instanceof Arguments arguments) {
             arguments.clear();

=> directly define the arguments variable

Unfortunately the autostyle not seems recognize this:


Build jmeter FAILURE reason:
     Execution failed for task ':src:components:autostyleJavaProcess':
         com.github.autostyle.FormatterException: Error while formatting 
src/components/src/main/java/org/apache/jmeter/assertions/gui/AssertionGui.java: 
160:45: error: ')' expected
             Caused by: 
com.google.googlejavaformat.java.FormatterException: 160:45: error: ')' 
expected
                 at 
com.google.googlejavaformat.java.FormatterException.fromJavacDiagnostics(FormatterException.java:50)
                 at 
com.google.googlejavaformat.java.RemoveUnusedImports.parse(RemoveUnusedImports.java:253)
                 at 
com.google.googlejavaformat.java.RemoveUnusedImports.removeUnusedImports(RemoveUnusedImports.java:211)
                 at 
com.google.googlejavaformat.java.RemoveUnusedImports.removeUnusedImports(RemoveUnusedImports.java:204)
                 at 
com.github.autostyle.java.GoogleJavaFormatStep$State.lambda$createRemoveUnusedImportsOnly$1(GoogleJavaFormatStep.java:156)
                 at 
com.github.autostyle.FormatterFunc.apply(FormatterFunc.java:31)
                 at 
com.github.autostyle.FormatterStepImpl$Standard.format(FormatterStepImpl.java:77)
                 at 
com.github.autostyle.FormatterStep$Strict.format(FormatterStep.java:76)
                 at 
com.github.autostyle.Formatter.compute(Formatter.java:204)
                 at 
com.github.autostyle.Formatter.formatOrNull(Formatter.java:171)
                 at 
com.github.autostyle.ConvergenceAnalyzer.analyze(ConvergenceAnalyzer.kt:45)
                 at 
com.github.autostyle.gradle.AutostyleTask.formatFiles(AutostyleTask.kt:118)
                 at 
com.github.autostyle.gradle.AutostyleTask.run(AutostyleTask.kt:107)

Is a autostyle bug/missing behavior or just need to update autostyle?

Milamber

Re: com.github.autostyle.FormatterException: Error while formatting

Posted by Vladimir Sitnikov <si...@gmail.com>.
Apparently,
googlejavaformat.java.RemoveUnusedImports
 is not able to parse Java 17. I'm not sure if it can be resolved with
bumping googlejavaformat version.

I am leaning towards using openrewrite for that as it's parser is more
robust.

For now, we could temporary disable import order check. I'm delivering a
talk on 24 April, and I'm going to finish openrewrite integration sometime
later.

Vladimir