palantir-java-format icon indicating copy to clipboard operation
palantir-java-format copied to clipboard

fix `RemoveUnusedImportsStep` leftovers

Open Pankraz76 opened this issue 8 months ago • 6 comments

depends on:

  • https://github.com/diffplug/spotless/pull/2541

ref:

  • https://github.com/google/google-java-format/pull/1262

fix #1261

implementation fixed by reliable contributor @iddeepak

Thanks for this initiative.

  • https://github.com/google/google-java-format/pull/1262
  • https://github.com/google/google-java-format/pull/1262#issuecomment-3014695342

before: 14 issues:

image

now: 10 issues:

image

Pankraz76 avatar Jun 29 '25 09:06 Pankraz76

Thanks for your interest in palantir/palantir-java-format, @Pankraz76! Before we can accept your pull request, you need to sign our contributor license agreement - just visit https://cla.palantir.com/ and follow the instructions. Once you sign, I'll automatically update this pull request.

palantirtech avatar Jun 29 '25 09:06 palantirtech

Generate changelog in changelog/@unreleased

Type (Select exactly one)

  • [ ] Feature (Adding new functionality)
  • [ ] Improvement (Improving existing functionality)
  • [ ] Fix (Fixing an issue with existing functionality)
  • [ ] Break (Creating a new major version by breaking public APIs)
  • [ ] Deprecation (Removing functionality in a non-breaking way)
  • [ ] Migration (Automatically moving data/functionality to a new system)

Description RemoveUnusedImportsTest

Check the box to generate changelog(s)

  • [ ] Generate changelog entry

changelog-app[bot] avatar Jun 29 '25 09:06 changelog-app[bot]

https://github.com/palantir/palantir-java-format/blob/f537f78e6fc8697e18ce05fa5b95f2cddc0b5e9f/palantir-java-format/src/main/java/com/palantir/javaformat/java/RemoveUnusedImports.java#L348 fixedRanges is not used ? @Pankraz76

iddeepak avatar Jul 02 '25 18:07 iddeepak

fixedRanges is not used ? @Pankraz76

as no (mutation) test coverage imposed, of course not. Whole branch makes no sense in this case:

  • https://github.com/palantir/palantir-java-format/blob/f537f78e6fc8697e18ce05fa5b95f2cddc0b5e9f/palantir-java-format/src/main/java/com/palantir/javaformat/java/RemoveUnusedImports.java#L363

Good catch!

Pankraz76 avatar Jul 03 '25 10:07 Pankraz76

issue: formattingWithoutImportOrdering() com.palantir.javaformat.java.FormatterTest

Pankraz76 avatar Jul 04 '25 09:07 Pankraz76

fixes empty line issue, added this test case to import tests as well, as important. Good that we have tests.

Pankraz76 avatar Jul 04 '25 10:07 Pankraz76