spotless icon indicating copy to clipboard operation
spotless copied to clipboard

setEditorConfigPath caches in memory?

Open TWiStErRob opened this issue 2 years ago • 2 comments

Repro

  1. Setup:

    1. Clone https://github.com/cashapp/paparazzi at d146c97
    2. Apply this patch:
    Patch
    Subject: [PATCH] Sync up spotless.kotlin.ktlint config overrides with .editorconfig and use a single source of truth.
    ---
    Index: .editorconfig
    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
    ===================================================================
    diff --git a/.editorconfig b/.editorconfig
    --- a/.editorconfig	(revision d146c9739e3f434ef0c196061ce66e26ba20bff5)
    +++ b/.editorconfig	(date 1702209972810)
    @@ -5,9 +5,12 @@
     charset = utf-8
     trim_trailing_whitespace = true
     insert_final_newline = true
    +max_line_length = 70
     end_of_line = lf
    
     [*.{kt, kts}]
     ij_kotlin_imports_layout = *,java.**,javax.**,kotlin.**,kotlinx.**,^
    +ij_kotlin_allow_trailing_comma = false
    +ij_kotlin_allow_trailing_comma_on_call_site = false
    
    -ktlint_standard_argument-list-wrapping = disabled
    \ No newline at end of file
    +ktlint_standard_argument-list-wrapping = disabled
    Index: build.gradle
    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
    ===================================================================
    diff --git a/build.gradle b/build.gradle
    --- a/build.gradle	(revision d146c9739e3f434ef0c196061ce66e26ba20bff5)
    +++ b/build.gradle	(date 1702209773198)
    @@ -92,18 +92,7 @@
       spotless {
         kotlin {
           target("src/**/*.kt")
    -      // ktlint doesn't honour .editorconfig yet: https://github.com/diffplug/spotless/issues/142
    -      ktlint(libs.versions.ktlint.get()).editorConfigOverride([
    -        'insert_final_newline': 'true',
    -        'end_of_line': 'lf',
    -        'charset': 'utf-8',
    -        'indent_size': '2',
    -        'trim_trailing_whitespace': 'true',
    -        'ij_kotlin_imports_layout': '*,java.**,javax.**,kotlin.**,kotlinx.**,^',
    -        'ij_kotlin_allow_trailing_comma': 'false',
    -        'ij_kotlin_allow_trailing_comma_on_call_site': 'false',
    -        'ktlint_standard_argument-list-wrapping': 'disabled',
    -      ])
    +      ktlint(libs.versions.ktlint.get()).setEditorConfigPath(rootProject.file(".editorconfig"))
         }
       }
     }
    
    1. gradlew :paparazzi:spotlessKotlin
    2. Should pass without any problems.
  2. Control:

    1. Change .editorconfig by adding max_line_length = 70
    2. gradlew :paparazzi:spotlessKotlin
    3. Should fail with Exceeded max line length (70)
  3. Problem:

    1. Change: max_line_length to 71
    2. gradlew :paparazzi:spotlessKotlin
    3. Expected: fail with Exceeded max line length (71)
      Actual: fail with Exceeded max line length (70)
  4. Investigation

    1. gradlew --stop
    2. gradlew :paparazzi:spotlessKotlin
    3. Now it fails with Exceeded max line length (71)

Spotless version: 6.23.3 ktlint version: 0.50.0 (but I think it's the same with 1.0, because I'm trying to update to that versions and couldn't figure out why it wasn't doing what I tell it to.) Gradle version: 8.5 OS: Windows 10

TWiStErRob avatar Dec 10 '23 12:12 TWiStErRob

May related to #1924.

Goooler avatar Dec 10 '23 13:12 Goooler

Yeah, looks like a dupe. "Disable rule" vs "edit random line" is the same thing.

TWiStErRob avatar Dec 10 '23 14:12 TWiStErRob

Duplicate of #1924

Goooler avatar Feb 27 '24 10:02 Goooler