Skip to content

Commit

Permalink
Removes unneeded fixture & lints the project
Browse files Browse the repository at this point in the history
  • Loading branch information
mustiikhalil committed Mar 16, 2024
1 parent 59db266 commit 30d7b15
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 188 deletions.
15 changes: 6 additions & 9 deletions Sources/TuistLoader/Linter/FilesLinter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,12 @@ public protocol FilesLinting {
}

public class FilesLinter: FilesLinting {

public init() {}


public func lint(project: LoadedWorkspace, convertedProjects: [TuistGraph.Project]) -> [LintingIssue] {
var issues: [LintingIssue] = []
convertedProjects.forEach {
issues.append(contentsOf: lint(project: project.projects[$0.path], convertedProject: $0))
for item in convertedProjects {
issues.append(contentsOf: lint(project: project.projects[item.path], convertedProject: item))
}
return issues
}
Expand All @@ -27,7 +25,7 @@ public class FilesLinter: FilesLinting {
private func lint(project: ProjectDescription.Project?, convertedProject: TuistGraph.Project) -> [LintingIssue] {
guard let project else { return [] }
var issues: [LintingIssue] = []
convertedProject.targets.forEach { target in
for target in convertedProject.targets {
issues.append(contentsOf: lint(project: project, convertedTarget: target))
}
return issues
Expand All @@ -45,7 +43,7 @@ public class FilesLinter: FilesLinting {
guard let fileList else { return [] }
let sourcePaths = fileList.globs.filter { !$0.glob.pathString.isGlobComponent }
var issues: [LintingIssue] = []
sourcePaths.forEach { glob in
for glob in sourcePaths {
if sources.first(where: { $0.path.pathString.contains(glob.glob.pathString) }) == nil {
issues.append(LintingIssue(reason: "No files found at: \(glob.glob.pathString)", severity: .warning))
}
Expand All @@ -61,17 +59,16 @@ public class FilesLinter: FilesLinting {
var issues: [LintingIssue] = []
for resource in resourceList.resources {
switch resource {
case .glob(let pattern, _, _, _):
case let .glob(pattern, _, _, _):
if !pattern.pathString.isGlobComponent, check(resources: resources, path: pattern.pathString) == nil {
issues.append(LintingIssue(reason: "No resources found at: \(pattern.pathString)", severity: .warning))
}
case .folderReference(let path, _, _):
case let .folderReference(path, _, _):
if check(resources: resources, path: path.pathString) == nil {
issues.append(LintingIssue(reason: "No resources found at: \(path.pathString)", severity: .warning))
}
}
}
return issues
}

}
36 changes: 18 additions & 18 deletions Tests/TuistLoaderTests/Linters/FilesLinterTests.swift
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import ProjectDescription
import TSCBasic
import TuistCore
import TuistGraph
import TuistSupport
import TSCBasic
import XCTest

@testable import TuistLoader
Expand Down Expand Up @@ -33,12 +33,12 @@ class FilesLinterTests: XCTestCase {
product: .app,
bundleId: "testapp",
sources: [
"Sources/AppDelegate.swift"
"Sources/AppDelegate.swift",
],
resources: [
"Resources/image.png"
"Resources/image.png",
]
)
),
]
let project = Project.test(
name: "Test",
Expand All @@ -49,7 +49,7 @@ class FilesLinterTests: XCTestCase {
path: .current,
workspace: Workspace(name: "Test", projects: []),
projects: [
path: project
path: project,
]
)

Expand All @@ -61,7 +61,7 @@ class FilesLinterTests: XCTestCase {
platform: .iOS,
sources: [],
resources: []
)
),
]
)

Expand Down Expand Up @@ -91,12 +91,12 @@ class FilesLinterTests: XCTestCase {
product: .app,
bundleId: "testapp",
sources: [
"Sources/AppDelegate.swift"
"Sources/AppDelegate.swift",
],
resources: [
"Resources/image.png"
"Resources/image.png",
]
)
),
]
let project = Project.test(
name: "Test",
Expand All @@ -107,7 +107,7 @@ class FilesLinterTests: XCTestCase {
path: .current,
workspace: Workspace(name: "Test", projects: []),
projects: [
path: project
path: project,
]
)

Expand All @@ -118,12 +118,12 @@ class FilesLinterTests: XCTestCase {
name: "TestApp",
platform: .iOS,
sources: [
.init(path: try! AbsolutePath(validating: "/Sources/AppDelegate.swift"))
.init(path: try! AbsolutePath(validating: "/Sources/AppDelegate.swift")),
],
resources: [
.init(path: try! AbsolutePath(validating: "/Resources/image.png"))
.init(path: try! AbsolutePath(validating: "/Resources/image.png")),
]
)
),
]
)

Expand All @@ -145,12 +145,12 @@ class FilesLinterTests: XCTestCase {
product: .app,
bundleId: "testapp",
sources: [
"Sources/**"
"Sources/**",
],
resources: [
"Resources/**"
"Resources/**",
]
)
),
]
let project = Project.test(
name: "Test",
Expand All @@ -161,7 +161,7 @@ class FilesLinterTests: XCTestCase {
path: .current,
workspace: Workspace(name: "Test", projects: []),
projects: [
path: project
path: project,
]
)

Expand All @@ -173,7 +173,7 @@ class FilesLinterTests: XCTestCase {
platform: .iOS,
sources: [],
resources: []
)
),
]
)

Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Empty file.

This file was deleted.

This file was deleted.

0 comments on commit 30d7b15

Please sign in to comment.