Skip to content

Better names for indentWithSpaces and indentWithTabs #794

Closed

Description

@wheelerlaw

So I have this simple groovy formatter just to ensure that all files Groovy and Groovy related files end with newlines and are indented using 4 spaces. However, when I run ./gradlew spotlessApply, files that are indented with 2 spaces are not converted. Here is the block:

spotless {
    format 'groovy', {
        target '*.gradle', 'Jenkinsfile*', '*.groovy'
        indentWithSpaces()
        endWithNewline()
    }
}

I am not using the groovy formatter because I have Jenkins script files that are located outside of source sets. So according to the documentation, this should work, since I have defined the target file name matcher, and the rules I want applied.

Spotless version: 5.10.0
Gradle version: 6.7
Operating system: Fedora 33

Activity

  1. jbduncan commented on Feb 10, 2021

    @jbduncan
    Member

    Ah, that's something with indentWithSpaces() that people get confused about a lot. (I was confused about it in the past too!)

    indentWithSpaces() doesn't translate stuff that already has spaces from e.g. 2 spaces per indent to 4 spaces; it only translates tabs to 4 spaces.

    See @nedtwigg's rationale for this over at #58 (comment). tl;dr: it would clobber spaces in Javadoc comments otherwise.

  2. wheelerlaw commented on Feb 10, 2021

    @wheelerlaw
    Author

    Ah, that's interesting. It should at the very least be renamed to remove the confusion, like tabsToSpaces() or something similar. I can create a PR for it.

  3. nedtwigg commented on Feb 10, 2021

    @nedtwigg
    Member

    leadingTabsToSpaces and leadingSpacesToTabs are better names, good call! Important checklist for the old methods:

    • should keep working
    • be marked as deprecated
    • emit a warning saying something like replace 'foo' with 'bar' in your gradle buildscript
  4. changed the title [-]Simple custom Groovy linter not working[/-] [+]Better names for `indentWithSpaces` and `indentWithTabs`[/+] on Feb 11, 2021
  5. jbduncan commented on Apr 27, 2021

    @jbduncan
    Member

    @wheelerlaw If you're still willing and able to create a PR for this issue, then please feel free to go ahead. :)

  6. self-assigned this
    on Jan 26, 2023
  7. pinned this issue on Jun 5, 2024
  8. PaulNgo-BlueOC commented on Aug 12, 2024

    @PaulNgo-BlueOC

    @jbduncan @wheelerlaw @alexvetter I have the issue that indent does not work with palandir
    #2204
    Did this fix fix the issue? If yes, which config I need to put to my pom.xml? Thanks

  9. unpinned this issue on Aug 25, 2024
  10. added a commit that references this issue on Dec 8, 2024
    1804930
  11. nedtwigg commented on Jan 7, 2025

    @nedtwigg
    Member

    Released in plugin-gradle 7.0.0 and plugin-maven 2.44.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions