Closed pseandersson closed 6 years ago
There are two different kinds of formatter
Spotless is really just a wrapper around other formatting libraries. Wherever possible, we try to use formatting libraries that change the input, rather than just yelling about it. ktlint
does a mixture of both - sometimes it can fix the problem, sometimes it just yells about it.
In this case, ktlint
has found a formatting error that it can't fix automatically, so you have to fix it yourself. The error message is telling you what you have to do:
Step 'ktlint' found problem in 'app\src\main\java\com\gradleformatter\MainActivity.kt':
Error on line: 8, column: 1
Unexpected indentation (6) (it should be 4)
I agree this is annoying, which is why I prefer to only use rules that can automatically be fixed. You've got three options
ktlint
asking for the formatter to fix these automatically rather than throw an exceptionktlint
to ignore indentation errors, and use a different tool, such as indentWithSpaces(2)
to enforce indentation, although it will not be as powerful as ktlint's indentation rulesThanks I will consider raising a bug in ktlint, they seem to have some issues with the indentation rules.
First time I'm using spotless, and I would see how it would react on indentation erros for kotlin, it throws an exception so I'm not able to run the formatter.
Android-built-tools:3.2.1 Gradle-version: 4.7 Spotless version: 3.1.5 Windows 7
Stacktrace