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

Update SwiftLint to 0.57.0 #113

Merged
merged 4 commits into from
Dec 16, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ jobs:
uses: swift-actions/setup-swift@v2.1.0
- name: Install SwiftLint
run: |
curl -L https://github.com/realm/SwiftLint/releases/download/0.54.0/swiftlint_linux.zip -o swiftlint.zip
curl -L https://github.com/realm/SwiftLint/releases/download/0.57.0/swiftlint_linux.zip -o swiftlint.zip
unzip swiftlint.zip -d swiftlint
./swiftlint/swiftlint --version
- name: Run SwiftLint
Expand Down
6 changes: 5 additions & 1 deletion .swiftlint.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Updated for 0.53.0
# Updated for 0.57.0

excluded:
- ".build"
Expand Down Expand Up @@ -103,6 +103,10 @@ opt_in_rules:
- redundant_self_in_closure
- unhandled_throwing_task
- private_swiftui_state
- final_test_case
- prefer_key_path
- no_empty_block
- unused_parameter

disabled_rules:
- trailing_comma
Expand Down
12 changes: 6 additions & 6 deletions Sources/SwiftScraper/Browser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public class Browser: NSObject, WKNavigationDelegate, WKScriptMessageHandler {
private let moduleName: String
private let logger = Logger()
/// The webview itself
public private (set) var webView: WKWebView!
public private(set) var webView: WKWebView!
private let userContentController = WKUserContentController()
private var navigationCallback: NavigationCallback?
private var asyncScriptCallback: ScriptResponseResultCallback?
Expand Down Expand Up @@ -105,7 +105,7 @@ public class Browser: NSObject, WKNavigationDelegate, WKScriptMessageHandler {
/// - Parameters:
/// - webView: The web view that loaded the content.
/// - navigation: The navigation object that finished.
public func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
public func webView(_: WKWebView, didFinish _: WKNavigation!) {
callNavigationCompletion(result: .success(()))
}

Expand All @@ -117,8 +117,8 @@ public class Browser: NSObject, WKNavigationDelegate, WKScriptMessageHandler {
/// to track the progress of that operation.
/// - error: The error that occurred.
public func webView(
_ webView: WKWebView,
didFailProvisionalNavigation navigation: WKNavigation!,
_: WKWebView,
didFailProvisionalNavigation _: WKNavigation!,
withError error: Error
) {
logger.warning("didFailProvisionalNavigation: \(error.localizedDescription)")
Expand All @@ -132,7 +132,7 @@ public class Browser: NSObject, WKNavigationDelegate, WKScriptMessageHandler {
/// - navigation: The navigation object for the operation. This object corresponds to a WKNavigation object
/// that WebKit returned when the load operation began. You use it to track the progress of that operation.
/// - error: The error that occurred.
public func webView(_ webView: WKWebView, didFail navigation: WKNavigation!, withError error: Error) {
public func webView(_: WKWebView, didFail _: WKNavigation!, withError error: Error) {
logger.warning("didFailNavigation: \(error.localizedDescription)")
let nsError = error as NSError
if nsError.domain == "NSURLErrorDomain" && nsError.code == NSURLErrorCancelled {
Expand Down Expand Up @@ -160,7 +160,7 @@ public class Browser: NSObject, WKNavigationDelegate, WKScriptMessageHandler {
/// - userContentController: The user content controller that delivered the message to your handler.
/// - message: An object that contains the message details.
public func userContentController(
_ userContentController: WKUserContentController,
_: WKUserContentController,
didReceive message: WKScriptMessage
) {
logger.debug("WKScriptMessage didReceiveMessage")
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftScraper/JavaScriptGenerator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ enum JavaScriptGenerator {
}
if JSONSerialization.isValidJSONObject(param),
let prettyJsonData = try? JSONSerialization.data(withJSONObject: param, options: []) {
return String(decoding: prettyJsonData, as: UTF8.self)
return String(data: prettyJsonData, encoding: .utf8) ?? ""
}
throw SwiftScraperError.parameterSerialization
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftScraper/Steps/AsyncProcessStep.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class AsyncProcessStep: Step {
self.handler = handler
}

public func run(with browser: Browser, model: JSON, completion: @escaping StepCompletionCallback) {
public func run(with _: Browser, model: JSON, completion: @escaping StepCompletionCallback) {
handler(model) { model, result in
completion(result.convertToStepCompletionResult(with: model))
}
Expand Down
6 changes: 3 additions & 3 deletions Sources/SwiftScraper/Steps/DownloadStep.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ public class DownloadStep: NSObject, Step {
@available(iOS 14.5, macOS 11.3, *)
extension DownloadStep: WKDownloadDelegate {

public func download(_ download: WKDownload, decideDestinationUsing response: URLResponse, suggestedFilename: String, completionHandler: @escaping (URL?) -> Void) {
public func download(_: WKDownload, decideDestinationUsing _: URLResponse, suggestedFilename: String, completionHandler: @escaping (URL?) -> Void) {
let temporaryDir = NSTemporaryDirectory()
let fileName = temporaryDir + "/" + suggestedFilename + UUID().description
let url = URL(fileURLWithPath: fileName)
destinationURL = url
completionHandler(url)
}

public func downloadDidFinish(_ download: WKDownload) {
public func downloadDidFinish(_: WKDownload) {
do {
let text = try String(contentsOf: destinationURL, encoding: .utf8)
try? FileManager.default.removeItem(at: destinationURL)
Expand All @@ -68,7 +68,7 @@ extension DownloadStep: WKDownloadDelegate {
}
}

public func download(_ download: WKDownload, didFailWithError error: Error, resumeData: Data?) {
public func download(_: WKDownload, didFailWithError error: Error, resumeData _: Data?) {
completion?(.failure(error, model))
}

Expand Down
4 changes: 2 additions & 2 deletions Sources/SwiftScraper/Steps/ProcessStep.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public typealias ProcessStepHandler = (_ model: inout JSON) -> StepFlowResult

// MARK: - ProcessStep

/// Step that performs some processing, can update the model dictionary,
/// Step that performs some processing, can update the model dictionary,
/// and can be used to drive control flow of the steps.
public class ProcessStep: Step {

Expand All @@ -32,7 +32,7 @@ public class ProcessStep: Step {
self.handler = handler
}

public func run(with browser: Browser, model: JSON, completion: @escaping StepCompletionCallback) {
public func run(with _: Browser, model: JSON, completion: @escaping StepCompletionCallback) {
var modelCopy = model
let result = handler(&modelCopy)
completion(result.convertToStepCompletionResult(with: modelCopy))
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftScraper/Steps/WaitStep.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class WaitStep: Step {
self.waitTimeInSeconds = waitTimeInSeconds
}

public func run(with browser: Browser, model: JSON, completion: @escaping StepCompletionCallback) {
public func run(with _: Browser, model: JSON, completion: @escaping StepCompletionCallback) {
DispatchQueue.main.asyncAfter(deadline: .now() + waitTimeInSeconds) {
completion(.proceed(model))
}
Expand Down
2 changes: 1 addition & 1 deletion Tests/SwiftScraperTests/JavaScriptGeneratorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
@testable import SwiftScraper
import XCTest

class JavaScriptGeneratorTests: XCTestCase {
final class JavaScriptGeneratorTests: XCTestCase {

func testGenerateScriptNoArg() {
let script = try? JavaScriptGenerator.generateScript(moduleName: "MyModule", functionName: "doSomething")
Expand Down
2 changes: 1 addition & 1 deletion Tests/SwiftScraperTests/StepRunnerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ enum TestHelper {

}

class StepRunnerCommonTests: XCTestCase {
class StepRunnerCommonTests: XCTestCase { // swiftlint:disable:this final_test_case

var stepRunnerStates: [StepRunnerState] = [] // swiftlint:disable:this test_case_accessibility

Expand Down
Loading