-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c0d4941
commit 866c9d1
Showing
9 changed files
with
472 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import Foundation | ||
|
||
import XcodeProj | ||
|
||
extension PBXProj { | ||
func enumerateBuildConfigurations(_ block: (String, XCConfigurationList) throws -> Void) rethrows { | ||
for target in legacyTargets { | ||
guard let list = target.buildConfigurationList else { continue } | ||
|
||
try block(target.name, list) | ||
} | ||
|
||
for target in nativeTargets { | ||
guard let list = target.buildConfigurationList else { continue } | ||
|
||
try block(target.name, list) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import Foundation | ||
|
||
import XcodeProj | ||
import XCConfig | ||
|
||
/// Detect build settings that are deprecated or no longer functional. | ||
/// | ||
/// This currently runs a superficial check. It does not perform configuration evaluation yet. | ||
struct ValidateBuildSettingsRule { | ||
func run(_ environment: XCLinter.Environment) throws -> [Violation] { | ||
var violations = [Violation]() | ||
|
||
// check top-level | ||
for config in environment.project.pbxproj.buildConfigurations { | ||
violations.append(contentsOf: evaluateTargetSettings("Project", config: config)) | ||
} | ||
|
||
// check targets | ||
environment.project.pbxproj.enumerateBuildConfigurations { name, configList in | ||
for config in configList.buildConfigurations { | ||
violations.append(contentsOf: evaluateTargetSettings(name, config: config)) | ||
} | ||
} | ||
|
||
return violations | ||
} | ||
|
||
func evaluateTargetSettings(_ name: String, config: XCBuildConfiguration) -> [Violation] { | ||
var violations = [Violation]() | ||
|
||
for pair in config.buildSettings { | ||
guard let setting = BuildSetting(rawValue: pair.key) else { continue } | ||
|
||
let status = setting.evaluateValue(pair.value as? String ?? "") | ||
|
||
switch status { | ||
case .deprecated: | ||
violations.append(.init("\(name):\(pair.key) = \(pair.value) is deprecated")) | ||
case .invalid: | ||
violations.append(.init("\(name):\(pair.key) = \(pair.value) is invalid")) | ||
case .valid: | ||
break | ||
} | ||
} | ||
|
||
return violations | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import Foundation | ||
import XCTest | ||
|
||
extension Bundle { | ||
func testDataURL(named: String) throws -> URL { | ||
let bundle = Bundle.module | ||
|
||
let resourceURL = try XCTUnwrap(bundle.resourceURL) | ||
|
||
return resourceURL | ||
.appendingPathComponent("TestData", isDirectory: true) | ||
.appendingPathComponent(named) | ||
.standardizedFileURL | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.