Skip to content

Commit

Permalink
Improve error message (tuist#6377)
Browse files Browse the repository at this point in the history
  • Loading branch information
woin2ee authored Jun 8, 2024
1 parent deac1fd commit 024983a
Show file tree
Hide file tree
Showing 6 changed files with 150 additions and 45 deletions.
6 changes: 3 additions & 3 deletions Sources/TuistGenerator/Linter/ProjectLinter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ class ProjectLinter: ProjectLinting {
}

private func lintTargets(project: Project) -> [LintingIssue] {
var issues: [LintingIssue] = []
issues.append(contentsOf: project.targets.values.flatMap(targetLinter.lint))
return issues
return project.targets.values.flatMap { target in
targetLinter.lint(target: target, options: project.options)
}
}
}
12 changes: 6 additions & 6 deletions Sources/TuistGenerator/Linter/TargetLinter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import TuistSupport
import XcodeGraph

protocol TargetLinting: AnyObject {
func lint(target: Target) -> [LintingIssue]
func lint(target: Target, options: Project.Options) -> [LintingIssue]
}

class TargetLinter: TargetLinting {
Expand All @@ -25,15 +25,15 @@ class TargetLinter: TargetLinting {

// MARK: - TargetLinting

func lint(target: Target) -> [LintingIssue] {
func lint(target: Target, options: Project.Options) -> [LintingIssue] {
var issues: [LintingIssue] = []
issues.append(contentsOf: lintProductName(target: target))
issues.append(contentsOf: lintProductNameBuildSettings(target: target))
issues.append(contentsOf: lintValidPlatformProductCombinations(target: target))
issues.append(contentsOf: lintBundleIdentifier(target: target))
issues.append(contentsOf: lintHasSourceFiles(target: target))
issues.append(contentsOf: lintCopiedFiles(target: target))
issues.append(contentsOf: lintLibraryHasNoResources(target: target))
issues.append(contentsOf: lintLibraryHasNoResources(target: target, options: options))
issues.append(contentsOf: lintDeploymentTarget(target: target))
issues.append(contentsOf: settingsLinter.lint(target: target))
issues.append(contentsOf: lintDuplicateDependency(target: target))
Expand Down Expand Up @@ -220,15 +220,15 @@ class TargetLinter: TargetLinting {
return issues
}

private func lintLibraryHasNoResources(target: Target) -> [LintingIssue] {
private func lintLibraryHasNoResources(target: Target, options: Project.Options) -> [LintingIssue] {
if target.supportsResources {
return []
}

if target.resources.resources.isEmpty == false {
if target.resources.resources.isEmpty == false, options.disableBundleAccessors {
return [
LintingIssue(
reason: "Target \(target.name) cannot contain resources. \(target.product) targets do not support resources",
reason: "Target \(target.name) cannot contain resources. For \(target.product) targets to support resources, 'Bundle Accessors' feature should be enabled.",
severity: .error
),
]
Expand Down
4 changes: 2 additions & 2 deletions Sources/XcodeGraph/Models/Product.swift
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ public enum Product: String, CustomStringConvertible, CaseIterable, Codable {
case .dynamicLibrary:
return "dynamic library"
case .framework:
return "framework"
return "dynamic framework"
case .staticFramework:
return "staticFramework"
return "static framework"
case .unitTests:
return "unit tests"
case .uiTests:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import XcodeGraphTesting
@testable import TuistGenerator

class MockTargetLinter: TargetLinting {
func lint(target _: Target) -> [LintingIssue] {
func lint(target _: Target, options _: Project.Options) -> [LintingIssue] {
[]
}
}
Loading

0 comments on commit 024983a

Please sign in to comment.