Skip to content

Commit

Permalink
Merge branch 'lint_format'
Browse files Browse the repository at this point in the history
  • Loading branch information
sgr-ksmt committed Sep 29, 2019
2 parents 441d400 + 712f456 commit e8e46bc
Show file tree
Hide file tree
Showing 29 changed files with 171 additions and 71 deletions.
9 changes: 9 additions & 0 deletions .swiftformat
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

# exclude files
--exclude Carthage,Pods

# change rules
--stripunusedargs closure-only

# disable rules
--disable strongOutlets,numberFormatting,emptyBraces,andOperator
41 changes: 41 additions & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
disabled_rules:
- colon
- comma
- control_statement
- identifier_name
- type_name
- trailing_comma
- multiple_closures_with_trailing_closure
- opening_brace

opt_in_rules:
- empty_count
- sorted_imports
- anyobject_protocol

excluded:
- Carthage
- Pods
- vendor/bundle

force_cast: error

force_try:
severity: error

type_body_length:
- 300
- 400

function_body_length:
- 200
- 300

file_length:
- 500
- 1000

line_length: 200

nesting:
type_level: 3
19 changes: 19 additions & 0 deletions FireTodo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@
isa = PBXNativeTarget;
buildConfigurationList = 160702982337231400A57BE8 /* Build configuration list for PBXNativeTarget "FireTodo" */;
buildPhases = (
166451F82340FE0400E0E7AB /* SwiftLint */,
678E1EE18A824791FD50167E /* [CP] Check Pods Manifest.lock */,
160702802337231300A57BE8 /* Sources */,
160702812337231300A57BE8 /* Frameworks */,
Expand Down Expand Up @@ -412,6 +413,24 @@
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
166451F82340FE0400E0E7AB /* SwiftLint */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
);
name = SwiftLint;
outputFileListPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "${SRCROOT}/Pods/SwiftLint/swiftlint\n";
};
6332EE6E8916A88AE530C93A /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
Expand Down
3 changes: 1 addition & 2 deletions FireTodo/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Copyright © Suguru Kishimoto. All rights reserved.
//

import UIKit
import Firebase
import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
Expand All @@ -19,4 +19,3 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
}
}

4 changes: 2 additions & 2 deletions FireTodo/Combine/Auth+Combine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ extension CombineAuth {
let listener = addListener(auth) { auth, user in
_ = subscriber.receive((auth, user))
}
self._cancel = { removeListener($0, listener) }
_cancel = { removeListener($0, listener) }
}

public func request(_ demand: Subscribers.Demand) {}
Expand All @@ -53,7 +53,7 @@ extension CombineAuth {
self.removeListener = removeListener
}

public func receive<S>(subscriber: S) where S : Subscriber, S.Failure == Failure, S.Input == Output {
public func receive<S>(subscriber: S) where S: Subscriber, S.Failure == Failure, S.Input == Output {
subscriber.receive(subscription: Subscription(
subscriber: subscriber,
auth: auth,
Expand Down
10 changes: 4 additions & 6 deletions FireTodo/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Copyright © Suguru Kishimoto. All rights reserved.
//

import SwiftUI
import Combine
import SwiftUI

struct ContentView: View {
@EnvironmentObject private var store: AppStore
Expand All @@ -19,11 +19,9 @@ struct ContentView: View {
return AnyView(SignUpView())
}
}
}())
.onAppear { self.store.dispatch(AuthAction.subscribe()) }
.onDisappear {
self.store.dispatch(AuthAction.subscribe())
}
}())
.onAppear { self.store.dispatch(AuthAction.subscribe()) }
.onDisappear { self.store.dispatch(AuthAction.subscribe()) }
}
}

Expand Down
2 changes: 1 addition & 1 deletion FireTodo/Firebase/Model.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Copyright © Suguru Kishimoto. All rights reserved.
//

import Foundation
import FireSnapshot
import Foundation

/// Name space for Cloud Firestore document models.
enum Model {
Expand Down
2 changes: 1 addition & 1 deletion FireTodo/Firebase/Snapshot+Identifiable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Copyright © Suguru Kishimoto. All rights reserved.
//

import Foundation
import FireSnapshot
import Foundation

extension Snapshot: Identifiable {
public var id: String {
Expand Down
10 changes: 5 additions & 5 deletions FireTodo/Redux/Auth/AuthAction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
// Copyright © Suguru Kishimoto. All rights reserved.
//

import Combine
import Firebase
import FireSnapshot
import Foundation
import ReSwift
import ReSwiftThunk
import Firebase
import FireSnapshot
import Combine

enum AuthAction: Action {
case finishInitialLoad
Expand Down Expand Up @@ -36,8 +36,8 @@ enum AuthAction: Action {
finishInitialLoad()
return AuthAction.updateUser(user: nil)
}
}
.sink(receiveValue: dispatch)
}
.sink(receiveValue: dispatch)

dispatch(AuthAction.subscribeAuthChange(cancellable: cancellable))
}
Expand Down
7 changes: 4 additions & 3 deletions FireTodo/Redux/Auth/AuthState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@
// Copyright © Suguru Kishimoto. All rights reserved.
//

import Foundation
import ReSwift
import Combine
import Firebase
import FireSnapshot
import Combine
import Foundation
import ReSwift

struct AuthState: StateType {
enum LoadingState {
case initial
case loaded
}

var loadingState: LoadingState = .initial
var user: Snapshot<Model.User>?
var listenerHandle: AuthStateDidChangeListenerHandle?
Expand Down
6 changes: 3 additions & 3 deletions FireTodo/Redux/EditTask/EditTaskAction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
// Copyright © Suguru Kishimoto. All rights reserved.
//

import FireSnapshot
import Foundation
import ReSwift
import FireSnapshot

enum EditTaskAction: Action {
case startRequest
Expand All @@ -13,7 +13,7 @@ enum EditTaskAction: Action {
case reset

static func saveTask(_ taskData: Model.Task, userID: String) -> AppThunkAction {
AppThunkAction { dispatch, getState in
AppThunkAction { dispatch, _ in
dispatch(EditTaskAction.startRequest)
Snapshot(data: taskData, path: Model.Path.tasks(userID: userID)).create { result in
dispatch(EditTaskAction.endRequest)
Expand All @@ -28,7 +28,7 @@ enum EditTaskAction: Action {
}

static func updateTask(_ taskData: Model.Task, taskID: String, userID: String) -> AppThunkAction {
AppThunkAction { dispatch, getState in
AppThunkAction { dispatch, _ in
dispatch(EditTaskAction.startRequest)
Snapshot(data: taskData, path: Model.Path.task(userID: userID, taskID: taskID)).update { result in
dispatch(EditTaskAction.endRequest)
Expand Down
2 changes: 1 addition & 1 deletion FireTodo/Redux/Main/AppStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
// Copyright © Suguru Kishimoto. All rights reserved.
//

import Combine
import Foundation
import ReSwift
import Combine

final class AppStore: StoreSubscriber, DispatchingStoreType, ObservableObject {
private let store: Store<AppState>
Expand Down
2 changes: 1 addition & 1 deletion FireTodo/Redux/Middleware/Logging/LoggingMiddleware.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Foundation
import ReSwift

func createLoggingMiddleware() -> Middleware<AppState> {
return { dispatch, getState in
return { _, _ in
{ next in
{ action in
print("> \(action)")
Expand Down
6 changes: 3 additions & 3 deletions FireTodo/Redux/SignUp/SignUpAction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
// Copyright © Suguru Kishimoto. All rights reserved.
//

import Firebase
import FireSnapshot
import Foundation
import ReSwift
import ReSwiftThunk
import Firebase
import FireSnapshot

enum SignUpAction: Action {
case signUpStarted
Expand All @@ -31,7 +31,7 @@ enum SignUpAction: Action {
}

private static func createUser(with uid: String, name: String, db: Firestore = .firestore()) -> AppThunkAction {
AppThunkAction { dispatch, getState in
AppThunkAction { dispatch, _ in
let user = Model.User(username: name)
Snapshot<Model.User>.init(data: user, path: Model.Path.user(userID: uid)).create { result in
switch result {
Expand Down
10 changes: 5 additions & 5 deletions FireTodo/Redux/Tasks/TasksAction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
// Copyright © Suguru Kishimoto. All rights reserved.
//

import Foundation
import ReSwift
import Firebase
import FireSnapshot
import Foundation
import ReSwift

enum TasksAction: Action {
case updateTasks(tasks: [Snapshot<Model.Task>])
case registerListener(listener: ListenerRegistration)
case removeListener

static func subscribe(userID: String) -> AppThunkAction {
AppThunkAction { dispatch, getState in
AppThunkAction { dispatch, _ in
let listener = Snapshot<Model.Task>.listen(Model.Path.tasks(userID: userID)) { result in
switch result {
case let .success(tasks):
Expand All @@ -36,13 +36,13 @@ enum TasksAction: Action {
}

static func deleteTask(_ task: Snapshot<Model.Task>) -> AppThunkAction {
AppThunkAction { dispatch, getState in
AppThunkAction { _, _ in
task.remove()
}
}

static func toggleTaskCompleted(_ task: Snapshot<Model.Task>) -> AppThunkAction {
AppThunkAction { dispatch, getState in
AppThunkAction { _, _ in
task.data.completed.toggle()
task.update()
}
Expand Down
2 changes: 1 addition & 1 deletion FireTodo/Redux/Tasks/TasksReducer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ enum TasksReducer {
case let .updateTasks(tasks):
state.tasks = tasks
return state
case .registerListener(let listener):
case let .registerListener(listener):
state.tasksListener = listener
return state
case .removeListener:
Expand Down
4 changes: 2 additions & 2 deletions FireTodo/Redux/Tasks/TasksState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
// Copyright © Suguru Kishimoto. All rights reserved.
//

import Foundation
import ReSwift
import Firebase
import FireSnapshot
import Foundation
import ReSwift

struct TasksState: StateType {
var tasks: [Snapshot<Model.Task>] = []
Expand Down
6 changes: 2 additions & 4 deletions FireTodo/SceneDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
// Copyright © Suguru Kishimoto. All rights reserved.
//

import UIKit
import SwiftUI
import ReSwift
import SwiftUI
import UIKit

class SceneDelegate: UIResponder, UIWindowSceneDelegate {

var window: UIWindow?
private lazy var main: AppMain = .init()

Expand Down Expand Up @@ -37,4 +36,3 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
func sceneDidEnterBackground(_ scene: UIScene) {
}
}

3 changes: 3 additions & 0 deletions FireTodo/Views/Common/LoadingView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ struct LoadingView: View {
init(isLoading: Bool) {
self.isLoading = isLoading
}

var body: some View {
ZStack {
if isLoading {
Expand All @@ -25,8 +26,10 @@ struct LoadingView: View {
}
}

#if DEBUG
struct LoadingView_Previews: PreviewProvider {
static var previews: some View {
LoadingView(isLoading: true)
}
}
#endif
Loading

0 comments on commit e8e46bc

Please sign in to comment.