Skip to content

Commit

Permalink
Fix finding a nested config when a single file path is passed
Browse files Browse the repository at this point in the history
Fixes #3341
  • Loading branch information
sethfri committed Sep 18, 2020
1 parent d9ce579 commit 4a9e1c1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@

#### Bug Fixes

* None.
* Fix finding a nested config when a single file path is passed.
[Seth Friedman](https://github.com/sethfri)

## 0.40.2: Demo Unit

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ extension Configuration {
}

private func configuration(forPath path: String) -> Configuration {
if path == rootDirectory {
let rootConfigurationDirectory = configurationPath?.bridge().deletingLastPathComponent
// We're linting a file in the same directory as the root configuration we've already loaded
if path == rootConfigurationDirectory {
return self
}

Expand Down
8 changes: 8 additions & 0 deletions Tests/SwiftLintFrameworkTests/ConfigurationTests+Nested.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ extension ConfigurationTests {
XCTAssertEqual(projectMockConfig0.merge(with: projectMockConfig3).rootPath, projectMockConfig3.rootPath)
}

func testNestedConfigurationForOnePathPassedIn() {
let config = Configuration(path: projectMockYAML0, rootPath: projectMockSwift3)
XCTAssertEqual(
config.configuration(for: SwiftLintFile(path: projectMockSwift3)!),
config.merge(with: projectMockConfig3)
)
}

func testMergedWarningThreshold() {
func configuration(forWarningThreshold warningThreshold: Int?) -> Configuration {
return Configuration(warningThreshold: warningThreshold,
Expand Down

0 comments on commit 4a9e1c1

Please sign in to comment.