From 892a0d9819ab3da7395b549cf037e98ed70b9dd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Herculano?= Date: Wed, 24 Jan 2024 17:03:41 +0000 Subject: [PATCH] fix linting issues --- .swiftlint.yml | 7 ++++--- ConsentViewController/Classes/Constants.swift | 2 ++ ConsentViewController/Classes/Extensions/Date.swift | 2 ++ ConsentViewController/Classes/OSLogger.swift | 11 +++++++---- ConsentViewController/Classes/SPError.swift | 2 ++ .../Classes/SPMessageViewController.swift | 2 ++ .../Classes/SourcePointClient/SourcePointClient.swift | 2 ++ .../SourcepointClientCoordinator.swift | 3 ++- .../Classes/Views/iOS/SPWebViewExtensions.swift | 2 ++ .../SPGDPRNativePrivacyManagerViewController.swift | 2 ++ Example/.swiftlint.yml | 7 ++++--- Example/ConsentViewController/ViewController.swift | 2 ++ 12 files changed, 33 insertions(+), 11 deletions(-) diff --git a/.swiftlint.yml b/.swiftlint.yml index d7bbfb342..9fef9f7a7 100644 --- a/.swiftlint.yml +++ b/.swiftlint.yml @@ -6,6 +6,9 @@ disabled_rules: - switch_case_alignment - void_function_in_ternary +analyzer_rules: + - unused_declaration + - unused_import opt_in_rules: - force_unwrapping - trailing_semicolon @@ -21,9 +24,7 @@ opt_in_rules: - unused_capture_list - unused_closure_parameter - unused_control_flow_label - - unused_declaration - unused_enumerated - - unused_import - unused_optional_binding - unused_setter_value - valid_ibinspectable @@ -40,8 +41,8 @@ opt_in_rules: - yoda_condition included: # paths to include during linting. `--path` is ignored if present. - ConsentViewController/Classes - - Example excluded: # paths to ignore during linting. Takes precedence over `included`. + - Example/* - Example/AuthExample - Example/Pods - Example/SourcePointMetaAppUITests diff --git a/ConsentViewController/Classes/Constants.swift b/ConsentViewController/Classes/Constants.swift index c13fd6f2a..39a3fd13c 100644 --- a/ConsentViewController/Classes/Constants.swift +++ b/ConsentViewController/Classes/Constants.swift @@ -60,3 +60,5 @@ struct Constants { static let prod = (Bundle.framework.object(forInfoDictionaryKey: "SPEnv") as? String) != "preprod" } + +// swiftlint:enable force_unwrapping diff --git a/ConsentViewController/Classes/Extensions/Date.swift b/ConsentViewController/Classes/Extensions/Date.swift index 03636366c..a8478e692 100644 --- a/ConsentViewController/Classes/Extensions/Date.swift +++ b/ConsentViewController/Classes/Extensions/Date.swift @@ -22,3 +22,5 @@ extension Date { Calendar.current.date(bySettingHour: 12, minute: 0, second: 0, of: self)! } } + +// swiftlint:enable force_unwrapping diff --git a/ConsentViewController/Classes/OSLogger.swift b/ConsentViewController/Classes/OSLogger.swift index 338eed197..49d59442e 100644 --- a/ConsentViewController/Classes/OSLogger.swift +++ b/ConsentViewController/Classes/OSLogger.swift @@ -3,11 +3,12 @@ // GDPRConsentViewController // // Created by Andre Herculano on 06.10.19. -// swiftlint:disable all import Foundation import os +// swiftlint:disable force_unwrapping + protocol SPLogger { func log(_ message: String) func debug(_ message: String) @@ -126,15 +127,15 @@ struct NoopLogger: SPLogger { struct OSLogger: SPLogger { static let category = "SPSDK" static var standard: OSLogger { OSLogger() } - private let logger: SPLogger - - static var defaultLevel: SPLogLevel { + static var defaultLevel: SPLogLevel { SPLogLevel(rawValue: Bundle.main.object(forInfoDictionaryKey: "SPLogLevel") as? String ?? Bundle.framework.object(forInfoDictionaryKey: "SPLogLevel") as? String ?? "prod" ) ?? .prod} + private let logger: SPLogger + private init (level: SPLogLevel? = Self.defaultLevel) { if level == .prod { logger = NoopLogger() @@ -177,3 +178,5 @@ struct OSLogger: SPLogger { logger.error(message) } } + +// swiftlint:enable force_unwrapping diff --git a/ConsentViewController/Classes/SPError.swift b/ConsentViewController/Classes/SPError.swift index 677b6ce26..aa9774880 100644 --- a/ConsentViewController/Classes/SPError.swift +++ b/ConsentViewController/Classes/SPError.swift @@ -312,3 +312,5 @@ public enum InvalidResponsAPICode: String { "\(rawValue)" } } + +// swiftlint:enable line_length diff --git a/ConsentViewController/Classes/SPMessageViewController.swift b/ConsentViewController/Classes/SPMessageViewController.swift index 32a3da8f1..c1111b0a1 100644 --- a/ConsentViewController/Classes/SPMessageViewController.swift +++ b/ConsentViewController/Classes/SPMessageViewController.swift @@ -101,3 +101,5 @@ extension RenderingAppEvents: ExpressibleByStringLiteral { fatalError("not implemented") } } + +// swiftlint:enable unavailable_function diff --git a/ConsentViewController/Classes/SourcePointClient/SourcePointClient.swift b/ConsentViewController/Classes/SourcePointClient/SourcePointClient.swift index 39fc2a47d..2bed628b2 100644 --- a/ConsentViewController/Classes/SourcePointClient/SourcePointClient.swift +++ b/ConsentViewController/Classes/SourcePointClient/SourcePointClient.swift @@ -539,3 +539,5 @@ extension SourcePointClient { } } } + +// swiftlint:enable function_parameter_count diff --git a/ConsentViewController/Classes/SourcePointClient/SourcepointClientCoordinator.swift b/ConsentViewController/Classes/SourcePointClient/SourcepointClientCoordinator.swift index f2904632b..13dd45dc1 100644 --- a/ConsentViewController/Classes/SourcePointClient/SourcepointClientCoordinator.swift +++ b/ConsentViewController/Classes/SourcePointClient/SourcepointClientCoordinator.swift @@ -522,7 +522,6 @@ class SourcepointClientCoordinator: SPClientCoordinator { } } - // swiftlint:disable:next function_body_length func handleConsentStatusResponse(_ response: ConsentStatusResponse) { state.localState = response.localState if let gdpr = response.consentStatusData.gdpr { @@ -1079,3 +1078,5 @@ class SourcepointClientCoordinator: SPClientCoordinator { spClient.setRequestTimeout(timeout) } } + +// swiftlint:enable type_body_length diff --git a/ConsentViewController/Classes/Views/iOS/SPWebViewExtensions.swift b/ConsentViewController/Classes/Views/iOS/SPWebViewExtensions.swift index 73f1c8f5f..718a33e9a 100644 --- a/ConsentViewController/Classes/Views/iOS/SPWebViewExtensions.swift +++ b/ConsentViewController/Classes/Views/iOS/SPWebViewExtensions.swift @@ -109,3 +109,5 @@ import WebKit getCookies { handler($0[name, default: ""], $1) } } } + +// swiftlint:enable line_length diff --git a/ConsentViewController/Classes/Views/tvOS/NativePrivacyManager/GDPR/SPGDPRNativePrivacyManagerViewController.swift b/ConsentViewController/Classes/Views/tvOS/NativePrivacyManager/GDPR/SPGDPRNativePrivacyManagerViewController.swift index 7ca36514f..c247f204c 100644 --- a/ConsentViewController/Classes/Views/tvOS/NativePrivacyManager/GDPR/SPGDPRNativePrivacyManagerViewController.swift +++ b/ConsentViewController/Classes/Views/tvOS/NativePrivacyManager/GDPR/SPGDPRNativePrivacyManagerViewController.swift @@ -316,3 +316,5 @@ class FocusableScrollView: UIScrollView { true } } + +// swiftlint:enable function_body_length diff --git a/Example/.swiftlint.yml b/Example/.swiftlint.yml index c52a485ee..4a47447de 100644 --- a/Example/.swiftlint.yml +++ b/Example/.swiftlint.yml @@ -4,6 +4,9 @@ disabled_rules: - switch_case_alignment - void_function_in_ternary +analyzer_rules: + - unused_declaration + - unused_import opt_in_rules: - force_unwrapping - trailing_semicolon @@ -19,9 +22,7 @@ opt_in_rules: - unused_capture_list - unused_closure_parameter - unused_control_flow_label - - unused_declaration - unused_enumerated - - unused_import - unused_optional_binding - unused_setter_value - valid_ibinspectable @@ -38,8 +39,8 @@ opt_in_rules: - yoda_condition included: # paths to include during linting. `--path` is ignored if present. - ../ConsentViewController/Classes - - ./ excluded: # paths to ignore during linting. Takes precedence over `included`. + - ./ - AuthExample - Pods - SourcePointMetaAppUITests diff --git a/Example/ConsentViewController/ViewController.swift b/Example/ConsentViewController/ViewController.swift index 22e5a3b87..937dfe80b 100644 --- a/Example/ConsentViewController/ViewController.swift +++ b/Example/ConsentViewController/ViewController.swift @@ -196,3 +196,5 @@ extension ViewController { sdkStatusLabel.text = sdkStatus.rawValue } } + +// swiftlint:enable force_unwrapping