Repository navigation
Closed
Labels
wontfixIssues that became stale and were auto-closed by a bot.
Description
New Issue Checklist
- Updated SwiftLint to the latest version
- I searched for existing GitHub issues
Describe the bug
At Codacy, we are using SwiftLint to analyse Swift code.
We are trying to use a custom configuration file by passing it to --config param.
If the source code directory contains a .swiftlint.yml file and we run SwiftLint with a custom configuration on 2 or more specific files (by passing them as param to the command), it ignores the custom the configuration and uses .swiftlint.yml file present inside the source code directory.
If I run the same command but specifying only 1 file or a directory with multiple files inside, it uses the custom configuration file we are providing.
Example
As an example, we have a /src folder with the following files:
dynamic_inline.swift- with dynamic_inline violation:
class C {
@inline(__always) dynamic func f() {}
}
class C {
@inline(__always) public dynamic func f() {}
}
class C {
@inline(__always) dynamic internal func f() {}
}
class C {
@inline(__always)
dynamic func f() {}
}
class C {
@inline(__always)
dynamic
func f() {}
}closing_brace.swift- with closing_brace violation:
[].map({ } )
[].map({ } )
.test.ymlfile:
whitelist_rules:
- dynamic_inline
.swiftlint.ymlfile:
whitelist_rules:
- closing_brace
With this source folder, we are making these tests:
- Custom configuration file (
.test.yml) and analysing 1 file - returns the expected result
$ swiftlint lint --config /src/.test.yml /src/dynamic_inline.swift
Loading configuration from '/src/.test.yml'
Linting Swift files at paths /src/dynamic_inline.swift
Linting 'dynamic_inline.swift' (1/1)
/src/dynamic_inline.swift:3:31: error: Dynamic Inline Violation: Avoid using 'dynamic' and '@inline(__always)' together. (dynamic_inline)
/src/dynamic_inline.swift:7:38: error: Dynamic Inline Violation: Avoid using 'dynamic' and '@inline(__always)' together. (dynamic_inline)
/src/dynamic_inline.swift:11:40: error: Dynamic Inline Violation: Avoid using 'dynamic' and '@inline(__always)' together. (dynamic_inline)
/src/dynamic_inline.swift:16:13: error: Dynamic Inline Violation: Avoid using 'dynamic' and '@inline(__always)' together. (dynamic_inline)
/src/dynamic_inline.swift:22:5: error: Dynamic Inline Violation: Avoid using 'dynamic' and '@inline(__always)' together. (dynamic_inline)
Done linting! Found 5 violations, 5 serious in 1 file.- Custom configuration file (
.test.yml) and analysing entire src folder - returns the expected result
$ swiftlint lint --config /src/.test.yml /src/
Loading configuration from '/src/.test.yml'
Linting Swift files at paths /src/dynamic_inline.swift
Linting 'dynamic_inline.swift' (1/1)
/src/dynamic_inline.swift:3:31: error: Dynamic Inline Violation: Avoid using 'dynamic' and '@inline(__always)' together. (dynamic_inline)
/src/dynamic_inline.swift:7:38: error: Dynamic Inline Violation: Avoid using 'dynamic' and '@inline(__always)' together. (dynamic_inline)
/src/dynamic_inline.swift:11:40: error: Dynamic Inline Violation: Avoid using 'dynamic' and '@inline(__always)' together. (dynamic_inline)
/src/dynamic_inline.swift:16:13: error: Dynamic Inline Violation: Avoid using 'dynamic' and '@inline(__always)' together. (dynamic_inline)
/src/dynamic_inline.swift:22:5: error: Dynamic Inline Violation: Avoid using 'dynamic' and '@inline(__always)' together. (dynamic_inline)
Done linting! Found 5 violations, 5 serious in 1 file.- Custom configuration file (
.test.yml) and analysing 2 or more files - returns result different from the expected
$ swiftlint lint --config /src/.test.yml /src/dynamic_inline.swift /src/closing_brace.swift
Loading configuration from '/src/.test.yml'
Linting Swift files at paths /src/dynamic_inline.swift, /src/closing_brace.swift
Linting 'closing_brace.swift' (1/2)
Linting 'dynamic_inline.swift' (2/2)
/src/closing_brace.swift:1:14: warning: Closing Brace Spacing Violation: Closing brace with closing parenthesis should not have any whitespaces in the middle. (closing_brace)
/src/closing_brace.swift:3:14: warning: Closing Brace Spacing Violation: Closing brace with closing parenthesis should not have any whitespaces in the middle. (closing_brace)
Done linting! Found 2 violations, 0 serious in 2 files.Environment
- SwiftLint version: 0.38.2
Metadata
Metadata
Assignees
Labels
wontfixIssues that became stale and were auto-closed by a bot.
Activity
laxmorek commentedon Aug 31, 2020
Problem still occurs in
0.40.1.stale commentedon Nov 8, 2020
This issue has been automatically marked as stale because it has not had any recent activity. Please comment to prevent this issue from being closed. Thank you for your contributions!
sethfri commentedon Nov 9, 2020
@josemiguelmelo @laxmorek Do you mind checking to see if you still see this behavior in 0.41.0? I did some work in this area where we should now always be treating
--configas an explicit override, but I don't think I tested your use case explicitly. Thanks!stale commentedon Jan 8, 2021
This issue has been automatically marked as stale because it has not had any recent activity. Please comment to prevent this issue from being closed. Thank you for your contributions!