e

    Eric

    6 months ago
    formatting is completely mangling a few files, seems to be related to Mockk lambdas, maybe. Is there a way to just turn off formatting completely for a file? I tried
    // ktlint-disable
    just after the package declaration, but that didn’t work
    e

    Endre Deak

    6 months ago
    you should be able to exclude files for a gradle task
    I made this for myself:
    # build.gradle.kts
    
    val excludeFilesFromFormatChecking = listOf("fileToExclude1", "fileToExclude2", "...")
    
    tasks.withType<FormatTask> { exclude { f -> excludeFilesFromFormatChecking.any { p -> f.name.contains(p) } } }
    tasks.withType<LintTask> { exclude { f -> excludeFilesFromFormatChecking.any { p -> f.name.contains(p) } } }
    tasks.withType<Detekt> { exclude { f -> excludeFilesFromFormatChecking.any { p -> f.name.contains(p) } } }
    I use the
    kotlinter
    plugin
    e

    Eric

    6 months ago
    if i run ktlint on the file directly, it does not mangle it
    it is definitely the mockk lambdas messing up the formatting. the mangling for each file starts in a block like this:
    it is the indentation rule. i can suppress w/
    @file:Suppress("Indentation")
    on the test classes that use
    every { … } just runs
    fixed by putting each of those function arguments on a separate line like this:
    every {
        kafkaProducer.synchronousSend(
            Topics.query.sourcing,
            match { it.orderNumber == report.lastOrder().orderNumber },
            capture(producedValue)
        )
    } just Runs
    tried to create a minimal project to reproduce, but couldn’t get it to happen w/ a simple test case