diffplug / diffplug/spotless

take toggleOffOn into account for linters

Offen
#719 3 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
enhancement
Vorherrschende Sprache
Java
Sterne
5.6k
Forks
559
Ø Merge
1 T. 14 Std.
Gemergte PRs (30 T.)
43

Beschreibung

First of all, I'm expecting a solution to this to be something extremely obvious but here it is.
Spotless setup in the project looks like this:
```
apply plugin: "com.diffplug.spotless"

spotless {

ext.targetBranch = "develop"
if (project.hasProperty('target_branch') && project.getProperty('target_branch')?.trim()) {
targetBranch = project.getProperty('target_branch')
}

ratchetFrom "origin/$targetBranch"

kotlin {
target '**/*.kt'
trimTrailingWhitespace()
indentWithSpaces()
toggleOffOn('format:off', 'format:on')

ktlint().userData([
'max_line_length': '120',
'disabled_rules' : 'import-ordering' //https://github.com/pinterest/ktlint/issues/527, https://youtrack.jetbrains.com/issue/KT-10974
])
}
}
```

The problem occurs when trying to exclude a part of the code using `spotless:off` and `spotless:on`
I also tried (as seen in the snippet above) with different tags but running `./gradlew spotlessCheck` still fails.

The part where it fails looks something like this:
```

// format:off
private fun functionName(): ReturnType = when (this) {
// A bunch of stuff, one line is >120 chars, our line limit
}
// format:on

```
Reason for failure:
```
java.lang.AssertionError: Error on line: 70, column: 1
Exceeded max line length (120)
```

What is it that I'm missing here?

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Beginne damit, den Fehler mit ./gradlew spotlessCheck unter Verwendung der in der Issue gezeigten Kotlin Spotless-Konfiguration zu reproduzieren. Verfolge, wie toggleOffOn-Markierungen behandelt werden, bevor der ktlint()-Schritt ausgeführt wird, und überprüfe anschließend, dass der markierte Bereich ausgeschlossen wird und der Befehl trotz seiner langen Zeile erfolgreich ist.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
kotlin
Bereich
tooling
Issue-Typ
Bug
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.