Skip to content

Unexpected behaviour from indentWithSpaces(int) #58

Closed
@jbduncan

Description

@jbduncan

Given the following build script and Java file on Gradle 3.2.1:
build.gradle

plugins {
    id 'java'
    id 'com.diffplug.gradle.spotless' version '2.4.0'
}

group 'org.jbduncan'
version '1.0-SNAPSHOT'

sourceCompatibility = 1.8

repositories {
    mavenCentral()
}

spotless {
    format('example') {
        target '**/*.java'
        indentWithSpaces(4)
    }
}

src/main/java/HelloWorld.java

public final class HelloWorld {
      public String greeting() {
        return "Hello, world!";
    }
}

...I would have expected the Java file to turn into:

public final class HelloWorld {
    public String greeting() {
        return "Hello, world!";
    }
}

or:

public final class HelloWorld {
        public String greeting() {
        return "Hello, world!";
    }
}

...but it seems it doesn't.

Have I misunderstood what indentWithSpaces(4) is supposed to do here? I understand that it turns all tab indents into 4-space indents, but by my intuitive understanding it should also make sure that all space-indents have a number of spaces equal to a multiple of 4.

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