diffplug / diffplug/spotless

Enforce `var` vs `FullTypeName` in java 11

Open
#1,532 5 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Java
Stars
5.6k
Forks
559
Avg merge
1d 13h
Merged PRs (30d)
34

Description

The informal Spotless styleguide has been "any style that matters is enforced by spotlessApply". Now that we're compiling against Java 11 world, there's a big new degree of freedom, which is when to use `var` or not.

I'd like to adopt a style which is "you must always use var, unless the line has a comment".

```java
// before spotlessApply
String example = "blah";

// after spotlessApply
var example = "blah";
```

```java
// before spotlessApply
String example = "blah"; // keep type

// after spotlessApply
String example = "blah"; // keep type
```

I'd like it to be a discrete step, ala

```java
spotless { java {
gjf() // or whatever the user is currently using
alwaysUseVarUnlessCommented()
} }
```

But if there's a way to configure an existing formatter, GJF, palantir-java-format, or eclipse, that would work too.

Suggestions and PRs welcome!

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.