Skip to content

Enforce var vs FullTypeName in java 11 #1532

Open
@nedtwigg

Description

@nedtwigg

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".

// before spotlessApply
String example = "blah";

// after spotlessApply
var example = "blah";
// before spotlessApply
String example = "blah"; // keep type

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

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

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!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions