Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gradle Plugin "6.7.2" - indentWithSpaces() is ignored when using googleJavaFormat() #1245

Closed
5 tasks done
hajdukd opened this issue Jun 22, 2022 · 1 comment
Closed
5 tasks done
Labels

Comments

@hajdukd
Copy link

hajdukd commented Jun 22, 2022

If you are submitting a bug, please include the following:

  • summary of problem

Indent is ignored instead of 4 spaces only 2 are applied despite indent being after google format.

  • gradle version - 7.3
  • spotless version - 6.7.2
  • operating system and version - Windows 10
  • copy-paste your full Spotless configuration block(s), and a link to a public git repo that reproduces the problem if possible
spotless {
    format 'misc', {
        // define the files to apply `misc` to
        target '*.gradle', '*.md'
        trimTrailingWhitespace()
        endWithNewline()
    }
    java {
        removeUnusedImports()
        googleJavaFormat('1.15.0')
        indentWithSpaces()
        endWithNewline()
        licenseHeader '/* Copyright (C) $YEAR - All Rights Reserved */'
    }
}
@nedtwigg
Copy link
Member

The unintuitive thing here is that indentWithSpaces just find-replaces \t with n spaces. And indentWithTabs just find-replaces n spaces with a \t. The only semi-smart stuff is checking for the beginning of lines and some multiline comment stuff.

GJF indents with 2-spaces, correct? The solution for your case is:

googleJavaFormat()
indentWithTabs(2)
indentWithSpaces(4)

That is confusing, I agree. Hopefully someday we'll get a PR to rename these methods and end the confusion once and for all!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants