Fix lint issues.
This commit is contained in:
parent
fd84481129
commit
48fc807f94
@ -108,13 +108,21 @@ public extension Article {
|
||||
result.append(text)
|
||||
}
|
||||
|
||||
if let _ = scanner.scanString("<") {
|
||||
if scanner.scanString("<") != nil {
|
||||
// All the allowed tags currently don't allow attributes
|
||||
if let tag = scanner.scanUpToString(">") {
|
||||
if Self.allowedTags.contains(tag.replacingOccurrences(of: "/", with: "")) {
|
||||
forHTML ? result.append("<\(tag)>") : result.append("")
|
||||
if forHTML {
|
||||
result.append("<\(tag)>")
|
||||
} else {
|
||||
result.append("")
|
||||
}
|
||||
} else {
|
||||
forHTML ? result.append("<\(tag)>") : result.append("<\(tag)>")
|
||||
if forHTML {
|
||||
result.append("<\(tag)>")
|
||||
} else {
|
||||
result.append("<\(tag)>")
|
||||
}
|
||||
}
|
||||
|
||||
_ = scanner.scanString(">")
|
||||
|
@ -12,8 +12,8 @@ import os
|
||||
public final class ArticleStatus: Sendable, Hashable {
|
||||
|
||||
public enum Key: String {
|
||||
case read = "read"
|
||||
case starred = "starred"
|
||||
case read
|
||||
case starred
|
||||
}
|
||||
|
||||
public let articleID: String
|
||||
|
@ -299,7 +299,7 @@ private final class StatusCache {
|
||||
|
||||
for status in statuses {
|
||||
let articleID = status.articleID
|
||||
if let _ = self[articleID] {
|
||||
if self[articleID] != nil {
|
||||
continue
|
||||
}
|
||||
self[articleID] = status
|
||||
|
@ -192,18 +192,18 @@ private extension DateParser {
|
||||
|
||||
enum Month: Int {
|
||||
|
||||
case January = 1,
|
||||
February,
|
||||
March,
|
||||
April,
|
||||
May,
|
||||
June,
|
||||
July,
|
||||
August,
|
||||
September,
|
||||
October,
|
||||
November,
|
||||
December
|
||||
case january = 1,
|
||||
february,
|
||||
march,
|
||||
april,
|
||||
may,
|
||||
june,
|
||||
july,
|
||||
august,
|
||||
september,
|
||||
october,
|
||||
november,
|
||||
december
|
||||
}
|
||||
|
||||
// MARK: - Standard Formats
|
||||
@ -291,7 +291,7 @@ private extension DateParser {
|
||||
var finalIndex = 0
|
||||
|
||||
let day = nextNumericValue(bytes, numberOfBytes, 0, 2, &finalIndex) ?? 1
|
||||
let month = nextMonthValue(bytes, numberOfBytes, finalIndex + 1, &finalIndex) ?? .January
|
||||
let month = nextMonthValue(bytes, numberOfBytes, finalIndex + 1, &finalIndex) ?? .january
|
||||
|
||||
guard let year = nextNumericValue(bytes, numberOfBytes, finalIndex + 1, 4, &finalIndex) else {
|
||||
return nil
|
||||
@ -451,7 +451,9 @@ private extension DateParser {
|
||||
characters.append(character)
|
||||
}
|
||||
|
||||
let name = String(decoding: characters, as: UTF8.self)
|
||||
guard let name = String(bytes: characters, encoding: .utf8) else {
|
||||
return nil
|
||||
}
|
||||
return timeZoneTable[name]
|
||||
}
|
||||
|
||||
@ -482,19 +484,19 @@ private extension DateParser {
|
||||
numberOfAlphaCharactersFound+=1
|
||||
if numberOfAlphaCharactersFound == 1 {
|
||||
if ch == DateCharacter.F || ch == DateCharacter.f {
|
||||
return .February
|
||||
return .february
|
||||
}
|
||||
if ch == DateCharacter.S || ch == DateCharacter.s {
|
||||
return .September
|
||||
return .september
|
||||
}
|
||||
if ch == DateCharacter.O || ch == DateCharacter.o {
|
||||
return .October
|
||||
return .october
|
||||
}
|
||||
if ch == DateCharacter.N || ch == DateCharacter.n {
|
||||
return .November
|
||||
return .november
|
||||
}
|
||||
if ch == DateCharacter.D || ch == DateCharacter.d {
|
||||
return .December
|
||||
return .december
|
||||
}
|
||||
}
|
||||
|
||||
@ -510,32 +512,32 @@ private extension DateParser {
|
||||
|
||||
if monthCharacters[0] == DateCharacter.J || monthCharacters[0] == DateCharacter.j { // Jan, Jun, Jul
|
||||
if monthCharacters[1] == DateCharacter.A || monthCharacters[1] == DateCharacter.a {
|
||||
return .January
|
||||
return .january
|
||||
}
|
||||
if monthCharacters[1] == DateCharacter.U || monthCharacters[1] == DateCharacter.u {
|
||||
if monthCharacters[2] == DateCharacter.N || monthCharacters[2] == DateCharacter.n {
|
||||
return .June
|
||||
return .june
|
||||
}
|
||||
return .July
|
||||
return .july
|
||||
}
|
||||
return .January
|
||||
return .january
|
||||
}
|
||||
|
||||
if monthCharacters[0] == DateCharacter.M || monthCharacters[0] == DateCharacter.m { // March, May
|
||||
if monthCharacters[2] == DateCharacter.Y || monthCharacters[2] == DateCharacter.y {
|
||||
return .May
|
||||
return .may
|
||||
}
|
||||
return .March
|
||||
return .march
|
||||
}
|
||||
|
||||
if monthCharacters[0] == DateCharacter.A || monthCharacters[0] == DateCharacter.a { // April, August
|
||||
if monthCharacters[1] == DateCharacter.U || monthCharacters[1] == DateCharacter.u {
|
||||
return .August
|
||||
return .august
|
||||
}
|
||||
return .April
|
||||
return .april
|
||||
}
|
||||
|
||||
return .January // Should never get here (but possibly do)
|
||||
return .january // Should never get here (but possibly do)
|
||||
}
|
||||
|
||||
private static func nextNumericValue(_ bytes: DateBuffer, _ numberOfBytes: Int, _ startingIndex: Int, _ maximumNumberOfDigits: Int, _ finalIndex: inout Int) -> Int? {
|
||||
|
@ -12,7 +12,7 @@ public class RSToolbarItem: NSToolbarItem {
|
||||
|
||||
override public func validate() {
|
||||
|
||||
guard let view = view, let _ = view.window else {
|
||||
guard view?.window != nil else {
|
||||
isEnabled = false
|
||||
return
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ import AppKit
|
||||
|
||||
public func writableTypes(for pasteboard: NSPasteboard) -> [NSPasteboard.PasteboardType] {
|
||||
|
||||
if let _ = URL(string: urlString) {
|
||||
if URL(string: urlString) != nil {
|
||||
return [.URL, .string]
|
||||
}
|
||||
return [.string]
|
||||
|
@ -56,11 +56,11 @@ public final class BatchUpdate {
|
||||
private extension BatchUpdate {
|
||||
|
||||
func incrementCount() {
|
||||
count = count + 1
|
||||
count += 1
|
||||
}
|
||||
|
||||
func decrementCount() {
|
||||
count = count - 1
|
||||
count -= 1
|
||||
if count < 1 {
|
||||
assert(count > -1, "Expected batch updates count to be 0 or greater.")
|
||||
count = 0
|
||||
|
@ -88,6 +88,8 @@ public extension Data {
|
||||
static let lessThan = "<".utf8.first!
|
||||
static let greaterThan = ">".utf8.first!
|
||||
|
||||
// swiftlint:disable non_optional_string_data_conversion
|
||||
|
||||
/// Tags in UTF-8/ASCII format.
|
||||
enum UTF8 {
|
||||
static let lowercaseHTML = "html".data(using: .utf8)!
|
||||
@ -104,6 +106,7 @@ public extension Data {
|
||||
static let uppercaseBody = "BODY".data(using: .utf16LittleEndian)!
|
||||
}
|
||||
|
||||
// swiftlint:enable non_optional_string_data_conversion
|
||||
}
|
||||
|
||||
/// Returns `true` if the data looks like it could be HTML.
|
||||
|
@ -326,16 +326,16 @@ public extension String {
|
||||
|
||||
for char in self {
|
||||
switch char {
|
||||
case "&":
|
||||
escaped.append("&")
|
||||
case "<":
|
||||
escaped.append("<")
|
||||
case ">":
|
||||
escaped.append(">")
|
||||
case "\"":
|
||||
escaped.append(""")
|
||||
default:
|
||||
escaped.append(char)
|
||||
case "&":
|
||||
escaped.append("&")
|
||||
case "<":
|
||||
escaped.append("<")
|
||||
case ">":
|
||||
escaped.append(">")
|
||||
case "\"":
|
||||
escaped.append(""")
|
||||
default:
|
||||
escaped.append(char)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,14 +8,13 @@
|
||||
|
||||
import XCTest
|
||||
|
||||
class String_RSCore: XCTestCase {
|
||||
class StringRSCore: XCTestCase {
|
||||
|
||||
func testCollapsingWhitespace() {
|
||||
|
||||
let str = " lots\t\tof random\n\nwhitespace\r\n"
|
||||
let expected = "lots of random whitespace"
|
||||
XCTAssertEqual(str.collapsingWhitespace, expected)
|
||||
|
||||
}
|
||||
|
||||
func testTrimmingWhitespace() {
|
||||
@ -103,7 +102,6 @@ class String_RSCore: XCTestCase {
|
||||
let str = #"<foo attr="value">bar&baz</foo>"#
|
||||
let expected = "<foo attr="value">bar&baz</foo>"
|
||||
XCTAssertEqual(str.escapingSpecialXMLCharacters, expected)
|
||||
|
||||
}
|
||||
|
||||
func testStrippingHTTPOrHTTPSScheme() {
|
||||
@ -117,7 +115,6 @@ class String_RSCore: XCTestCase {
|
||||
|
||||
let noreplacement = "example://ranchero.com/"
|
||||
XCTAssertEqual(noreplacement.strippingHTTPOrHTTPSScheme, noreplacement)
|
||||
|
||||
}
|
||||
|
||||
func testNormalizedURL() {
|
||||
@ -150,7 +147,6 @@ class String_RSCore: XCTestCase {
|
||||
// bare
|
||||
let http = "http://daringfireball.net/"
|
||||
XCTAssertEqual(http.normalizedURL, "http://daringfireball.net/")
|
||||
|
||||
}
|
||||
|
||||
func testMD5StringPerformance() {
|
||||
@ -181,5 +177,4 @@ class String_RSCore: XCTestCase {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -21,10 +21,7 @@ public final class Node: Hashable {
|
||||
private static var incrementingID = 0
|
||||
|
||||
public var isRoot: Bool {
|
||||
if let _ = parent {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
parent == nil
|
||||
}
|
||||
|
||||
public var numberOfChildNodes: Int {
|
||||
|
Loading…
x
Reference in New Issue
Block a user