google / google/styleguide

Java style for Eclipse formats imports incorrectly

Open
#273 6 comments 3 reactions 0 assignees View on GitHub
lang:java
Dominant language
HTML
Stars
39.6k
Forks
12.9k
Avg merge
42m
Merged PRs (30d)
15

Description

From https://google.github.io/styleguide/javaguide.html#s3.3.3-import-ordering-and-spacing:

>If there are both static and non-static imports, a single blank line separates the two blocks.

Now, all imports are in a single block:

```
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import java.net.URI;
import java.util.Collections;
import org.eclipse.core.runtime.CoreException;
import org.junit.Test;
```

Empty line should be left between static and non-static imports, so it should be like this:
```
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;

import java.net.URI;
import java.util.Collections;
import org.eclipse.core.runtime.CoreException;
import org.junit.Test;
```

This formatting is done by this line in config:
```

```

The problem is that Eclipse doesn't seem to support custom spacing between static and non-static groups.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.