Skip to content

Commit

Permalink
Fix finding the 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 15, 2020
1 parent d9ce579 commit beb232d
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 3 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 the nested config when a single file path is passed.
[Seth Friedman](https://github.com/sethfri)

## 0.40.2: Demo Unit

Expand Down
9 changes: 9 additions & 0 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@
"version": "0.17.0"
}
},
{
"package": "CryptoSwift",
"repositoryURL": "https://github.com/krzyzanowskim/CryptoSwift.git",
"state": {
"branch": null,
"revision": "3a2acbb32ab68215ee1596ee6004da8e90c3721b",
"version": "1.0.0"
}
},
{
"package": "Nimble",
"repositoryURL": "https://github.com/Quick/Nimble.git",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ extension Configuration {
}

private func configuration(forPath path: String) -> Configuration {
if path == rootDirectory {
if path == rootDirectory && configurationPath != nil {
return self
}

Expand Down
3 changes: 2 additions & 1 deletion Tests/LinuxMain.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Generated using Sourcery 0.17.0 — https://github.com/krzysztofzablocki/Sourcery
// Generated using Sourcery 1.0.0 — https://github.com/krzysztofzablocki/Sourcery
// DO NOT EDIT

@testable import SwiftLintFrameworkTests
Expand Down Expand Up @@ -196,6 +196,7 @@ extension ConfigurationTests {
("testCustomConfiguration", testCustomConfiguration),
("testConfigurationWithSwiftFileAsRoot", testConfigurationWithSwiftFileAsRoot),
("testConfigurationWithSwiftFileAsRootAndCustomConfiguration", testConfigurationWithSwiftFileAsRootAndCustomConfiguration),
("testConfigurationWithSwiftFileAsRootAndNestedConfiguration", testConfigurationWithSwiftFileAsRootAndNestedConfiguration),
("testIndentationTabs", testIndentationTabs),
("testIndentationSpaces", testIndentationSpaces),
("testIndentationFallback", testIndentationFallback),
Expand Down
11 changes: 11 additions & 0 deletions Tests/SwiftLintFrameworkTests/ConfigurationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,17 @@ class ConfigurationTests: XCTestCase {
XCTAssertEqual(configuration.configuration(for: file), configuration)
}

func testConfigurationWithSwiftFileAsRootAndNestedConfiguration() {
let rootConfiguration = Configuration(path: Configuration.fileName,
rootPath: nil,
optional: true, quiet: true)
let expectedConfiguration = Configuration(path: projectMockYAML2,
rootPath: projectMockSwift2,
optional: true, quiet: true)
let file = SwiftLintFile(path: projectMockSwift2)!
XCTAssertEqual(rootConfiguration.configuration(for: file), expectedConfiguration)
}

// MARK: - Testing custom indentation

func testIndentationTabs() {
Expand Down

0 comments on commit beb232d

Please sign in to comment.