scinfu / SwiftSoup

SwiftSoup: Pure Swift HTML Parser, with best of DOM, CSS, and jquery (Supports Linux, iOS, Mac, tvOS, watchOS)
https://scinfu.github.io/SwiftSoup/
MIT License
4.52k stars 345 forks source link

Issue with not valid syntax on property unwrapping #252

Closed geraldkfzteile24 closed 10 months ago

geraldkfzteile24 commented 10 months ago

In the code snippet within Cleaner.swift:

if let headWhitelist, let dirtHead = dirtyDocument.head(), let cleanHead = clean.head() {
    // ...
}

The problem arises because the headWhitelist is included in the if let statement without an associated optional unwrapping expression. This is not valid in Swift's syntax. The correct approach is to either provide an initializer for each variable in an if let statement or to ensure that each variable is an optional being unwrapped.

The CI is failing because of it.

❌  /Users/runner/work/ios-app/ios-app/Pods/SwiftSoup/Sources/Cleaner.swift:36:29: variable binding in a condition requires an initializer

        if let headWhitelist, let dirtHead = dirtyDocument.head(), let cleanHead = clean.head() *** // frameset documents won't have a head. the clean doc will have empty head.

Suggested solution

if let headWhitelist = headWhitelist, let dirtHead = dirtyDocument.head(), let cleanHead = clean.head() {
    // ...
}
geraldkfzteile24 commented 10 months ago

Upgrading the CI Xcode version to 14.3 solved the issue