New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add linting for mismatching build configurations in a workspace #474
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,7 @@ class GraphLinter: GraphLinting { | |
var issues: [LintingIssue] = [] | ||
issues.append(contentsOf: graph.projects.flatMap(projectLinter.lint)) | ||
issues.append(contentsOf: lintDependencies(graph: graph)) | ||
issues.append(contentsOf: lintMismatchingConfigurations(graph: graph)) | ||
return issues | ||
} | ||
|
||
|
@@ -148,6 +149,30 @@ class GraphLinter: GraphLinting { | |
return [issue] | ||
} | ||
|
||
private func lintMismatchingConfigurations(graph: Graphing) -> [LintingIssue] { | ||
let entryNodeProjects = graph.entryNodes.compactMap { $0 as? TargetNode }.map { $0.project } | ||
|
||
let knownConfgiruations = entryNodeProjects.reduce(into: Set()) { | ||
$0.formUnion(Set($1.settings.configurations.keys)) | ||
} | ||
|
||
let projectBuildConfigurations = graph.projects.map { | ||
(name: $0.name, buildConfigurations: Set($0.settings.configurations.keys)) | ||
} | ||
|
||
let mismatchingBuildConfigurations = projectBuildConfigurations.filter { | ||
!knownConfgiruations.isSubset(of: $0.buildConfigurations) | ||
} | ||
|
||
return mismatchingBuildConfigurations.map { | ||
let expectedConfigurations = knownConfgiruations.sorted() | ||
let configurations = $0.buildConfigurations.sorted() | ||
let reason = "The project '\($0.name)' has missing or mismatching configurations. It has \(configurations), other projects have \(expectedConfigurations)" | ||
return LintingIssue(reason: reason, | ||
severity: .warning) | ||
} | ||
} | ||
|
||
struct LintableTarget: Equatable, Hashable { | ||
let platform: Platform | ||
let product: Product | ||
|
@@ -161,11 +186,11 @@ class GraphLinter: GraphLinting { | |
LintableTarget(platform: .iOS, product: .framework), | ||
LintableTarget(platform: .iOS, product: .staticFramework), | ||
LintableTarget(platform: .iOS, product: .bundle), | ||
// LintableTarget(platform: .iOS, product: .appExtension), | ||
// LintableTarget(platform: .iOS, product: .messagesExtension), | ||
// LintableTarget(platform: .iOS, product: .stickerPack), | ||
// LintableTarget(platform: .watchOS, product: .watch2App), | ||
// LintableTarget(platform: .watchOS, product: .watchApp), | ||
// LintableTarget(platform: .iOS, product: .appExtension), | ||
// LintableTarget(platform: .iOS, product: .messagesExtension), | ||
// LintableTarget(platform: .iOS, product: .stickerPack), | ||
// LintableTarget(platform: .watchOS, product: .watch2App), | ||
// LintableTarget(platform: .watchOS, product: .watchApp), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just double check you're happy with this new alignment, I think by formatting the file it's indented them by accident. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it was swiftformat - will push a revert, hopefully won't get flagged as an unformatted PR π€ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
], | ||
LintableTarget(platform: .iOS, product: .staticLibrary): [ | ||
LintableTarget(platform: .iOS, product: .staticLibrary), | ||
|
@@ -203,33 +228,33 @@ class GraphLinter: GraphLinting { | |
LintableTarget(platform: .iOS, product: .bundle), | ||
], | ||
// LintableTarget(platform: .iOS, product: .appExtension): [ | ||
// LintableTarget(platform: .iOS, product: .staticLibrary), | ||
// LintableTarget(platform: .iOS, product: .dynamicLibrary), | ||
// LintableTarget(platform: .iOS, product: .framework), | ||
// ], | ||
// LintableTarget(platform: .iOS, product: .messagesApplication): [ | ||
// LintableTarget(platform: .iOS, product: .messagesExtension), | ||
// LintableTarget(platform: .iOS, product: .staticLibrary), | ||
// LintableTarget(platform: .iOS, product: .dynamicLibrary), | ||
// LintableTarget(platform: .iOS, product: .framework), | ||
// ], | ||
// LintableTarget(platform: .iOS, product: .messagesExtension): [ | ||
// LintableTarget(platform: .iOS, product: .staticLibrary), | ||
// LintableTarget(platform: .iOS, product: .dynamicLibrary), | ||
// LintableTarget(platform: .iOS, product: .framework), | ||
// ], | ||
// LintableTarget(platform: .iOS, product: .stickerPack): [ | ||
// LintableTarget(platform: .iOS, product: .staticLibrary), | ||
// LintableTarget(platform: .iOS, product: .dynamicLibrary), | ||
// LintableTarget(platform: .iOS, product: .framework), | ||
// ], | ||
// LintableTarget(platform: .iOS, product: .staticLibrary), | ||
// LintableTarget(platform: .iOS, product: .dynamicLibrary), | ||
// LintableTarget(platform: .iOS, product: .framework), | ||
// ], | ||
// LintableTarget(platform: .iOS, product: .messagesApplication): [ | ||
// LintableTarget(platform: .iOS, product: .messagesExtension), | ||
// LintableTarget(platform: .iOS, product: .staticLibrary), | ||
// LintableTarget(platform: .iOS, product: .dynamicLibrary), | ||
// LintableTarget(platform: .iOS, product: .framework), | ||
// ], | ||
// LintableTarget(platform: .iOS, product: .messagesExtension): [ | ||
// LintableTarget(platform: .iOS, product: .staticLibrary), | ||
// LintableTarget(platform: .iOS, product: .dynamicLibrary), | ||
// LintableTarget(platform: .iOS, product: .framework), | ||
// ], | ||
// LintableTarget(platform: .iOS, product: .stickerPack): [ | ||
// LintableTarget(platform: .iOS, product: .staticLibrary), | ||
// LintableTarget(platform: .iOS, product: .dynamicLibrary), | ||
// LintableTarget(platform: .iOS, product: .framework), | ||
// ], | ||
// macOS | ||
LintableTarget(platform: .macOS, product: .app): [ | ||
LintableTarget(platform: .macOS, product: .staticLibrary), | ||
LintableTarget(platform: .macOS, product: .dynamicLibrary), | ||
LintableTarget(platform: .macOS, product: .framework), | ||
LintableTarget(platform: .iOS, product: .staticFramework), | ||
// LintableTarget(platform: .macOS, product: .appExtension), | ||
// LintableTarget(platform: .macOS, product: .appExtension), | ||
], | ||
LintableTarget(platform: .macOS, product: .staticLibrary): [ | ||
LintableTarget(platform: .macOS, product: .staticLibrary), | ||
|
@@ -264,17 +289,17 @@ class GraphLinter: GraphLinting { | |
LintableTarget(platform: .iOS, product: .staticFramework), | ||
], | ||
// LintableTarget(platform: .macOS, product: .appExtension): [ | ||
// LintableTarget(platform: .macOS, product: .staticLibrary), | ||
// LintableTarget(platform: .macOS, product: .dynamicLibrary), | ||
// LintableTarget(platform: .macOS, product: .framework), | ||
// ], | ||
// LintableTarget(platform: .macOS, product: .staticLibrary), | ||
// LintableTarget(platform: .macOS, product: .dynamicLibrary), | ||
// LintableTarget(platform: .macOS, product: .framework), | ||
// ], | ||
// tvOS | ||
LintableTarget(platform: .tvOS, product: .app): [ | ||
LintableTarget(platform: .tvOS, product: .staticLibrary), | ||
LintableTarget(platform: .tvOS, product: .dynamicLibrary), | ||
LintableTarget(platform: .tvOS, product: .framework), | ||
LintableTarget(platform: .iOS, product: .staticFramework), | ||
// LintableTarget(platform: .tvOS, product: .tvExtension), | ||
// LintableTarget(platform: .tvOS, product: .tvExtension), | ||
], | ||
LintableTarget(platform: .tvOS, product: .staticLibrary): [ | ||
LintableTarget(platform: .tvOS, product: .staticLibrary), | ||
|
@@ -299,42 +324,42 @@ class GraphLinter: GraphLinting { | |
LintableTarget(platform: .tvOS, product: .framework), | ||
LintableTarget(platform: .iOS, product: .staticFramework), | ||
], | ||
// LintableTarget(platform: .tvOS, product: .tvExtension): [ | ||
// LintableTarget(platform: .tvOS, product: .staticLibrary), | ||
// LintableTarget(platform: .tvOS, product: .dynamicLibrary), | ||
// LintableTarget(platform: .tvOS, product: .framework), | ||
// ], | ||
// LintableTarget(platform: .tvOS, product: .tvExtension): [ | ||
// LintableTarget(platform: .tvOS, product: .staticLibrary), | ||
// LintableTarget(platform: .tvOS, product: .dynamicLibrary), | ||
// LintableTarget(platform: .tvOS, product: .framework), | ||
// ], | ||
// watchOS | ||
// LintableTarget(platform: .watchOS, product: .watchApp): [ | ||
// LintableTarget(platform: .watchOS, product: .staticLibrary), | ||
// LintableTarget(platform: .watchOS, product: .dynamicLibrary), | ||
// LintableTarget(platform: .watchOS, product: .framework), | ||
// LintableTarget(platform: .watchOS, product: .watchExtension), | ||
// ], | ||
// LintableTarget(platform: .watchOS, product: .watch2App): [ | ||
// LintableTarget(platform: .watchOS, product: .staticLibrary), | ||
// LintableTarget(platform: .watchOS, product: .dynamicLibrary), | ||
// LintableTarget(platform: .watchOS, product: .framework), | ||
// LintableTarget(platform: .watchOS, product: .watch2Extension), | ||
// ], | ||
// LintableTarget(platform: .watchOS, product: .staticLibrary): [ | ||
// LintableTarget(platform: .watchOS, product: .staticLibrary), | ||
// ], | ||
// LintableTarget(platform: .watchOS, product: .dynamicLibrary): [ | ||
// LintableTarget(platform: .watchOS, product: .dynamicLibrary), | ||
// ], | ||
// LintableTarget(platform: .watchOS, product: .framework): [ | ||
// LintableTarget(platform: .watchOS, product: .framework), | ||
// ], | ||
// LintableTarget(platform: .watchOS, product: .watchExtension): [ | ||
// LintableTarget(platform: .watchOS, product: .staticLibrary), | ||
// LintableTarget(platform: .watchOS, product: .dynamicLibrary), | ||
// LintableTarget(platform: .watchOS, product: .framework), | ||
// ], | ||
// LintableTarget(platform: .watchOS, product: .watch2Extension): [ | ||
// LintableTarget(platform: .watchOS, product: .staticLibrary), | ||
// LintableTarget(platform: .watchOS, product: .dynamicLibrary), | ||
// LintableTarget(platform: .watchOS, product: .framework), | ||
// ], | ||
// LintableTarget(platform: .watchOS, product: .watchApp): [ | ||
// LintableTarget(platform: .watchOS, product: .staticLibrary), | ||
// LintableTarget(platform: .watchOS, product: .dynamicLibrary), | ||
// LintableTarget(platform: .watchOS, product: .framework), | ||
// LintableTarget(platform: .watchOS, product: .watchExtension), | ||
// ], | ||
// LintableTarget(platform: .watchOS, product: .watch2App): [ | ||
// LintableTarget(platform: .watchOS, product: .staticLibrary), | ||
// LintableTarget(platform: .watchOS, product: .dynamicLibrary), | ||
// LintableTarget(platform: .watchOS, product: .framework), | ||
// LintableTarget(platform: .watchOS, product: .watch2Extension), | ||
// ], | ||
// LintableTarget(platform: .watchOS, product: .staticLibrary): [ | ||
// LintableTarget(platform: .watchOS, product: .staticLibrary), | ||
// ], | ||
// LintableTarget(platform: .watchOS, product: .dynamicLibrary): [ | ||
// LintableTarget(platform: .watchOS, product: .dynamicLibrary), | ||
// ], | ||
// LintableTarget(platform: .watchOS, product: .framework): [ | ||
// LintableTarget(platform: .watchOS, product: .framework), | ||
// ], | ||
// LintableTarget(platform: .watchOS, product: .watchExtension): [ | ||
// LintableTarget(platform: .watchOS, product: .staticLibrary), | ||
// LintableTarget(platform: .watchOS, product: .dynamicLibrary), | ||
// LintableTarget(platform: .watchOS, product: .framework), | ||
// ], | ||
// LintableTarget(platform: .watchOS, product: .watch2Extension): [ | ||
// LintableTarget(platform: .watchOS, product: .staticLibrary), | ||
// LintableTarget(platform: .watchOS, product: .dynamicLibrary), | ||
// LintableTarget(platform: .watchOS, product: .framework), | ||
// ], | ||
] | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo: knownConfgiruations