Skip to content

Commit

Permalink
style: run swiftlint and swiftformat, improve lint
Browse files Browse the repository at this point in the history
  • Loading branch information
ErrorErrorError committed Dec 14, 2023
1 parent 5aa1187 commit 3619a2c
Show file tree
Hide file tree
Showing 69 changed files with 278 additions and 491 deletions.
3 changes: 2 additions & 1 deletion .swiftformat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
--throwcapturing
--trimwhitespace always
--typeattributes prev-line
--varattributes prev-line
--varattributes same-line
--voidtype void
--wraparguments before-first
--wrapeffects never
Expand All @@ -46,6 +46,7 @@

# op-ins (enable)

--enable blockComments
--enable genericExtensions
--enable spaceInsideGenerics
--enable opaqueGenericParameters
Expand Down
4 changes: 0 additions & 4 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ opt_in_rules:
- identical_operands
- implicit_return
- implicitly_unwrapped_optional
- indentation_width
- joined_default_parameter
- last_where
- literal_expression_end_indentation
Expand Down Expand Up @@ -86,9 +85,6 @@ private_over_fileprivate:
force_unwrapping:
severity: error

indentation_width:
indentation_width: 2

line_length:
warning: 150
error: 175
Expand Down
7 changes: 0 additions & 7 deletions App/Shared/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,6 @@ class AppDelegate: NSObject, NSApplicationDelegate {
}

func applicationShouldTerminate(_: NSApplication) -> NSApplication.TerminateReply {
// let viewStore = ViewStore(store)
//
// if viewStore.hasPendingChanges {
// viewStore.send(.appDelegate(.appWillTerminate))
// return .terminateLater
// }
//
.terminateNow
}
}
Expand Down
3 changes: 1 addition & 2 deletions App/iOS/PreferenceHostingView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ extension PreferenceHostingView {
}

private struct PreferenceModifier: ViewModifier, OpaquePreferenceProperties {
@State
var _homeIndicatorAutoHidden = false
@State var _homeIndicatorAutoHidden = false

func body(content: Content) -> some View {
if #available(iOS 16, *) {
Expand Down
10 changes: 3 additions & 7 deletions Sources/Clients/AnalyticsClient/Reducer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,11 @@ extension Reducer {
// MARK: - AnalyticsReducer

public struct AnalyticsReducer<State, Action>: Reducer {
@usableFromInline
let toAnalyticsAction: (State, Action) -> AnalyticsClient.Action?
@usableFromInline let toAnalyticsAction: (State, Action) -> AnalyticsClient.Action?

@usableFromInline
@Dependency(\.analyticsClient)
var analyticsClient
@Dependency(\.analyticsClient) var analyticsClient

@inlinable
public var body: some Reducer<State, Action> {
@inlinable public var body: some Reducer<State, Action> {
Reduce { state, action in
guard let event = toAnalyticsAction(state, action) else {
return .none
Expand Down
9 changes: 3 additions & 6 deletions Sources/Clients/LocalizableClient/Localizable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ public protocol Localizable {

extension Localizable {
public var localized: String {
@Dependency(\.localizableClient.localize)
var localize
@Dependency(\.localizableClient.localize) var localize

return localize(localizable)
}
Expand All @@ -35,17 +34,15 @@ extension Localizable where Self: CustomStringConvertible {

extension String {
public init(localizable: String) {
@Dependency(\.localizableClient.localize)
var localize
@Dependency(\.localizableClient.localize) var localize

self = localize(localizable)
}
}

extension Text {
public init(localizable: String) {
@Dependency(\.localizableClient.localize)
var localize
@Dependency(\.localizableClient.localize) var localize

self.init(localize(localizable))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ extension JSContext {
setConsoleBinding(logger)
setRequestBinding()

@Dependency(\.fileClient)
var fileClient
@Dependency(\.fileClient) var fileClient

let jsURL = try fileClient.retrieveModuleDirectory(module.mainJSFile)
try evaluateScript(String(contentsOf: jsURL))
Expand Down
6 changes: 2 additions & 4 deletions Sources/Clients/ModuleClient/Live.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ private actor ModulesCache {

@Sendable
func initialize() async throws {
@Dependency(\.databaseClient)
var databaseClient
@Dependency(\.databaseClient) var databaseClient
}

@Sendable
Expand All @@ -47,8 +46,7 @@ private actor ModulesCache {
}

private func fetchFromDB(for id: RepoModuleID) async throws -> ModuleClient.Instance {
@Dependency(\.databaseClient)
var databaseClient
@Dependency(\.databaseClient) var databaseClient

try await semaphore.waitUnlessCancelled()
defer { semaphore.signal() }
Expand Down
6 changes: 2 additions & 4 deletions Sources/Clients/ModuleClient/Logger.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ final class ModuleLogger {
private let logFileURL: URL
private let queue: DispatchQueue

@Dependency(\.fileClient)
var fileClient
@Dependency(\.fileClient) var fileClient

init(
id: RepoModuleID,
Expand All @@ -51,8 +50,7 @@ final class ModuleLogger {
self.id = id
self.queue = .init(label: "\(id.description)-logger")

@Dependency(\.fileClient)
var fileClient
@Dependency(\.fileClient) var fileClient

self.logFileURL = try fileClient.retrieveModuleDirectory(directory)
.appendingPathComponent("logs")
Expand Down
30 changes: 15 additions & 15 deletions Sources/Clients/PlayerClient/Internal/PlayerItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,22 +61,22 @@ extension PlayerItem: AVAssetResourceLoaderDelegate {
_: AVAssetResourceLoader,
shouldWaitForLoadingOfRequestedResource loadingRequest: AVAssetResourceLoadingRequest
) -> Bool {
// if payload.source.format == .mpd {
// if url.pathExtension == "ts" {
// loadingRequest.redirect = URLRequest(url: url.recoveryScheme)
// loadingRequest.response = HTTPURLResponse(
// url: url.recoveryScheme,
// statusCode: 302,
// httpVersion: nil,
// headerFields: nil
// )
// loadingRequest.finishLoading()
// } else {
// handleDASHRequest(url, callback)
// }
// } else {
// if payload.source.format == .mpd {
// if url.pathExtension == "ts" {
// loadingRequest.redirect = URLRequest(url: url.recoveryScheme)
// loadingRequest.response = HTTPURLResponse(
// url: url.recoveryScheme,
// statusCode: 302,
// httpVersion: nil,
// headerFields: nil
// )
// loadingRequest.finishLoading()
// } else {
// handleDASHRequest(url, callback)
// }
// } else {
handleHLSRequest(loadingRequest: loadingRequest)
// }
// }
}
}

Expand Down
12 changes: 4 additions & 8 deletions Sources/Clients/RepoClient/Live.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,9 @@ import SharedModels
extension RepoClient: DependencyKey {
private static let downloadManager = ModulesDownloadManager()

@Dependency(\.databaseClient)
private static var databaseClient
@Dependency(\.databaseClient) private static var databaseClient

@Dependency(\.fileClient)
private static var fileClient
@Dependency(\.fileClient) private static var fileClient

public static let liveValue = Self(
validate: { url in
Expand Down Expand Up @@ -102,11 +100,9 @@ private class ModulesDownloadManager {
private var semaphore = AsyncSemaphore(value: 1)
private var downloadTasks = [RepoModuleID: Task<Module?, Never>]()

@Dependency(\.fileClient)
var fileClient
@Dependency(\.fileClient) var fileClient

@Dependency(\.databaseClient)
var databaseClient
@Dependency(\.databaseClient) var databaseClient

func addToQueue(_ repoModuleId: RepoModuleID, module: Module.Manifest) {
Task.detached { [weak self] in
Expand Down
6 changes: 2 additions & 4 deletions Sources/Features/App/AppDelegateFeature.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,9 @@ public struct AppDelegateFeature: Reducer {
case didFinishLaunching
}

@Dependency(\.databaseClient)
var databaseClient
@Dependency(\.databaseClient) var databaseClient

@Dependency(\.moduleClient)
var moduleClient
@Dependency(\.moduleClient) var moduleClient

public init() {}

Expand Down
12 changes: 4 additions & 8 deletions Sources/Features/App/AppFeature.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ public struct AppFeature: Feature {

public var selected = Tab.discover

@PresentationState
public var videoPlayer: VideoPlayerFeature.State?
@PresentationState public var videoPlayer: VideoPlayerFeature.State?

public init(
discover: DiscoverFeature.State = .init(),
Expand Down Expand Up @@ -113,20 +112,17 @@ public struct AppFeature: Feature {
public struct View: FeatureView {
public let store: StoreOf<AppFeature>

@Environment(\.theme)
var theme
@Environment(\.theme) var theme

@MainActor
public init(store: StoreOf<AppFeature>) {
self.store = store
}
}

@Dependency(\.databaseClient)
var databaseClient
@Dependency(\.databaseClient) var databaseClient

@Dependency(\.playerClient)
var playerClient
@Dependency(\.playerClient) var playerClient

public init() {}
}
3 changes: 1 addition & 2 deletions Sources/Features/App/iOS/AppFeatureView+iOS.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ import ViewComponents

#if os(iOS)
extension AppFeature.View: View {
@MainActor
public var body: some View {
@MainActor public var body: some View {
WithViewStore(store, observe: \.selected) { viewStore in
TabView(
selection: viewStore.binding(
Expand Down
3 changes: 1 addition & 2 deletions Sources/Features/App/macOS/AppFeatureView+macOS.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ import VideoPlayer

#if os(macOS)
extension AppFeature.View: View {
@MainActor
public var body: some View {
@MainActor public var body: some View {
NavigationView {
WithViewStore(store, observe: \.selected) { viewStore in
List {
Expand Down
23 changes: 8 additions & 15 deletions Sources/Features/ContentCore/ContentCore+View.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ extension ContentCore {
public struct View: SwiftUI.View {
public let store: StoreOf<ContentCore>

@ObservedObject
private var viewStore: ViewStoreOf<ContentCore>
@ObservedObject private var viewStore: ViewStoreOf<ContentCore>
private let contentType: Playlist.PlaylistType

@MainActor
Expand All @@ -42,17 +41,13 @@ extension ContentCore {
self.selectedItemId = selectedItemId
}

@Environment(\.theme)
var theme
@Environment(\.theme) var theme

@SwiftUI.State
private var _selectedGroupId: Playlist.Group.ID?
@SwiftUI.State private var _selectedGroupId: Playlist.Group.ID?

@SwiftUI.State
private var _selectedVariantId: Playlist.Group.Variant.ID?
@SwiftUI.State private var _selectedVariantId: Playlist.Group.Variant.ID?

@SwiftUI.State
private var _selectedPagingId: PagingID?
@SwiftUI.State private var _selectedPagingId: PagingID?

private let selectedItemId: Playlist.Item.ID?

Expand All @@ -77,8 +72,7 @@ extension ContentCore {
(viewStore.groups.value?.count ?? 0) > 1
}

@MainActor
public var body: some SwiftUI.View {
@MainActor public var body: some SwiftUI.View {
HeaderWithContent {
VStack {
HStack(alignment: .center) {
Expand Down Expand Up @@ -204,7 +198,7 @@ extension ContentCore {
.font(.callout.weight(.semibold))

Button {
// viewStore.send(.view(.didTapRetry(items)))
// viewStore.send(.view(.didTapRetry(items)))
} label: {
Text("Retry")
.padding(.horizontal, 8)
Expand Down Expand Up @@ -324,8 +318,7 @@ private struct HeaderWithContent<Label: View, Content: View>: View {
let label: () -> Label
let content: () -> Content

@MainActor
var body: some View {
@MainActor var body: some View {
LazyVStack(alignment: .leading, spacing: 12) {
label()
.font(.title3.bold())
Expand Down
3 changes: 1 addition & 2 deletions Sources/Features/ContentCore/ContentCore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,7 @@ extension ContentCore.State {
_ option: Playlist.ItemsRequestOptions? = nil,
forced: Bool = false
) -> Effect<ContentCore.Action> {
@Dependency(\.moduleClient)
var moduleClient
@Dependency(\.moduleClient) var moduleClient

let playlistId = playlist.id
let repoModuleId = repoModuleId
Expand Down
6 changes: 2 additions & 4 deletions Sources/Features/Discover/DiscoverFeature+Reducer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ extension DiscoverFeature {
case fetchDiscoverList
}

@ReducerBuilder<State, Action>
public var body: some ReducerOf<Self> {
@ReducerBuilder<State, Action> public var body: some ReducerOf<Self> {
Reduce { state, action in
switch action {
case .view(.didAppear):
Expand Down Expand Up @@ -126,8 +125,7 @@ extension DiscoverFeature {

extension DiscoverFeature.State {
mutating func fetchLatestListings(_ selectedModule: RepoClient.SelectedModule?) -> Effect<DiscoverFeature.Action> {
@Dependency(\.moduleClient)
var moduleClient
@Dependency(\.moduleClient) var moduleClient

guard let selectedModule else {
section = .home(.init())
Expand Down
3 changes: 1 addition & 2 deletions Sources/Features/Discover/DiscoverFeature+View.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ import ViewComponents
// MARK: - DiscoverFeature.View + View

extension DiscoverFeature.View: View {
@MainActor
public var body: some View {
@MainActor public var body: some View {
NavStack(
store.scope(
state: \.path,
Expand Down
Loading

0 comments on commit 3619a2c

Please sign in to comment.