From 9b44b5ab8b1206125500f58984d619b8c3edb454 Mon Sep 17 00:00:00 2001 From: maximkrouk Date: Wed, 30 Nov 2022 10:49:20 +0100 Subject: [PATCH] style: Format places not handled by ci --- .../FunctionalConfigurator/Configurator.swift | 34 ++++++++++++++----- .../FunctionalKeyPath/FunctionalKeyPath.swift | 5 ++- .../BuilderTests.swift | 21 ++++++------ 3 files changed, 40 insertions(+), 20 deletions(-) diff --git a/Sources/FunctionalConfigurator/Configurator.swift b/Sources/FunctionalConfigurator/Configurator.swift index 7e6e44a..3f0bea3 100644 --- a/Sources/FunctionalConfigurator/Configurator.swift +++ b/Sources/FunctionalConfigurator/Configurator.swift @@ -140,13 +140,18 @@ extension Configurator { } public func callAsFunction(_ value: Value) -> Configurator { - _block.configurator.appendingConfiguration { _block.keyPath.embed(value, in: $0) } + _block.configurator.appendingConfiguration { + _block.keyPath.embed(value, in: $0) + } } public func set(_ transform: @escaping (inout Value) -> Void) -> Configurator { _block.configurator.appendingConfiguration { base in _block.keyPath.embed( - modification(of: _block.keyPath.extract(from: base), with: transform), + modification( + of: _block.keyPath.extract(from: base), + with: transform + ), in: base ) } @@ -157,7 +162,10 @@ extension Configurator { ) -> Configurator { _block.configurator.appendingConfiguration { base in _block.keyPath.embed( - _modification(of: _block.keyPath.extract(from: base), with: configuration), + _modification( + of: _block.keyPath.extract(from: base), + with: configuration + ), in: base ) } @@ -167,7 +175,9 @@ extension Configurator { _ configuration: @escaping (Configurator) -> Configurator ) -> Configurator where Value == Wrapped? { _block.configurator.appendingConfiguration { base in - guard let value = _block.keyPath.extract(from: base) else { return base } + guard let value = _block.keyPath.extract(from: base) + else { return base } + return _block.keyPath.embed( _modification(of: value, with: configuration), in: base @@ -180,7 +190,8 @@ extension Configurator { ) -> CallableBlock { CallableBlock( configurator: _block.configurator, - keyPath: _block.keyPath.appending(path: FunctionalKeyPath(keyPath)) + keyPath: _block.keyPath + .appending(path: FunctionalKeyPath(keyPath)) ) } @@ -195,7 +206,9 @@ extension Configurator { ) -> CallableBlock where Value == Wrapped? { CallableBlock( configurator: _block.configurator, - keyPath: _block.keyPath.appending(path: FunctionalKeyPath(keyPath).optional()) + keyPath: _block.keyPath.appending( + path: FunctionalKeyPath(keyPath).optional() + ) ) } @@ -216,7 +229,10 @@ extension Configurator { ) -> Configurator where Value: AnyObject { configurator.appendingConfiguration { base in keyPath.embed( - _modification(of: keyPath.extract(from: base), with: configuration), + _modification( + of: keyPath.extract(from: base), + with: configuration + ), in: base ) } @@ -226,7 +242,9 @@ extension Configurator { _ configuration: @escaping (Configurator) -> Configurator ) -> Configurator where Wrapped: AnyObject, Value == Wrapped? { configurator.appendingConfiguration { base in - guard let value = keyPath.extract(from: base) else { return base } + guard let value = keyPath.extract(from: base) + else { return base } + return keyPath.embed( _modification(of: value, with: configuration), in: base diff --git a/Sources/FunctionalKeyPath/FunctionalKeyPath.swift b/Sources/FunctionalKeyPath/FunctionalKeyPath.swift index 48b95dd..ddfa1ee 100644 --- a/Sources/FunctionalKeyPath/FunctionalKeyPath.swift +++ b/Sources/FunctionalKeyPath/FunctionalKeyPath.swift @@ -13,7 +13,10 @@ public struct FunctionalKeyPath { /// - Parameters: /// - embed: A function that always succeeds in embedding a value in a root. /// - extract: A function that can optionally fail in extracting a value from a root. - public init(embed: @escaping (Value, Root) -> Root, extract: @escaping (Root) -> Value) { + public init( + embed: @escaping (Value, Root) -> Root, + extract: @escaping (Root) -> Value + ) { self._embed = embed self._extract = extract } diff --git a/Tests/DeclarativeConfigurationTests/BuilderTests.swift b/Tests/DeclarativeConfigurationTests/BuilderTests.swift index d0239c0..467c8e2 100644 --- a/Tests/DeclarativeConfigurationTests/BuilderTests.swift +++ b/Tests/DeclarativeConfigurationTests/BuilderTests.swift @@ -91,17 +91,16 @@ final class BuilderTests: XCTestCase { let initial = Container() let actual = Container().builder - .content.scope { - $0 - .a(1) - .b(2) - .c(3) - .innerClass - .ifLetScope { - $0 - .value(1) - } - }.build() + .content.scope { $0 + .a(1) + .b(2) + .c(3) + .innerClass + .ifLetScope { $0 + .value(1) + } + } + .build() XCTAssertNotEqual(actual.content.a, initial.content.a) XCTAssertNotEqual(actual.content.b, initial.content.b)