palantir / palantir/palantir-java-format
crash on white space in import statements
Open
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 907
- Forks
- 101
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 19
Description
What happened?
case a
import java. util.*;
results in
com.palantir.javaformat.java.FormatterException: error: Could not parse imported name, at:
at com.palantir.javaformat.java.ImportOrderer.scanImported (ImportOrderer.java:417)
case b
import java .util.*;
results in
com.palantir.javaformat.java.FormatterException: error: Expected ; after import
at com.palantir.javaformat.java.ImportOrderer.scanImports (ImportOrderer.java:321)
What did you want to happen?
Should not crash and instead should remove the extra white space, resulting in:
import java.util.*;
env details
<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
<version>2.43.0</version>
<configuration>
<java>
<importOrder />
<removeUnusedImports />
<trimTrailingWhitespace />
<endWithNewline />
<indent>
<spaces>true</spaces>
<spacesPerTab>4</spacesPerTab>
</indent>
<palantirJavaFormat />
</java>
</configuration>
</plugin>
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in ImportOrderer.java at scanImported (around line 417) and scanImports (around line 321), using the two import examples as reproductions. Verify the formatter handles whitespace around the dot and produces import java.util.*; without a FormatterException.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100