Skip to content

Commit

Permalink
Turn on warning when func take time to compile
Browse files Browse the repository at this point in the history
  • Loading branch information
hoangatuan committed Mar 4, 2024
1 parent 6efb411 commit 3ed7043
Show file tree
Hide file tree
Showing 31 changed files with 1,481 additions and 32 deletions.
9 changes: 9 additions & 0 deletions Core/CommonUI/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,12 @@ let package = Package(
),
]
)

for target in package.targets {
target.swiftSettings = target.swiftSettings ?? []
target.swiftSettings?.append(
.unsafeFlags([
"-Xfrontend", "-warn-long-function-bodies=200", "-Xfrontend", "-warn-long-expression-type-checking=200",
])
)
}
11 changes: 10 additions & 1 deletion Features/Movies/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,17 @@ let package = Package(
.product(name: "NetworkMock", package: "Network"),
],
resources: [
.process("Resources")
.process("Resources"),
]
),
]
)

for target in package.targets {
target.swiftSettings = target.swiftSettings ?? []
target.swiftSettings?.append(
.unsafeFlags([
"-Xfrontend", "-warn-long-function-bodies=200", "-Xfrontend", "-warn-long-expression-type-checking=200",
])
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ enum MovieSheetDesination: Identifiable {
return "share"
}
}

case share(movie: Movie)
}

Expand All @@ -34,7 +34,6 @@ enum Destination: Hashable {
}

public struct MoviesCoordinator: View {

@EnvironmentObject private var router: Router
private let dependencies: Dependencies

Expand All @@ -51,7 +50,8 @@ public struct MoviesCoordinator: View {
case let .movieByGenre(genre):
GenreMoviesView(dependencies: .init(
genre: genre,
repository: MovieRepository(apiClientService: dependencies.apiClient))
repository: MovieRepository(apiClientService: dependencies.apiClient)
)
)
case let .movieDetail(movie):
MovieDetailView(
Expand All @@ -68,7 +68,7 @@ public struct MoviesCoordinator: View {
.sheet(item: $router.presentedSheet) { destination in
if let destination = destination.destination as? MovieSheetDesination {
switch destination {
case .share(movie: let movie):
case .share(movie: _):
Text("Share movie")
}
}
Expand Down
16 changes: 15 additions & 1 deletion Features/People/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ let package = Package(
.product(name: "DomainData", package: "Domain"),
"Router",
"DesignSystem",
],
swiftSettings: [
.unsafeFlags([
"-Xfrontend", "-warn-long-function-bodies=200", "-Xfrontend", "-warn-long-expression-type-checking=200",
]),
]
),
.testTarget(
Expand All @@ -41,8 +46,17 @@ let package = Package(
.product(name: "NetworkMock", package: "Network"),
],
resources: [
.process("Resources")
.process("Resources"),
]
),
]
)

// for target in package.targets {
// target.swiftSettings = target.swiftSettings ?? []
// target.swiftSettings?.append(
// .unsafeFlags([
// "-Xfrontend", "-warn-long-function-bodies=200", "-Xfrontend", "-warn-long-expression-type-checking=200"
// ])
// )
// }
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
//
// SwiftUIView.swift
//
// PeopleCoordinator.swift
//
//
// Created by Tuan Hoang on 19/11/23.
//

import SwiftUI
import Domain
import DomainData
import Network
import Router
import SwiftUI

public enum PublicPeopleDestination: Hashable {
case movieDetail(movie: Movie)
Expand All @@ -23,19 +23,18 @@ enum SheetDesination: Identifiable {
return "share"
}
}

case share(person: PersonDetail)
}

public struct PersonDetailCoordinator: View {

@EnvironmentObject private var router: Router
private let dependencies: Dependencies

public init(dependencies: Dependencies) {
self.dependencies = dependencies
}

public var body: some View {
PersonDetailView(
dependencies: .init(personId: dependencies.personId, peopleRepository: PeopleRepository(apiClientService: dependencies.apiClient))
Expand All @@ -44,7 +43,7 @@ public struct PersonDetailCoordinator: View {
.sheet(item: $router.presentedSheet) { destination in
if let destination = destination.destination as? SheetDesination {
switch destination {
case .share(person: let person):
case .share(person: _):
Text("Share person")
}
}
Expand All @@ -56,7 +55,7 @@ public extension PersonDetailCoordinator {
struct Dependencies {
let personId: Int
let apiClient: IAPIClientService

public init(personId: Int, apiClient: IAPIClientService) {
self.personId = personId
self.apiClient = apiClient
Expand Down
12 changes: 9 additions & 3 deletions Features/Search/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,16 @@ let package = Package(
dependencies: [
"Search",
.product(name: "NetworkMock", package: "Network"),
],
resources: [
.process("Resources")
]
),
]
)

for target in package.targets {
target.swiftSettings = target.swiftSettings ?? []
target.swiftSettings?.append(
.unsafeFlags([
"-Xfrontend", "-warn-long-function-bodies=200", "-Xfrontend", "-warn-long-expression-type-checking=200",
])
)
}
11 changes: 10 additions & 1 deletion Features/TVSeries/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,17 @@ let package = Package(
.product(name: "NetworkMock", package: "Network"),
],
resources: [
.process("Resources")
.process("Resources"),
]
),
]
)

for target in package.targets {
target.swiftSettings = target.swiftSettings ?? []
target.swiftSettings?.append(
.unsafeFlags([
"-Xfrontend", "-warn-long-function-bodies=200", "-Xfrontend", "-warn-long-expression-type-checking=200",
])
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ public struct TVSeriesCoordinator: View {

public var body: some View {
TVSeriesHomeView(repository: TVSeriesRepository(apiClientService: dependencies.apiClient))
.navigationDestination(for: Destination.self) { destination in
switch destination {
case .tvSeriesDetail(let tvSeries):
Text("TV Series")
.toolbar(.hidden, for: .tabBar)
.navigationDestination(for: Destination.self) { destination in
switch destination {
case .tvSeriesDetail:
Text("TV Series")
.toolbar(.hidden, for: .tabBar)
}
}
}
}
}

Expand Down
9 changes: 9 additions & 0 deletions Foundation/DesignSystem/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,12 @@ let package = Package(
),
]
)

for target in package.targets {
target.swiftSettings = target.swiftSettings ?? []
target.swiftSettings?.append(
.unsafeFlags([
"-Xfrontend", "-warn-long-function-bodies=200", "-Xfrontend", "-warn-long-expression-type-checking=200",
])
)
}
2 changes: 1 addition & 1 deletion Foundation/DesignSystem/Sources/DesignSystem/Color.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public extension Color {

extension Color {
init?(hex: String) {
var hexSanitized = hex.trimmingCharacters(in: .whitespacesAndNewlines)
var hexSanitized: String = hex.trimmingCharacters(in: .whitespacesAndNewlines)
hexSanitized = hexSanitized.replacingOccurrences(of: "#", with: "")

var rgb: UInt64 = 0
Expand Down
13 changes: 11 additions & 2 deletions Foundation/Domain/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ let package = Package(
],
dependencies: [
.package(path: "./Network"),
.package(path: "./HelperMacros")
.package(path: "./HelperMacros"),
],
targets: [
// Targets are the basic building blocks of a package, defining a module or a test suite.
// Targets can depend on other targets in this package and products from dependencies.
.target(
name: "Domain",
dependencies: [
"HelperMacros"
"HelperMacros",
]
),
.target(
Expand All @@ -44,3 +44,12 @@ let package = Package(
),
]
)

for target in package.targets {
target.swiftSettings = target.swiftSettings ?? []
target.swiftSettings?.append(
.unsafeFlags([
"-Xfrontend", "-warn-long-function-bodies=200", "-Xfrontend", "-warn-long-expression-type-checking=200",
])
)
}
13 changes: 11 additions & 2 deletions Foundation/HelperMacros/Package.swift
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// swift-tools-version: 5.9
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription
import CompilerPluginSupport
import PackageDescription

let package = Package(
name: "HelperMacros",
Expand Down Expand Up @@ -30,7 +30,7 @@ let package = Package(
name: "HelperMacrosMacros",
dependencies: [
.product(name: "SwiftSyntaxMacros", package: "swift-syntax"),
.product(name: "SwiftCompilerPlugin", package: "swift-syntax")
.product(name: "SwiftCompilerPlugin", package: "swift-syntax"),
]
),

Expand All @@ -50,3 +50,12 @@ let package = Package(
),
]
)

for target in package.targets {
target.swiftSettings = target.swiftSettings ?? []
target.swiftSettings?.append(
.unsafeFlags([
"-Xfrontend", "-warn-long-function-bodies=200", "-Xfrontend", "-warn-long-expression-type-checking=200",
])
)
}
9 changes: 9 additions & 0 deletions Foundation/Logger/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,12 @@ let package = Package(
),
]
)

for target in package.targets {
target.swiftSettings = target.swiftSettings ?? []
target.swiftSettings?.append(
.unsafeFlags([
"-Xfrontend", "-warn-long-function-bodies=200", "-Xfrontend", "-warn-long-expression-type-checking=200",
])
)
}
13 changes: 11 additions & 2 deletions Foundation/Network/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,24 @@ let package = Package(
name: "NetworkMock",
dependencies: [
"Network",
.product(name: "OHHTTPStubsSwift", package: "OHHTTPStubs")
.product(name: "OHHTTPStubsSwift", package: "OHHTTPStubs"),
]
),
.testTarget(
name: "NetworkTests",
dependencies: [
"Network",
.product(name: "OHHTTPStubsSwift", package: "OHHTTPStubs")
.product(name: "OHHTTPStubsSwift", package: "OHHTTPStubs"),
]
),
]
)

for target in package.targets {
target.swiftSettings = target.swiftSettings ?? []
target.swiftSettings?.append(
.unsafeFlags([
"-Xfrontend", "-warn-long-function-bodies=200", "-Xfrontend", "-warn-long-expression-type-checking=200",
])
)
}
9 changes: 9 additions & 0 deletions Foundation/Router/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,12 @@ let package = Package(
),
]
)

for target in package.targets {
target.swiftSettings = target.swiftSettings ?? []
target.swiftSettings?.append(
.unsafeFlags([
"-Xfrontend", "-warn-long-function-bodies=200", "-Xfrontend", "-warn-long-expression-type-checking=200",
])
)
}
Loading

0 comments on commit 3ed7043

Please sign in to comment.