Skip to content

fix RemoveUnusedImportsStep leftovers #1262

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Pankraz76
Copy link

@Pankraz76 Pankraz76 commented Jun 26, 2025

fix #1261

@iddeepak kindly request your eyes on this.

  • execute and debug some test locally on IDE?
  • maybe work this out?
    • tc exposed some issues
[ERROR] Failures: 
[ERROR]   RemoveUnusedImportsTest.removeUnused:485 value of:
    removeUnusedImports(...)
expected:
    interface Test { private static void foo() {} }
    
    
but was:
    import java.lang.Foo;
    interface Test { private static void foo() {} }
    
    
[ERROR]   RemoveUnusedImportsTest.removeUnused:485 value of:
    removeUnusedImports(...)
expected:
    …pkg.Constants.FOO;
    
    public class Test …
but was:
    …pkg.Constants.FOO;
    
    
    public class Test …
[ERROR]   RemoveUnusedImportsTest.removeUnused:485 value of:
    removeUnusedImports(...)
diff (-expected +actual):
    @@ -1,3 +1,4 @@
    +import static java.util.Collections.*;
     import static java.util.Collections.emptyList;
     
     class Test {
[ERROR]   RemoveUnusedImportsTest.removeUnused:485 value of:
    removeUnusedImports(...)
expected:
    class Test {
      java.…
but was:
    
    class Test {
      java.…
[ERROR]   RemoveUnusedImportsTest.removeUnused:485 value of:
    removeUnusedImports(...)
diff (-expected +actual):
    @@ -1,3 +1,4 @@
    +import static java.lang.Math.*;
     import static java.lang.Math.PI;
     
     class Test {
[ERROR]   RemoveUnusedImportsTest.removeUnused:485 value of:
    removeUnusedImports(...)
expected:
    // This is a comment mentioning ArrayList
    class Test {}
    
    
but was:
    
    // This is a comment mentioning ArrayList
    class Test {}
    
    
[ERROR]   RemoveUnusedImportsTest.removeUnused:485 value of:
    removeUnusedImports(...)
diff (-expected +actual):
    @@ -1,5 +1,6 @@
     package com.foo;
     import static com.foo.Outer.A;
    +import com.foo.*;
     import com.foo.B;
     import com.bar.C;
     class Test {
[INFO] 
[ERROR] Tests run: 1580, Failures: 7, Errors: 0, Skipped: 0

Copy link

google-cla bot commented Jun 26, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Copy link
Author

@Pankraz76 Pankraz76 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WIP

@Pankraz76 Pankraz76 force-pushed the fix-fix-blindspot-on-`RemoveUnusedImportsStep` branch 3 times, most recently from 33f45fd to 91080e2 Compare June 26, 2025 12:42
@Pankraz76 Pankraz76 marked this pull request as ready for review June 26, 2025 12:42
@Pankraz76 Pankraz76 force-pushed the fix-fix-blindspot-on-`RemoveUnusedImportsStep` branch from 91080e2 to 05caad3 Compare June 26, 2025 12:43
@iddeepak iddeepak mentioned this pull request Jun 28, 2025
@iddeepak
Copy link

@Pankraz76
I have pushed a few small tweaks—feel free to pull them into your branch and let me know what you think or if anything needs further adjustment PR #1266
Thank you!

@Pankraz76 Pankraz76 changed the title blindspot on RemoveUnusedImportsStep fix RemoveUnusedImportsStep leftovers Jun 28, 2025
@Pankraz76 Pankraz76 force-pushed the fix-fix-blindspot-on-`RemoveUnusedImportsStep` branch from 05caad3 to cf8220e Compare June 28, 2025 12:50
@@ -6,7 +6,6 @@ import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

import java.util.List;

Copy link
Author

@Pankraz76 Pankraz76 Jun 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems to be an issue now imposed by the new fixes done by me.

@Pankraz76 Pankraz76 force-pushed the fix-fix-blindspot-on-`RemoveUnusedImportsStep` branch from cf8220e to 8e6d995 Compare June 28, 2025 13:26
"import $1" + sep + sep);

// Remove multiple blank lines elsewhere in imports section
s = s.replaceAll("(?m)^import .+" + sep + "\\s+" + sep + "(?=import)", "import $1" + sep);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

items:

so the formatter test failing on the previous version is fixed now, but still failing other tests as well.

At least only related to the class, except of the IndexOutOfBounds.

[ERROR] Failures: 
[ERROR]   RemoveUnusedImportsTest.removeUnused:577 value of:
    removeUnusedImports(...)
diff (-expected +actual):
    @@ -1,5 +1,4 @@
     package p;
    -import java.lang.Foo;
     import java.lang.Foo.Bar;
     import p.Baz;
     import p.Baz.Bork;
[ERROR]   RemoveUnusedImportsTest.removeUnused:577 value of:
    removeUnusedImports(...)
expected:
    …pkg.Constants.FOO;
    
    public class Test …
but was:
    …pkg.Constants.FOO;
    
    
    public class Test …
[ERROR]   RemoveUnusedImportsTest.removeUnused:577 value of:
    removeUnusedImports(...)
expected:
    class Test {
      java.…
but was:
    
    class Test {
      java.…
[ERROR] Errors: 
[ERROR]   MainTest.optimizeImportsDoesNotLeaveEmptyLines:246 » IndexOutOfBounds No group...
[INFO] 
[ERROR] Tests run: 1580, Failures: 3, Errors: 1, Skipped: 0

@Pankraz76 Pankraz76 force-pushed the fix-fix-blindspot-on-`RemoveUnusedImportsStep` branch from 8e6d995 to 87ae466 Compare June 28, 2025 13:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

blindspot on RemoveUnusedImportsStep
2 participants