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 applied

See original GitHub issue

I set include the following into my buld.gradle:

    ktlint {
        debug = true
        verbose = true
        filter {
            exclude("**/generated/**")
        }
    }

However, the files below generated are STILL checked:

$ ./gradlew ktlintCheck

> Task :nano-container:ktlintMainSourceSetCheck FAILED
[DEBUG] Discovered ruleset "standard"
[DEBUG] Discovered reporter "plain"
[DEBUG] Discovered reporter "json"
[DEBUG] Discovered reporter "checkstyle"
[DEBUG] Initializing "plain" reporter with {verbose=true, color=true}
[DEBUG] Initializing "plain" reporter with {verbose=true, color=true}, output=XXX/nano-container/build/reports/ktlint/ktlintMainSourceSetCheck.txt
[DEBUG] Checking XXX/nano-container/build/generated/source/BuildInfo.kt
...
[DEBUG] Discovered .editorconfig (XXX) {indent_size=2}
XXX/nano-container/build/generated/source/BuildInfo.kt:1:1: Wildcard import (cannot be auto-corrected) (no-wildcard-imports)
XXX/nano-container/build/generated/source/BuildInfo.kt:246:14: Missing spacing before "=" (op-spacing)
"plain" report written to XXX/nano-container/build/reports/ktlint/ktlintMainSourceSetCheck.txt
[DEBUG] 879ms / 6 file(s) / 2 error(s)

The file XXX/nano-container/build/generated/source/BuildInfo.kt should have been ignored.

 ./gradlew --version

------------------------------------------------------------
Gradle 5.2.1
------------------------------------------------------------

Build time:   2019-02-08 19:00:10 UTC
Revision:     f02764e074c32ee8851a4e1877dd1fea8ffb7183

Kotlin DSL:   1.1.3
Kotlin:       1.3.20
Groovy:       2.5.4
Ant:          Apache Ant(TM) version 1.9.13 compiled on July 10 2018
JVM:          1.8.0_191 (Oracle Corporation 25.191-b12)
OS:           Linux 4.15.0-46-generic amd64

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5

github_iconTop GitHub Comments

3reactions
derolfcommented, Apr 8, 2019

Okay, I think I found the underlying issue.

Actually, BuildInfo.kt sits at build/generated/source/BuildInfo.kt and is added to the build via:

sourceSets.main.java.srcDir new File(buildDir, 'generated/source/')

But, if I do …

        filter {
            exclude({println(it.path)})
        }

… it just prints BuildInfo.kt, so the prefix is stripped from the filename. I guess that string-patterns are applied to the stripped and not absolute path.

Here is the workaround:

    ktlint {
        filter {
            exclude({it.file.absolutePath.contains("/generated/")})
        }
    }

However that will kick in if there is any “/generated/” in the full path.

1reaction
derolfcommented, Apr 8, 2019
    ktlint {
        filter {
            exclude({projectDir.toURI().relativize(it.file.toURI()).path.contains("/generated/")})
        }
    }

This will exclude all files in the project that have /generated/ in their path relative to the project directory. Worth adding to README?

Read more comments on GitHub >

github_iconTop Results From Across the Web

5 Reasons why your Excel filter may not be working
5 Reasons why your Excel filter may not be working · 1. Check that you have selected all of the data · 2....
Read more >
Excel Filter Not Working? Try These Fixes - Tech News Today
How to Fix Excel Filter Not Working? · Select All Data From Sheet · Remove Blank Rows/Columns · Unhide Rows or Columns ·...
Read more >
7 Reasons☝️ Why Your Excel Filter May Not Be Working
7 Reasons☝️ Why Your Excel Filter May Not Be Working · 1. Check that you have selected all the data. · 2. Check...
Read more >
Excel filter not working properly [Fixed] - The Windows Club
Excel filter not working properly · 1] Check for error · 2] Select the entire data · 3] Unhide hidden rows and columns...
Read more >
The filter function is not applied to all rows
Hi, I could find previous posts with this problem, but the filter function is not being applied to all rows of a sheet....
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