palantir / palantir/palantir-java-format

IntelliJ palantir-java-format plugin doesn't organize imports

Open
#1,352 4 comments 24 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
907
Forks
101
Avg merge
1d 3h
Merged PRs (30d)
19

Description

My team is attempting to utilize the palantir java formatter in conjunction with Gradle and Spotless. Executing ./gradlew spotlessApply works great, and formats our files as expected.

Additionally, we've installed the palantir-java-format IntelliJ plugin which auto-formats my Java files on save so that we don't need to manually execute spotlessApply prior to every commit. The plugin executes the palantir formatter on save, however we've found that it doesn't organize imports or remove unused imports.

Checking the File | Settings | Tools | Actions on Save | Optimize imports checkbox does appear to organize our imports, but it doesn't respect the palantir import structure, and seems to instead utilize IntelliJ's code style import config. This appears to be the opposite behavior from the Reformat code checkbox which ignores the IntelliJ code style config, and forces the palantir formatter.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by examining the IntelliJ plugin's Actions on Save integration and how it handles Optimize imports versus Reformat code. Reproduce the behavior with IntelliJ and the Gradle/Spotless setup described in the issue. Done means save-time formatting also organizes imports and removes unused imports while respecting the Palantir import structure.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
developer-experience, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.