Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: fix all swiftlint errors #53

Merged
merged 1 commit into from
Dec 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,16 @@ opt_in_rules:
- xct_specific_matcher
- yoda_condition
excluded:
- .git
- .swiftpm
- .build
- build
- Pods
- protobuf
- PrismAPISDK
- Sources/PrismSwiftSDK/protobuf
- Sources/PrismSwiftSDK/protobuf/*
- Tests/PrismSwiftSDKTests
- Castor/Sources/DIDParser/DIDGrammar
- Castor/Sources/DIDParser/DIDGrammar/*
- Castor/Tests
- Castor/Sources/protobuf
- Apollo/Tests
Expand All @@ -90,6 +92,7 @@ excluded:
- Pluto/Tests
- Pollux/Tests
- PrismAgent/Tests
- Mercury/Sources/TestingConstants/*
- Sample
line_length:
ignores_comments: true
Expand Down Expand Up @@ -121,4 +124,5 @@ identifier_name:
excluded:
- id
- ec
- to
reporter: "xcode"
6 changes: 5 additions & 1 deletion Castor/Sources/CastorImpl+Public.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ extension CastorImpl: Castor {
}

public func resolveDID(did: DID) async throws -> DIDDocument {
guard let document = try await resolvers.first?.resolve(did: did) else { throw CastorError.notPossibleToResolveDID }
guard
let document = try await resolvers
.first?
.resolve(did: did)
else { throw CastorError.notPossibleToResolveDID }
return document
}
}
2 changes: 1 addition & 1 deletion Core/Sources/Helpers/JSONDecoder+Helper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Foundation

public extension JSONDecoder {
static func didComm() -> JSONDecoder {
var decoder = JSONDecoder()
let decoder = JSONDecoder()
decoder.dataDecodingStrategy = .deferredToData
decoder.keyDecodingStrategy = .convertFromSnakeCase
return decoder
Expand Down
2 changes: 1 addition & 1 deletion Core/Sources/Helpers/JSONEncoder+Helper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Foundation

public extension JSONEncoder {
static func didComm() -> JSONEncoder {
var encoder = JSONEncoder()
let encoder = JSONEncoder()
encoder.dataEncodingStrategy = .deferredToData
encoder.keyEncodingStrategy = .convertToSnakeCase
encoder.outputFormatting = .prettyPrinted
Expand Down
4 changes: 2 additions & 2 deletions Domain/Sources/BBs/Mercury.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ public protocol Mercury {
func sendMessage(msg: Message) async throws -> Data?
}

extension Mercury {
public func sendMessage(msg: Message) async throws -> Message? {
public extension Mercury {
func sendMessage(msg: Message) async throws -> Message? {
guard
let msgData = try await sendMessage(msg: msg),
let msgStr = String(data: msgData, encoding: .utf8)
Expand Down
4 changes: 0 additions & 4 deletions Domain/Sources/Models/Message.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ public struct Message {
public let id: String
public let piuri: String
public let from: DID?
// swiftlint:disable identifier_name
public let to: DID?
// swiftlint:enable identifier_name
public let fromPrior: String?
public let body: Data
public let extraHeaders: [String: String]
Expand All @@ -21,9 +19,7 @@ public struct Message {
id: String = UUID().uuidString,
piuri: String,
from: DID? = nil,
// swiftlint:disable identifier_name
to: DID? = nil,
// swiftlint:enable identifier_name
fromPrior: String? = nil,
body: Data,
extraHeaders: [String : String] = [:],
Expand Down
2 changes: 1 addition & 1 deletion Pluto/Sources/Helpers/Message+Codable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ extension Message: Codable {
case ack
case body
}

public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(id, forKey: .id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ extension CDDIDPrivateKeyDAO: DIDPrivateKeyProvider {
func getDIDInfo(did: DID) -> AnyPublisher<(did: DID, privateKey: PrivateKey)?, Error> {
fetchByIDsPublisher(did.string, context: readContext)
.map {
$0.map { (DID(from: $0), PrivateKey(curve: $0.curve, value: $0.privateKey))}
}
$0.map { (DID(from: $0), PrivateKey(curve: $0.curve, value: $0.privateKey))
}}
.eraseToAnyPublisher()
}
func getPrivateKey(did: DID) -> AnyPublisher<PrivateKey?, Error> {
fetchByIDsPublisher(did.string, context: readContext)
.map { did in
did.map { PrivateKey(curve: $0.curve, value: $0.privateKey) }
}
did.map { PrivateKey(curve: $0.curve, value: $0.privateKey)
}}
.eraseToAnyPublisher()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ extension CDMediatorDIDDAO: MediatorStore {
.eraseToAnyPublisher()
}
.flatMap { peerDID, routingDID, mediatorDID in
updateOrCreate(peer.string, context: writeContext) { cdobj, context in
updateOrCreate(peer.string, context: writeContext) { cdobj, _ in
cdobj.parseFrom(peerDID: peerDID, routingDID: routingDID, mediatorDID: mediatorDID)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Domain
extension CDMessageDAO: MessageProvider {
func getAll() -> AnyPublisher<[Message], Error> {
fetchController(context: readContext)
.tryMap { try $0.map { try $0.toDomain() }}
.tryMap { try $0.map { try $0.toDomain() } }
.eraseToAnyPublisher()
}

Expand All @@ -14,7 +14,7 @@ extension CDMessageDAO: MessageProvider {
predicate: NSPredicate(format: "(pair.did == %@) OR (pair.holderDID.did == %@)", did.string, did.string),
context: readContext
)
.tryMap { try $0.map { try $0.toDomain() }}
.tryMap { try $0.map { try $0.toDomain() } }
.eraseToAnyPublisher()
}

Expand All @@ -23,7 +23,7 @@ extension CDMessageDAO: MessageProvider {
predicate: NSPredicate(format: "to == %@", did.string),
context: readContext
)
.tryMap { try $0.map { try $0.toDomain() }}
.tryMap { try $0.map { try $0.toDomain() } }
.eraseToAnyPublisher()
}

Expand All @@ -32,7 +32,7 @@ extension CDMessageDAO: MessageProvider {
predicate: NSPredicate(format: "from == %@", did.string),
context: readContext
)
.tryMap { try $0.map { try $0.toDomain() }}
.tryMap { try $0.map { try $0.toDomain() } }
.eraseToAnyPublisher()
}

Expand All @@ -41,7 +41,7 @@ extension CDMessageDAO: MessageProvider {
predicate: NSPredicate(format: "type == %@", type),
context: readContext
)
.tryMap { try $0.map { try $0.toDomain() }}
.tryMap { try $0.map { try $0.toDomain() } }
.eraseToAnyPublisher()
}

Expand All @@ -50,7 +50,7 @@ extension CDMessageDAO: MessageProvider {
predicate: NSPredicate(format: "(from == %@) OR (to == %@)", from.string, to.string),
context: readContext
)
.tryMap { try $0.map { try $0.toDomain() }}
.tryMap { try $0.map { try $0.toDomain() } }
.eraseToAnyPublisher()
}

Expand All @@ -62,7 +62,6 @@ extension CDMessageDAO: MessageProvider {
}

private extension CDMessage {

func toDomain() throws -> Message {
return try JSONDecoder().decode(Message.self, from: dataJson)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ extension CDMessageDAO: MessageStore {
}

private extension CDMessage {

func fromDomain(msg: Message, pair: CDDIDPair?) throws {
self.messageId = msg.id
self.from = msg.from?.string
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Domain
import CoreData
import Domain
import Foundation

@objc(CDDID)
Expand Down
1 change: 0 additions & 1 deletion Pollux/Sources/PolluxImpl.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import Domain

public struct PolluxImpl {

let castor: Castor

init(castor: Castor) {
Expand Down
2 changes: 1 addition & 1 deletion PrismAgent/Sources/PrismAgent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import Domain
import Foundation

public class PrismAgent {

public enum State {
case stoped
case starting
case running
case stoping
}

public enum DIDType {
case prism
case peer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ struct HandshakeRequest {
let type: String = ProtocolTypes.didcommconnectionRequest.rawValue
let id: String
let from: DID
// swiftlint:disable identifier_name
let to: DID
// swiftlint:enable identifier_name
let thid: String?
let body: Body

Expand All @@ -37,9 +35,7 @@ struct HandshakeRequest {
init(
id: String = UUID().uuidString,
from: DID,
// swiftlint:disable identifier_name
to: DID,
// swiftlint:enable identifier_name
thid: String?,
body: Body
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,15 @@ public struct IssueCredential {
let attachments: [AttachmentDescriptor]
public let thid: String?
public let from: DID
// swiftlint:disable identifier_name
public let to: DID
// swiftlint:enable identifier_name

init(
id: String = UUID().uuidString,
body: Body,
attachments: [AttachmentDescriptor],
thid: String?,
from: DID,
// swiftlint:disable identifier_name
to: DID
// swiftlint:enable identifier_name
) {
self.id = id
self.body = body
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,15 @@ public struct OfferCredential {
let attachments: [AttachmentDescriptor]
public let thid: String?
public let from: DID
// swiftlint:disable identifier_name
public let to: DID
// swiftlint:enable identifier_name

init(
id: String = UUID().uuidString,
body: Body,
attachments: [AttachmentDescriptor],
thid: String?,
from: DID,
// swiftlint:disable identifier_name
to: DID
// swiftlint:enable identifier_name
) {
self.id = id
self.body = body
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,15 @@ public struct ProposeCredential {
let attachments: [AttachmentDescriptor]
public let thid: String?
public let from: DID
// swiftlint:disable identifier_name
public let to: DID
// swiftlint:enable identifier_name

init(
id: String = UUID().uuidString,
body: Body,
attachments: [AttachmentDescriptor],
thid: String?,
from: DID,
// swiftlint:disable identifier_name
to: DID
// swiftlint:enable identifier_name
) {
self.id = id
self.body = body
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,15 @@ public struct RequestCredential {
let attachments: [AttachmentDescriptor]
public let thid: String?
public let from: DID
// swiftlint:disable identifier_name
public let to: DID
// swiftlint:enable identifier_name

init(
id: String = UUID().uuidString,
body: Body,
attachments: [AttachmentDescriptor],
thid: String?,
from: DID,
// swiftlint:disable identifier_name
to: DID
// swiftlint:enable identifier_name
) {
self.id = id
self.body = body
Expand Down
2 changes: 0 additions & 2 deletions PrismAgent/Sources/Protocols/Mediation/MediationGrant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ struct MediationGrant {
let id: String
let type = ProtocolTypes.didcommMediationGrant.rawValue
let from: DID
// swiftlint:disable identifier_name
let to: DID
// swiftlint:enable identifier_name
let body: Body

init(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ struct MediationRequest {
let id: String
let type = ProtocolTypes.didcommMediationRequest.rawValue
let from: DID
// swiftlint:disable identifier_name
let to: DID
// swiftlint:enable identifier_name

init(
id: String = UUID().uuidString,
Expand Down
2 changes: 0 additions & 2 deletions PrismAgent/Sources/Protocols/Pickup/PickupRequest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ struct PickUpRequest {
}

let from: DID
// swiftlint:disable identifier_name
let to: DID
// swiftlint:enable identifier_name
let body: Body

func makeMessage() throws -> Message {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,15 @@ public struct Presentation {
let attachments: [AttachmentDescriptor]
public let thid: String?
public let from: DID
// swiftlint:disable identifier_name
public let to: DID
// swiftlint:enable identifier_name

init(
id: String = UUID().uuidString,
body: Body,
attachments: [AttachmentDescriptor],
thid: String?,
from: DID,
// swiftlint:disable identifier_name
to: DID
// swiftlint:enable identifier_name
) {
self.id = id
self.body = body
Expand Down
Loading