Skip to content

Commit

Permalink
Merge pull request #152 from Team-Ampersand/31-swift-format-adapt
Browse files Browse the repository at this point in the history
🔀 :: [#31] SwiftFormat 적용
  • Loading branch information
baekteun authored Aug 11, 2023
2 parents 6c96475 + 2a48815 commit b6261c7
Show file tree
Hide file tree
Showing 221 changed files with 688 additions and 441 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/SwiftLint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: SwiftLint

on:
pull_request:
paths:
- '.github/workflows/swiftlint.yml'
- '**/*.swift'

jobs:
SwiftLint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: GitHub Action for SwiftLint (Different working directory)
uses: norio-nomura/action-swiftlint@3.2.1
env:
WORKING_DIRECTORY: Projects
with:
args: --config ../Scripts/.swiftlint.yml
14 changes: 8 additions & 6 deletions Projects/App/Project.swift
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
import ProjectDescriptionHelpers
import ProjectDescription
import ConfigurationPlugin
import DependencyPlugin
import EnvironmentPlugin
import Foundation
import ProjectDescription
import ProjectDescriptionHelpers

let isCI = (ProcessInfo.processInfo.environment["TUIST_CI"] ?? "0") == "1" ? true : false

let configurations: [Configuration] = .default

let settings: Settings =
.settings(base: env.baseSetting,
configurations: configurations,
defaultSettings: .recommended)
.settings(
base: env.baseSetting,
configurations: configurations,
defaultSettings: .recommended
)

let scripts: [TargetScript] = isCI ? [] : [.swiftLint]
let scripts: [TargetScript] = isCI ? [] : [.swiftFormat, .swiftLint]

let targets: [Target] = [
.init(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ final class DotoriShareViewController: UIViewController {
.then {
$0.layer.maskedCorners = [.layerMinXMinYCorner, .layerMaxXMinYCorner]
}

private let proposeMusicLabel = DotoriLabel(L10n.ProposeMusic.proposeMusicTitle, font: .subtitle1)
private let cancelButton = DotoriTextButton(L10n.Global.cancelButtonTitle, textColor: .neutral(.n20), font: .body2)
private let thumbnailImageView = UIImageView()
Expand Down
6 changes: 3 additions & 3 deletions Projects/App/ShareExtension/Sources/MusicContainer.swift
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import Swinject
import MusicDomain
import JwtStore
import Networking
import KeyValueStore
import MusicDomain
import Networking
import Swinject

final class MusicContainer {
static let shared = MusicContainer()
Expand Down
2 changes: 1 addition & 1 deletion Projects/App/Sources/Application/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import Database
import DetailNoticeFeature
import FilterSelfStudyFeature
import HomeFeature
import IQKeyboardManagerSwift
import InputDialogFeature
import IQKeyboardManagerSwift
import JwtStore
import KeyValueStore
import MainTabFeature
Expand Down
3 changes: 1 addition & 2 deletions Projects/App/Sources/Application/SceneDelegate.swift
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import UIKit
import Moordinator
import RootFeature
import UIKit

final class SceneDelegate: UIResponder, UIWindowSceneDelegate {

var window: UIWindow?
private let moordinatorWorker = MoordinatorWorker()
private let rootRouter = RootRouter()
Expand Down
2 changes: 0 additions & 2 deletions Projects/App/Tests/TargetTest.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import XCTest

class TargetTests: XCTestCase {

override func setUpWithError() throws {
// Put setup code here. This method is called before the invocation of each test method in the class.
}
Expand All @@ -13,5 +12,4 @@ class TargetTests: XCTestCase {
func testExample() throws {
XCTAssertEqual("A", "A")
}

}
2 changes: 1 addition & 1 deletion Projects/Core/Database/Project.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import DependencyPlugin
import ProjectDescription
import ProjectDescriptionHelpers
import DependencyPlugin

let project = Project.module(
name: ModulePaths.Core.Database.rawValue,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import Swinject

public final class DatabaseAssembly: Assembly {
public init() {}
// swiftlint : disable identifier_name
/// swiftlint : disable identifier_name
public func assemble(container: Container) {
container.register(LocalDatabase.self) { _ in
GRDBLocalDatabase { migrator in
#if DEBUG
#if DEBUG
migrator.eraseDatabaseOnSchemaChange = true
#endif
#endif

migrator.registerMigration("v1.0.0") { db in
try db.create(table: "MealInfoLocalEntity") { table in
Expand Down
8 changes: 4 additions & 4 deletions Projects/Core/Database/Sources/GRDBLocalDatabase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -139,17 +139,17 @@ final class GRDBLocalDatabase: LocalDatabase {
}
}

func delete<Record: FetchableRecord & PersistableRecord>(
as record: Record.Type,
func delete(
as record: (some FetchableRecord & PersistableRecord).Type,
key: any DatabaseValueConvertible
) throws {
try dbQueue.write { db in
_ = try record.deleteOne(db, key: key)
}
}

func deleteAll<Record: FetchableRecord & PersistableRecord>(
as record: Record.Type
func deleteAll(
as record: (some FetchableRecord & PersistableRecord).Type
) throws {
try dbQueue.write { db in
_ = try record.deleteAll(db)
Expand Down
8 changes: 4 additions & 4 deletions Projects/Core/Database/Testing/LocalDatabaseMock.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,16 @@ final class LocalDatabaseMock: LocalDatabase {
}

var deleteKeyCallCount = 0
func delete<Record: FetchableRecord & PersistableRecord>(
as record: Record.Type,
func delete(
as record: (some FetchableRecord & PersistableRecord).Type,
key: any DatabaseValueConvertible
) throws {
deleteKeyCallCount += 1
}

var deleteAllCallCount = 0
func deleteAll<Record: FetchableRecord & PersistableRecord>(
as record: Record.Type
func deleteAll(
as record: (some FetchableRecord & PersistableRecord).Type
) throws {
deleteAllCallCount += 1
}
Expand Down
2 changes: 1 addition & 1 deletion Projects/Core/JwtStore/Project.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import DependencyPlugin
import ProjectDescription
import ProjectDescriptionHelpers
import DependencyPlugin

let project = Project.module(
name: ModulePaths.Core.JwtStore.rawValue,
Expand Down
2 changes: 1 addition & 1 deletion Projects/Core/KeyValueStore/Project.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import DependencyPlugin
import ProjectDescription
import ProjectDescriptionHelpers
import DependencyPlugin

let project = Project.module(
name: ModulePaths.Core.KeyValueStore.rawValue,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import XCTest
@testable import KeyValueStore
import XCTest

final class UserDefaultsKeyValueStoreTests: XCTestCase {
var userDefaults: UserDefaults!
Expand Down Expand Up @@ -57,5 +57,4 @@ final class UserDefaultsKeyValueStoreTests: XCTestCase {
// Then
XCTAssertNil(loadedValue, "Loaded value should be nil after deletion")
}

}
13 changes: 6 additions & 7 deletions Projects/Core/Networking/Interface/Endpoint/DotoriEndpoint.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,26 @@ public protocol DotoriEndpoint: EndpointType, JwtAuthorizable {
var errorMap: [Int: Error] { get }
}

extension DotoriEndpoint {
public var baseURL: URL {
public extension DotoriEndpoint {
var baseURL: URL {
let baseURL = Bundle.module.object(forInfoDictionaryKey: "BASE_URL") as? String ?? ""
return URL(
string: "\(baseURL)/\(domain.rawValue)"
) ?? URL(string: "https://www.google.com")!
}

public var validationCode: ClosedRange<Int> { 200...300 }
var validationCode: ClosedRange<Int> { 200...300 }

public var headers: [String: String]? {
var headers: [String: String]? {
switch self {

default:
return ["Content-Type": "application/json"]
}
}

public var timeout: TimeInterval { 60 }
var timeout: TimeInterval { 60 }

public var errorMap: [Int: Error] { [:] }
var errorMap: [Int: Error] { [:] }
}

private class BundleFinder {}
Expand Down
1 change: 0 additions & 1 deletion Projects/Core/Networking/Interface/Networking.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import Emdpoint
import Foundation

public protocol Networking {

func request<T: Decodable>(_ endpoint: any EndpointType, dto: T.Type) async throws -> T
func request(_ endpoint: any EndpointType) async throws
}
10 changes: 5 additions & 5 deletions Projects/Core/Networking/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ let isCI = (ProcessInfo.processInfo.environment["TUIST_CI"] ?? "0") == "1" ? tru

let configurations: [Configuration] = isCI ?
.default :
[
.debug(name: .dev, xcconfig: .relativeToXCConfig(type: .dev, name: name)),
.debug(name: .stage, xcconfig: .relativeToXCConfig(type: .stage, name: name)),
.release(name: .prod, xcconfig: .relativeToXCConfig(type: .prod, name: name))
]
[
.debug(name: .dev, xcconfig: .relativeToXCConfig(type: .dev, name: name)),
.debug(name: .stage, xcconfig: .relativeToXCConfig(type: .stage, name: name)),
.release(name: .prod, xcconfig: .relativeToXCConfig(type: .prod, name: name))
]

let project = Project.module(
name: name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ extension RefreshEndpoint: DotoriEndpoint {
.refreshToken
}

var headers: [String : String]? {
var headers: [String: String]? {
switch self {
case let .refresh(refreshToken):
return ["refreshToken": refreshToken]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ public struct DotoriLoggingInterceptor: InterceptorType {
public func willRequest(_ request: URLRequest, endpoint: EndpointType) {
let url = request.description
let method = request.httpMethod ?? "unknown method"
var log = "----------------------------------------------------\n\n[\(method)] \(url)\n\n----------------------------------------------------\n"
var log =
"----------------------------------------------------\n\n[\(method)] \(url)\n\n----------------------------------------------------\n"
log.append("API: \(endpoint)\n")
if let headers = request.allHTTPHeaderFields, !headers.isEmpty {
log.append("header: \(headers)\n")
Expand Down
3 changes: 2 additions & 1 deletion Projects/Core/Networking/Sources/NetworkingImpl.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ private extension NetworkingImpl {
else {
throw error
}
throw dotoriEndpoint.errorMap[httpResponse.statusCode] ?? NetworkingError(statusCode: httpResponse.statusCode)
throw dotoriEndpoint
.errorMap[httpResponse.statusCode] ?? NetworkingError(statusCode: httpResponse.statusCode)
}
}
}
2 changes: 1 addition & 1 deletion Projects/Core/Timer/Project.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import DependencyPlugin
import ProjectDescription
import ProjectDescriptionHelpers
import DependencyPlugin

let project = Project.module(
name: ModulePaths.Core.Timer.rawValue,
Expand Down
4 changes: 2 additions & 2 deletions Projects/Core/Timer/Testing/RepeatableTimerStub.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import Combine
import Foundation
import TimerInterface

// Stub 테스트 더블 객체
/// Stub 테스트 더블 객체
class RepeatableTimerStub: RepeatableTimer {
var repeatPublisherClosure: ((TimeInterval, RunLoop, RunLoop.Mode) -> AnyPublisher<Date, Never>) = { _, _, _ in
Empty().eraseToAnyPublisher()
}

func repeatPublisher(
every interval: TimeInterval,
on runLoop: RunLoop,
Expand Down
2 changes: 1 addition & 1 deletion Projects/Domain/AuthDomain/Project.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import DependencyPlugin
import ProjectDescription
import ProjectDescriptionHelpers
import DependencyPlugin

let project = Project.module(
name: ModulePaths.Domain.AuthDomain.rawValue,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ final class RemoteAuthDataSourceImpl: RemoteAuthDataSource {
}

func networkIsConnected() async -> Bool {
return await withCheckedContinuation({ continuation in
return await withCheckedContinuation { continuation in
let monitor = NWPathMonitor()

monitor.pathUpdateHandler = { path in
Expand All @@ -36,6 +36,6 @@ final class RemoteAuthDataSourceImpl: RemoteAuthDataSource {
}
}
monitor.start(queue: DispatchQueue(label: "InternetConnectionMonitor"))
})
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import AuthDomainInterface
import XCTest
@testable import AuthDomain
import AuthDomainInterface
@testable import AuthDomainTesting
import XCTest

final class CheckIsLoggedInUseCaseTests: XCTestCase {
var authRepository: AuthRepositorySpy!
Expand Down
2 changes: 0 additions & 2 deletions Projects/Domain/BaseDomain/Tests/TargetTest.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import XCTest

class TargetTests: XCTestCase {

override func setUpWithError() throws {
// Put setup code here. This method is called before the invocation of each test method in the class.
}
Expand All @@ -13,5 +12,4 @@ class TargetTests: XCTestCase {
func testExample() throws {
XCTAssertEqual("A", "A")
}

}
2 changes: 1 addition & 1 deletion Projects/Domain/MassageDomain/Project.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import DependencyPlugin
import ProjectDescription
import ProjectDescriptionHelpers
import DependencyPlugin

let project = Project.module(
name: ModulePaths.Domain.MassageDomain.rawValue,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import BaseDomainInterface
import MassageDomainInterface
import Foundation
import MassageDomainInterface

struct FetchMassageRankListResponseDTO: Decodable {
let list: [MassageRankResponseDTO]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ extension MassageEndpoint: DotoriEndpoint {
.accessToken
}

public var errorMap: [Int : Error] {
public var errorMap: [Int: Error] {
switch self {
case .applyMassage:
return [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import NetworkingInterface
import MassageDomainInterface
import NetworkingInterface

final class RemoteMassageDataSourceImpl: RemoteMassageDataSource {
private let networking: any Networking
Expand Down
Loading

0 comments on commit b6261c7

Please sign in to comment.