question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

filter not working (Kotlin MPP)

See original GitHub issue

I have added the plugin to my Kotlin MPP project using this configuration:

ktlint {
    debug = true
    verbose = true
    android = false
    outputToConsole = true
    outputColorName = "RED"
    ignoreFailures = false
    enableExperimentalRules = true
    disabledRules = ["multiline-if-else"]
    reporters {
        reporter "plain"
        reporter "checkstyle"
    }
    filter {
        exclude("**/generated/**")
    }
}

Yet I am getting failures from files under build/generated like this:

Checking <path_to_project>/build/generated/moko/androidMain/src/<classpath>/MR.kt
Resolving .editorconfig files for <path_to_project>/build/generated/moko/androidMain/src/<classpath>/MR.kt file path
<path_to_project>/build/generated/moko/androidMain/src/<classpath>/MR.kt:3:1: Unnecessary import (no-unused-imports)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
xetra11commented, Oct 17, 2020

@Tapchicoma Sorry after a while I found the FAQ entry for filtering source outside src/main. It’s working with the mentioned workaround now

0reactions
PaulWoitaschekcommented, Jan 27, 2021

If someone is looking for this, a possible solution to filter on mpp projects could look like this:

  configure<KtlintExtension> {
    version.set(Dependencies.ktLintVersion)
    filter {
      exclude { tree ->
        val path = tree.file.path
        listOf(".gradle/", "cache/", "build/generated/").any {
          path.contains(it)
        }
      }
    }
  }
Read more comments on GitHub >

github_iconTop Results From Across the Web

Filtering collections - Kotlin
To filter collections by negative conditions, use filterNot() . It returns a list of elements for which the predicate yields false .
Read more >
Why does chaining .map() and .filter() in Kotlin not work as ...
I am trying to map a list of objects to a list of objects of another type, then filter the list ...
Read more >
Common tests can not be launched from gutter in MPP ...
Common tests can not be launched from gutter in MPP Android/iOS project · Go to app/src/test/java/sample/SampleTestsAndroid. · Go to app/src/commonTest/kotlin/ ...
Read more >
Filtering a List in Kotlin - Baeldung
In the example above, the filterNot() function returns the two elements from the List of countries for which the predicate yields false.
Read more >
Issues · localazy/kotlin-mpp-wininet - GitHub
This project demonstrates how to use the WinInet API in your Kotlin MPP app for simple HTTP communication. - Issues · localazy/kotlin-mpp-wininet.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found