Skip to content

Commit

Permalink
Fix SwiftLint warnings (#70)
Browse files Browse the repository at this point in the history
  • Loading branch information
anian03 authored Aug 24, 2024
1 parent 76243e7 commit dbcfc4d
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 15 deletions.
10 changes: 5 additions & 5 deletions Sources/APIClient/APIClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ public final class APIClient {
(by specifying RawResponse as ResponseType in Request) return the raw response
*/
if T.self is RawResponse.Type {
let rawData = String(data: data, encoding: .utf8)
return .success((RawResponse(rawData: rawData ?? "") as! T, response.statusCode))
let rawData = String(decoding: data, as: UTF8.self)
return .success((RawResponse(rawData: rawData) as! T, response.statusCode))
}
do {
let decoder = JSONDecoder()
Expand Down Expand Up @@ -139,8 +139,8 @@ public final class APIClient {
(by specifying RawResponse as ResponseType in Request) return the raw response
*/
if T.Response.self is RawResponse.Type {
let rawData = String(data: data, encoding: .utf8)
return .success((RawResponse(rawData: rawData ?? "") as! T.Response, response.statusCode))
let rawData = String(decoding: data, as: UTF8.self)
return .success((RawResponse(rawData: rawData) as! T.Response, response.statusCode))
}
do {
let decoder = JSONDecoder()
Expand Down Expand Up @@ -209,7 +209,7 @@ extension APIClient {
"""
\n––––––––––––––––––––––––––––––––––––––––Request––––––––––––––––––––––––––––––––––––––––––
\(urlRequest.httpMethod ?? "empty") \(urlRequest.url?.absoluteString ?? "empty")
Body: \(String(data: urlRequest.httpBody ?? Data(), encoding: .utf8) ?? "")
Body: \(String(decoding: urlRequest.httpBody ?? Data(), as: UTF8.self))
Length: \(urlRequest.httpBody?.debugDescription ?? "0")
Content-Type: \(urlRequest.value(forHTTPHeaderField: "Content-Type") ?? "unknown")
–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––\n
Expand Down
2 changes: 2 additions & 0 deletions Sources/PushNotifications/Models/PushNotification.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
// Copyright © 2023 orgName. All rights reserved.
//

// swiftlint:disable file_length

import Foundation

enum PushNotificationVersionError: Error {
Expand Down
2 changes: 1 addition & 1 deletion Sources/SharedModels/Course/CoursesForDashboardDTO.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ public struct CoursesForDashboardDTO: Codable {
}

public extension CoursesForDashboardDTO {
public static let mock = CoursesForDashboardDTO(courses: [.mock], activeExams: nil)
static let mock = CoursesForDashboardDTO(courses: [.mock], activeExams: nil)
}
2 changes: 1 addition & 1 deletion Sources/SharedModels/Exercise/Submission/Result.swift
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public struct Result: Codable {
return .noResult
}
} else if score != nil,
(assessmentDueDate == nil || assessmentDueDate! >= .now) {
assessmentDueDate == nil || assessmentDueDate! >= .now {
// Submission is not in due time of exercise, has a result with score and there is no assessmentDueDate for the exercise or it lies in the past.
// TODO: handle external submissions with new status "External"
return .late
Expand Down
4 changes: 2 additions & 2 deletions Sources/SharedModels/Exercise/Submission/TextSubmission.swift
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ public struct TextBlock: Codable {
let endIndex = endIndex ?? 0
let text = text ?? ""

let idData = "\(submissionId);\(startIndex)-\(endIndex);\(text)".data(using: .utf8) ?? Data()
self.id = Insecure.SHA1.hash(data: idData).map({ String(format: "%02hhx", $0) }).joined()
let idData = "\(submissionId);\(startIndex)-\(endIndex);\(text)".utf8
self.id = Insecure.SHA1.hash(data: Data(idData)).map({ String(format: "%02hhx", $0) }).joined()
}
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/SharedModels/User/Account.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public struct Account: Codable {
}

public extension Account {
public static let mock = Account(
static let mock = Account(
id: 1,
login: "chloe_mitchell",
name: "Chloe Mitchell",
Expand Down
8 changes: 4 additions & 4 deletions Sources/UserStore/UserSession.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class UserSession: ObservableObject {

private func setupInstitutionSelection() {
if let institutionData = KeychainHelper.shared.read(service: "institution", account: "Artemis") {
institution = InstitutionIdentifier(value: String(data: institutionData, encoding: .utf8))
institution = InstitutionIdentifier(value: String(decoding: institutionData, as: UTF8.self))
} else {
institution = .tum
saveInstitution(identifier: .tum)
Expand All @@ -52,15 +52,15 @@ public class UserSession: ObservableObject {

private func setupLoginData() {
if let tokenData = KeychainHelper.shared.read(service: "isLoggedIn", account: "Artemis") {
isLoggedIn = String(data: tokenData, encoding: .utf8) == "true"
isLoggedIn = String(decoding: tokenData, as: UTF8.self) == "true"
}

if let username = KeychainHelper.shared.read(service: "username", account: "Artemis") {
self.username = String(data: username, encoding: .utf8)
self.username = String(decoding: username, as: UTF8.self)
}

if let password = KeychainHelper.shared.read(service: "password", account: "Artemis") {
self.password = String(data: password, encoding: .utf8)
self.password = String(decoding: password, as: UTF8.self)
}
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/UserStore/UserSessionFactory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import Common

public enum UserSessionFactory: DependencyFactory {
public static let liveValue: UserSession = UserSession()
public static let liveValue = UserSession()

public static let testValue: UserSession = UserSessionStub()
}

0 comments on commit dbcfc4d

Please sign in to comment.