spotless icon indicating copy to clipboard operation
spotless copied to clipboard

Formatting inconsistent when both <tabs> and <spaces> indentation rules are present

Open priyaa2760 opened this issue 5 months ago • 2 comments

I'm encountering inconsistent formatting behavior when both blocks — one tabs true and another with spaces true — are defined under the Spotless configuration in a Maven project.

Some Java files are formatted, some are skipped, and others show partial formatting. When I remove one of the two blocks, the behavior becomes consistent. I keep getting this debug log [DEBUG] Spotless will not format an up-to-date file:

<plugin>
        <groupId>com.diffplug.spotless</groupId>
        <artifactId>spotless-maven-plugin</artifactId>
        <version>2.43.0</version>
        <configuration>
          <java>
            <includes>
              <include>src/main/java/**/*.java</include>
              <include>src/test/java/**/*.java</include>
            </includes>
            <trimTrailingWhitespace/>
            <removeUnusedImports/>
            <indent>
              <tabs>true</tabs>
              <spacesPerTab>2</spacesPerTab>
            </indent>
            <indent>
              <spaces>true</spaces>
              <spacesPerTab>4</spacesPerTab>
            </indent>
            <googleJavaFormat>
              <version>1.17.0</version>
            </googleJavaFormat>
          </java>
          <pom>
            <includes>
              <include>pom.xml</include>
            </includes>
            <sortPom>
              <expandEmptyElements>false</expandEmptyElements>
            </sortPom>
          </pom>
          <markdown>
            <excludes>
              <exclude>**/node/**</exclude>
              <exclude>**/node_modules/**</exclude>
            </excludes>
            <includes>
              <include>**/*.md</include>
            </includes>
            <flexmark/>
          </markdown>
        </configuration>
        <executions>
          <execution>
            <goals>
              <goal>check</goal>
            </goals>
            <phase>validate</phase>
          </execution>
        </executions>
      </plugin>

priyaa2760 avatar May 13 '25 09:05 priyaa2760