New Issue Checklist
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({ } )
whitelist_rules:
- dynamic_inline
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
New Issue Checklist
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
--configparam.If the source code directory contains a
.swiftlint.ymlfile 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.ymlfile 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
/srcfolder with the following files:dynamic_inline.swift- with dynamic_inline violation:closing_brace.swift- with closing_brace violation:.test.ymlfile:.swiftlint.ymlfile:With this source folder, we are making these tests:
.test.yml) and analysing 1 file - returns the expected result.test.yml) and analysing entire src folder - returns the expected result.test.yml) and analysing 2 or more files - returns result different from the expectedEnvironment