Skip to content

Commit

Permalink
style(ci): run swiftformat
Browse files Browse the repository at this point in the history
  • Loading branch information
maximkrouk authored and github-actions[bot] committed Nov 30, 2022
1 parent c729a3a commit 5731d20
Show file tree
Hide file tree
Showing 10 changed files with 64 additions and 62 deletions.
4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,14 @@ let package = Package(
.target(
name: "FunctionalKeyPath",
dependencies: [
.target(name: "FunctionalModification")
.target(name: "FunctionalModification"),
]
),
.target(name: "FunctionalModification"),
.testTarget(
name: "DeclarativeConfigurationTests",
dependencies: [
.target(name: "DeclarativeConfiguration")
.target(name: "DeclarativeConfiguration"),
]
),
]
Expand Down
5 changes: 2 additions & 3 deletions Sources/FunctionalBuilder/Builder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ public struct Builder<Base> {
_ initialValue: @escaping () -> Base,
_ configurator: Configurator<Base>
) {
_initialValue = initialValue
_configurator = configurator
self._initialValue = initialValue
self._configurator = configurator
}

/// Appends transformation to current configuration
Expand Down Expand Up @@ -126,7 +126,6 @@ public struct Builder<Base> {
keyPath: FunctionalKeyPath.getonly(keyPath).optional()
)
}

}

extension Builder {
Expand Down
2 changes: 1 addition & 1 deletion Sources/FunctionalClosures/DataSource.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
@propertyWrapper
public class DataSource<Input, Output> {
public struct Container {
internal var action: ((Input) -> Output)
internal var action: (Input) -> Output

public init(action: @escaping (Input) -> Output) {
self.action = action
Expand Down
60 changes: 30 additions & 30 deletions Sources/FunctionalClosures/Handler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ public class Handler<Input> {
*,
deprecated,
message:
"""
This API will be removed, \
consider using redeclaration with `(Input) -> Output` signature function. \
Feel free to discuss the API here \
https://github.com/MakeupStudio/swift-declarative-configuration/issues/1
"""
"""
This API will be removed, \
consider using redeclaration with `(Input) -> Output` signature function. \
Feel free to discuss the API here \
https://github.com/MakeupStudio/swift-declarative-configuration/issues/1
"""
)
public mutating func callAsFunction(_ behaviour: Behaviour, perform action: ((Input) -> Void)?)
{
Expand Down Expand Up @@ -100,12 +100,12 @@ public class Handler2<T0, T1> {
*,
deprecated,
message:
"""
This API will be removed, \
consider using redeclaration with `(Input) -> Output` signature function. \
Feel free to discuss the API here \
https://github.com/MakeupStudio/swift-declarative-configuration/issues/1
"""
"""
This API will be removed, \
consider using redeclaration with `(Input) -> Output` signature function. \
Feel free to discuss the API here \
https://github.com/MakeupStudio/swift-declarative-configuration/issues/1
"""
)
public mutating func callAsFunction(_ behaviour: Behaviour, perform action: ((T0, T1) -> Void)?)
{
Expand Down Expand Up @@ -174,12 +174,12 @@ public class Handler3<T0, T1, T2> {
*,
deprecated,
message:
"""
This API will be removed, \
consider using redeclaration with `(Input) -> Output` signature function. \
Feel free to discuss the API here \
https://github.com/MakeupStudio/swift-declarative-configuration/issues/1
"""
"""
This API will be removed, \
consider using redeclaration with `(Input) -> Output` signature function. \
Feel free to discuss the API here \
https://github.com/MakeupStudio/swift-declarative-configuration/issues/1
"""
)
public mutating func callAsFunction(
_ behaviour: Behaviour,
Expand Down Expand Up @@ -250,12 +250,12 @@ public class Handler4<T0, T1, T2, T3> {
*,
deprecated,
message:
"""
This API will be removed, \
consider using redeclaration with `(Input) -> Output` signature function. \
Feel free to discuss the API here \
https://github.com/MakeupStudio/swift-declarative-configuration/issues/1
"""
"""
This API will be removed, \
consider using redeclaration with `(Input) -> Output` signature function. \
Feel free to discuss the API here \
https://github.com/MakeupStudio/swift-declarative-configuration/issues/1
"""
)
public mutating func callAsFunction(
_ behaviour: Behaviour,
Expand Down Expand Up @@ -326,12 +326,12 @@ public class Handler5<T0, T1, T2, T3, T4> {
*,
deprecated,
message:
"""
This API will be removed, \
consider using redeclaration with `(Input) -> Output` signature function. \
Feel free to discuss the API here \
https://github.com/MakeupStudio/swift-declarative-configuration/issues/1
"""
"""
This API will be removed, \
consider using redeclaration with `(Input) -> Output` signature function. \
Feel free to discuss the API here \
https://github.com/MakeupStudio/swift-declarative-configuration/issues/1
"""
)
public mutating func callAsFunction(
_ behaviour: Behaviour,
Expand Down
3 changes: 1 addition & 2 deletions Sources/FunctionalConfigurator/Configurator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public struct Configurator<Base> {
///
/// Newly created configurator has no modification set up.
/// So it's `configure` function does not modify input
public init() { _configure = { $0 } }
public init() { self._configure = { $0 } }

/// Creates a configurator with a configuration function
///
Expand Down Expand Up @@ -122,7 +122,6 @@ public struct Configurator<Base> {
public static func set(_ transform: @escaping (inout Base) -> Void) -> Configurator {
Configurator().set(transform)
}

}

extension Configurator {
Expand Down
6 changes: 3 additions & 3 deletions Sources/FunctionalConfigurator/Modification.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
*,
deprecated,
message:
"""
This function will be made internal in `1.0.0` release, implement `CustomConfigurable` protocol for your object and use instance method instead
"""
"""
This function will be made internal in `1.0.0` release, implement `CustomConfigurable` protocol for your object and use instance method instead
"""
)
@inlinable
public func modification<Object>(
Expand Down
26 changes: 15 additions & 11 deletions Sources/FunctionalKeyPath/FunctionalKeyPath.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ public struct FunctionalKeyPath<Root, Value> {
@inlinable
public static func getonly(_ keyPath: KeyPath<Root, Value>) -> FunctionalKeyPath {
FunctionalKeyPath(
embed: { value, root in
return root
embed: { _, root in
root
},
extract: { root in
root[keyPath: keyPath]
Expand Down Expand Up @@ -77,7 +77,7 @@ public struct FunctionalKeyPath<Root, Value> {
/// - Parameter value: A value to embed.
/// - Returns: A root that embeds `value`.
public func embed(_ value: Value, in root: Root) -> Root {
self._embed(value, root)
_embed(value, root)
}

/// Returns a root by embedding a value.
Expand All @@ -86,15 +86,15 @@ public struct FunctionalKeyPath<Root, Value> {
///
/// - Parameter value: A value to embed.
public func embed(_ value: Value, in root: inout Root) {
root = self.embed(value, in: root)
root = embed(value, in: root)
}

/// Attempts to extract a value from a root.
///
/// - Parameter root: A root to extract from.
/// - Returns: A value iff it can be extracted from the given root, otherwise `nil`.
public func extract(from root: Root) -> Value {
self._extract(root)
_extract(root)
}

/// Returns a new functional keyPath created by appending the given functional keyPath to this one.
Expand Down Expand Up @@ -143,7 +143,8 @@ extension FunctionalKeyPath {
public static func key<Key: Hashable, _Value>(
_ key: Key
) -> FunctionalKeyPath
where Root == [Key: _Value], Value == _Value? {
where Root == [Key: _Value], Value == _Value?
{
FunctionalKeyPath(
embed: { value, root in
modification(of: root) { $0[key] = value }
Expand All @@ -153,7 +154,8 @@ extension FunctionalKeyPath {
}

public static func index(_ index: Root.Index) -> FunctionalKeyPath
where Root: MutableCollection, Value == Root.Element {
where Root: MutableCollection, Value == Root.Element
{
FunctionalKeyPath(
embed: { value, root in
modification(of: root) { root in
Expand All @@ -167,15 +169,17 @@ extension FunctionalKeyPath {
}

public static func getonlyIndex(_ index: Root.Index) -> FunctionalKeyPath
where Root: Collection, Value == Root.Element {
where Root: Collection, Value == Root.Element
{
FunctionalKeyPath(
embed: { _, root in return root },
embed: { _, root in root },
extract: { $0[index] }
)
}

public static func safeIndex(_ index: Root.Index) -> FunctionalKeyPath<Root, Value?>
where Root == [Value] {
where Root == [Value]
{
FunctionalKeyPath<Root, Value?>(
embed: { value, root in
modification(of: root) { root in
Expand All @@ -187,7 +191,7 @@ extension FunctionalKeyPath {
}
},
extract: { root in
return root.indices.contains(index)
root.indices.contains(index)
? root[index]
: nil
}
Expand Down
2 changes: 1 addition & 1 deletion Tests/DeclarativeConfigurationTests/BuilderTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ final class BuilderTests: XCTestCase {
var b: Int = 0
var c: Int = 0
let innerClass: InnerClass? = nil
var innerStruct: InnerStruct? = nil
var innerStruct: InnerStruct?

init() {}
}
Expand Down
8 changes: 4 additions & 4 deletions Tests/DeclarativeConfigurationTests/ConfiguratorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ final class ConfiguratorTests: XCTestCase {

let configurator =
wrappedConfiguator
.combined(with: valueConfigurator)
.combined(with: valueConfigurator)

let initial = TestConfigurable()
let expected = TestConfigurable(value: true, wrapped: .init(value: 1))
Expand Down Expand Up @@ -99,7 +99,7 @@ final class ConfiguratorTests: XCTestCase {
struct TestConfigurable: CustomConfigurable {
internal init(value: Bool = false, wrappedValue: Int = 0) {
self.value = value
self.wrapped?.value = wrappedValue
wrapped?.value = wrappedValue
}

class Wrapped: NSObject {
Expand All @@ -108,7 +108,7 @@ final class ConfiguratorTests: XCTestCase {
}

var value = false
let _wrapped: Wrapped = Wrapped()
let _wrapped: Wrapped = .init()
var wrapped: Wrapped? { _wrapped }
}

Expand Down Expand Up @@ -141,7 +141,7 @@ final class ConfiguratorTests: XCTestCase {
var b: Int = 0
var c: Int = 0
let innerClass: InnerClass? = nil
var innerStruct: InnerStruct? = nil
var innerStruct: InnerStruct?

init() {}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ final class FunctionalClosuresTests: XCTestCase {
func testBasicUsage() {
class Object: NSObject {
@DataSource<(Int, Int), Int>
var sum = .init { $0 + $1 } // You can specify default handler
var sum = .init { $0 + $1 } // You can specify default handler

@Handler<Int>
var handleSumResult // or leave it nil
var handleSumResult // or leave it nil

func sumOf(_ a: Int, _ b: Int) -> Int? {
let result = _sum((a, b))
Expand All @@ -25,7 +25,7 @@ final class FunctionalClosuresTests: XCTestCase {
let a = 10
let b = 20
let c = 30
var storageForHandler: Int? = nil
var storageForHandler: Int?

object.handleSumResult { int in
storageForHandler = int
Expand All @@ -52,10 +52,10 @@ final class FunctionalClosuresTests: XCTestCase {
func testUsageWithBuilder() {
final class Object: ConfigInitializable {
@DataSource<(Int, Int), Int>
var sum = .init { $0 + $1 } // You can specify default handler
var sum = .init { $0 + $1 } // You can specify default handler

@Handler3<Int, Int, Int>
var handleSum // or leave it nil
var handleSum // or leave it nil

init() {}

Expand Down

0 comments on commit 5731d20

Please sign in to comment.