Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Excluded paths in nested configurations seem to resolve to invalid paths #4765

Open
2 tasks done
dahlborn opened this issue Feb 13, 2023 · 3 comments
Open
2 tasks done
Labels
bug Unexpected and reproducible misbehavior. integration Issues related to integration of SwiftLint into toolchains.

Comments

@dahlborn
Copy link
Contributor

dahlborn commented Feb 13, 2023

New Issue Checklist

Describe the bug

Exluded paths in nested configurations currently do not seem to work.

Environment

  • SwiftLint version (run swiftlint version to be sure)? 50.3
  • Installation method used (Homebrew, CocoaPods, building from source, etc)? Building from source and using Homebrew
  • Paste your configuration file:
allow_zero_lintable_files: true
  • Are you using nested configurations? Yes
    If so, paste their relative paths and respective contents. -> See below
  • Which Xcode version are you using (check xcodebuild -version)? 14.1
  • Do you have a sample that shows the issue?

I created a small Test:

TestFolder
├── .swiftlint.yml
└── SubFolder
    ├── .swiftlint.yml
    └── testFile.swift

yml at TestFolder/.swiftlint.yml

allow_zero_lintable_files: true

yml at TestFolder/SubFolder/.swiflint.yml

disabled_rules:
    - nesting

excluded:
    - testFile.swift

allow_zero_lintable_files: true

Contents of testFile.swift:

import Foundation

struct TestStruct {
    let a = 1
    let b = 2

    struct Nested {
        let c = 3

        struct Nested {
            let d = 4
        }
    }
}

The result being that if SwiftLint is run in TestFolder the file does not get excluded but if it is run in SubFolder it is excluded

I used the debugger with the current master and the excluded paths for the child resolve to TestFolder/SubFolder/SubFolder/testFile.swift instead of TestFolder/SubFolder/testFile.swift which causes the file to not be skipped in Configuration+CommandLine groupFiles. But I don't know if this is caused by a code issue or user error on my side.

@netbe
Copy link

netbe commented Jun 28, 2023

+1 on this

From what I get of the readme documentation. Running swiftlint on root directory should work.

› swiftlint                                                                                                                                                    
Linting Swift files in current working directory
Linting 'testFile.swift' (1/1)
/tmp/TestFolder/SubFolder/testFile.swift:4:5: error: Identifier Name Violation: Variable name 'a' should be between 3 and 40 characters long (identifier_name)
/tmp/TestFolder/SubFolder/testFile.swift:5:5: error: Identifier Name Violation: Variable name 'b' should be between 3 and 40 characters long (identifier_name)
/tmp/TestFolder/SubFolder/testFile.swift:8:9: error: Identifier Name Violation: Variable name 'c' should be between 3 and 40 characters long (identifier_name)
/tmp/TestFolder/SubFolder/testFile.swift:11:13: error: Identifier Name Violation: Variable name 'd' should be between 3 and 40 characters long (identifier_name)
Done linting! Found 4 violations, 4 serious in 1 file.

Note that doing: swiftlint --config .swiftlint.yml --config SubFolder/.swiftlint.yml
is a workaround and works.

› swiftlint --config .swiftlint.yml --config SubFolder/.swiftlint.yml                                                                                             
Linting Swift files in current working directory
Done linting! Found 0 violations, 0 serious in 0 files.

@Mordil
Copy link

Mordil commented Aug 4, 2023

This does not help those using SwiftLint as a plugin

@SimplyDanny SimplyDanny added bug Unexpected and reproducible misbehavior. integration Issues related to integration of SwiftLint into toolchains. labels Aug 5, 2023
@yehe01
Copy link

yehe01 commented Apr 8, 2024

Same issue in 0.53.0. I tried exactly the same directory structure as per issue #2447 . The issue has been marked as resolved. I guess it's reappearing again?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Unexpected and reproducible misbehavior. integration Issues related to integration of SwiftLint into toolchains.
Projects
None yet
Development

No branches or pull requests

5 participants