mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2026-12-02 02:22:25 +00:00
Fix various SwiftLint warnings.
This commit is contained in:
1 parent
fb1b901efe
commit
e45490fb1e
36 files changed
+53
-106
No files matched your search
@@ -117,8 +117,7 @@ final class AppDefaults: Sendable {
|
||||
if let appGroupID = Bundle.main.object(forInfoDictionaryKey: "AppGroup") as? String,
|
||||
let appGroupDefaults = UserDefaults(suiteName: appGroupID) {
|
||||
return appGroupDefaults
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return UserDefaults.standard
|
||||
}
|
||||
}
|
||||
@@ -439,8 +438,7 @@ private extension AppDefaults {
|
||||
static func setSortDirection(for key: String, _ value: ComparisonResult) {
|
||||
if value == .orderedAscending {
|
||||
setInt(for: key, ComparisonResult.orderedAscending.rawValue)
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
setInt(for: key, ComparisonResult.orderedDescending.rawValue)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,8 +64,7 @@ final class InspectorWindowController: NSWindowController {
|
||||
|
||||
if let savedOrigin = originFromDefaults() {
|
||||
window?.setFlippedOriginAdjustingForScreen(savedOrigin)
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
window?.flippedOrigin = NSPoint(x: 256, y: 256)
|
||||
}
|
||||
}
|
||||
@@ -77,8 +76,7 @@ final class InspectorWindowController: NSWindowController {
|
||||
for inspector in inspectors {
|
||||
if inspector.isFallbackInspector {
|
||||
fallbackInspector = inspector
|
||||
}
|
||||
else if let objects = objects, inspector.canInspect(objects) {
|
||||
} else if let objects = objects, inspector.canInspect(objects) {
|
||||
return inspector
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,8 +39,7 @@ private extension NothingInspectorViewController {
|
||||
if let objects = objects, objects.count > 1 {
|
||||
nothingTextField?.isHidden = true
|
||||
multipleTextField?.isHidden = false
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
nothingTextField?.isHidden = false
|
||||
multipleTextField?.isHidden = true
|
||||
}
|
||||
|
||||
@@ -25,8 +25,7 @@ final class DetailStatusBarView: NSView {
|
||||
if let link = linkForDisplay {
|
||||
urlLabel.stringValue = link
|
||||
self.isHidden = false
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
urlLabel.stringValue = ""
|
||||
self.isHidden = true
|
||||
}
|
||||
@@ -68,8 +67,7 @@ private extension DetailStatusBarView {
|
||||
func updateLinkForDisplay() {
|
||||
if let mouseoverLink = mouseoverLink, !mouseoverLink.isEmpty {
|
||||
linkForDisplay = mouseoverLink.strippingHTTPOrHTTPSScheme
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
linkForDisplay = nil
|
||||
}
|
||||
}
|
||||
|
||||
@@ -370,8 +370,7 @@ final class MainWindowController: NSWindowController, NSUserInterfaceValidations
|
||||
// TODO: handle search mode
|
||||
if timelineViewController.canGoToNextUnread(wrappingToTop: false) {
|
||||
goToNextUnreadInTimeline(wrappingToTop: false)
|
||||
}
|
||||
else if sidebarViewController.canGoToNextUnread(wrappingToTop: true) {
|
||||
} else if sidebarViewController.canGoToNextUnread(wrappingToTop: true) {
|
||||
sidebarViewController.goToNextUnread(wrappingToTop: true)
|
||||
|
||||
// If we ended up on the same timelineViewController, we may need to wrap
|
||||
|
||||
@@ -96,8 +96,7 @@ final class ExportOPMLWindowController: NSWindowController {
|
||||
let opmlString = OPMLExporter.OPMLString(with: account, title: filename)
|
||||
do {
|
||||
try opmlString.write(to: url, atomically: true, encoding: String.Encoding.utf8)
|
||||
}
|
||||
catch let error as NSError {
|
||||
} catch let error as NSError {
|
||||
NSApplication.shared.presentError(error)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,8 +76,7 @@ struct PasteboardFeed: Hashable {
|
||||
var pasteboardType: NSPasteboard.PasteboardType?
|
||||
if pasteboardItem.types.contains(FeedPasteboardWriter.feedUTIInternalType) {
|
||||
pasteboardType = FeedPasteboardWriter.feedUTIInternalType
|
||||
}
|
||||
else if pasteboardItem.types.contains(FeedPasteboardWriter.feedUTIType) {
|
||||
} else if pasteboardItem.types.contains(FeedPasteboardWriter.feedUTIType) {
|
||||
pasteboardType = FeedPasteboardWriter.feedUTIType
|
||||
}
|
||||
if let foundType = pasteboardType {
|
||||
@@ -91,8 +90,7 @@ struct PasteboardFeed: Hashable {
|
||||
// Check for URL or a string that may be a URL.
|
||||
if pasteboardItem.types.contains(.URL) {
|
||||
pasteboardType = .URL
|
||||
}
|
||||
else if pasteboardItem.types.contains(.string) {
|
||||
} else if pasteboardItem.types.contains(.string) {
|
||||
pasteboardType = .string
|
||||
}
|
||||
if let foundType = pasteboardType {
|
||||
|
||||
@@ -167,8 +167,7 @@ private extension SidebarOutlineDataSource {
|
||||
for feed in draggedFeeds {
|
||||
if feed.isLocalFeed {
|
||||
hasLocalFeed = true
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
hasNonLocalFeed = true
|
||||
}
|
||||
if hasLocalFeed && hasNonLocalFeed {
|
||||
|
||||
@@ -78,11 +78,9 @@ private extension ArticlePasteboardWriter {
|
||||
}
|
||||
if let text = article.contentText {
|
||||
s += "\(text)\n\n"
|
||||
}
|
||||
else if let summary = article.summary {
|
||||
} else if let summary = article.summary {
|
||||
s += "\(summary)\n\n"
|
||||
}
|
||||
else if let html = article.contentHTML {
|
||||
} else if let html = article.contentHTML {
|
||||
let convertedHTML = html.convertingToPlainText()
|
||||
s += "\(convertedHTML)\n\n"
|
||||
}
|
||||
|
||||
@@ -42,8 +42,7 @@ import RSCore
|
||||
|
||||
if height > 0.1 {
|
||||
self.height = height
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
self.height = [feedNameRect, dateRect, titleRect, summaryRect, textRect, unreadIndicatorRect, iconImageRect].maxY() + paddingBottom
|
||||
}
|
||||
}
|
||||
@@ -62,8 +61,7 @@ import RSCore
|
||||
var lastTextRect = titleRect
|
||||
if numberOfLinesForTitle == 0 {
|
||||
lastTextRect = textRect
|
||||
}
|
||||
else if numberOfLinesForTitle < appearance.titleNumberOfLines {
|
||||
} else if numberOfLinesForTitle < appearance.titleNumberOfLines {
|
||||
if summaryRect.height > 0.1 {
|
||||
lastTextRect = summaryRect
|
||||
}
|
||||
|
||||
@@ -149,8 +149,7 @@ private extension TimelineTableCellView {
|
||||
|
||||
if Int(floor(rect.height)) == 0 || Int(floor(rect.width)) == 0 {
|
||||
hideView(textField)
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
showView(textField)
|
||||
textField.setFrame(ifNotEqualTo: rect)
|
||||
}
|
||||
|
||||
@@ -183,8 +183,7 @@ private extension TimelineContainerViewController {
|
||||
func mode(for timelineViewController: TimelineViewController) -> TimelineSourceMode {
|
||||
if timelineViewController === regularTimelineViewController {
|
||||
return .regular
|
||||
}
|
||||
else if timelineViewController === searchTimelineViewController {
|
||||
} else if timelineViewController === searchTimelineViewController {
|
||||
return .search
|
||||
}
|
||||
assertionFailure("Expected timelineViewController to match either regular or search timelineViewController, but it doesn’t.")
|
||||
|
||||
@@ -405,8 +405,7 @@ final class TimelineViewController: NSViewController, UndoableCommandRunner, Unr
|
||||
|
||||
if markAsRead {
|
||||
markSelectedArticlesAsRead(sender)
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
markSelectedArticlesAsUnread(sender)
|
||||
}
|
||||
}
|
||||
@@ -563,8 +562,7 @@ final class TimelineViewController: NSViewController, UndoableCommandRunner, Unr
|
||||
for article in selectedArticles {
|
||||
if cutoffDate == nil {
|
||||
cutoffDate = article.logicalDatePublished
|
||||
}
|
||||
else if cutoffDate! > article.logicalDatePublished {
|
||||
} else if cutoffDate! > article.logicalDatePublished {
|
||||
cutoffDate = article.logicalDatePublished
|
||||
}
|
||||
}
|
||||
@@ -913,8 +911,7 @@ extension TimelineViewController: NSTableViewDelegate {
|
||||
cell.cellAppearance = showIcons ? cellAppearanceWithIcon : cellAppearance
|
||||
if let article = articles.articleAtRow(row) {
|
||||
configureTimelineCell(cell, article: article)
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
makeTimelineCellEmpty(cell)
|
||||
}
|
||||
}
|
||||
@@ -1316,8 +1313,7 @@ private extension TimelineViewController {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
else if let folder = representedObject as? Folder {
|
||||
} else if let folder = representedObject as? Folder {
|
||||
for oneFeed in feeds {
|
||||
if folder.hasFeed(with: oneFeed.feedID) || folder.hasFeed(withURL: oneFeed.url) {
|
||||
return true
|
||||
|
||||
@@ -25,8 +25,7 @@ struct AddAccountHelpView: View {
|
||||
ForEach(accountTypes, id: \.self) { accountType in
|
||||
if accountType == .cloudKit && hasiCloudAccount {
|
||||
EmptyView()
|
||||
}
|
||||
else if !(AppDefaults.shared.isDeveloperBuild && accountType.isDeveloperRestricted) {
|
||||
} else if !(AppDefaults.shared.isDeveloperBuild && accountType.isDeveloperRestricted) {
|
||||
Button(action: {
|
||||
delegate?.presentSheetForAccount(accountType)
|
||||
}, label: {
|
||||
|
||||
@@ -57,8 +57,7 @@ private extension AdvancedPreferencesViewController {
|
||||
func updateUI() {
|
||||
if wantsTestBuilds {
|
||||
testBuildsButton.state = .on
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
releaseBuildsButton.state = .on
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,8 +140,7 @@ private extension PreferencesWindowController {
|
||||
|
||||
if let currentView = currentView {
|
||||
window!.contentView?.replaceSubview(currentView, with: newViewController.view)
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
window!.contentView?.addSubview(newViewController.view)
|
||||
}
|
||||
|
||||
|
||||
@@ -61,8 +61,7 @@ final class SafariExtensionHandler: SFSafariExtensionHandler {
|
||||
NSWorkspace.shared.open(feedURL)
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (messageName == "pong") {
|
||||
} else if (messageName == "pong") {
|
||||
if let validationIDString = userInfo?["validationID"] as? String {
|
||||
// Should we validate the button?
|
||||
let shouldValidate = userInfo?["shouldValidate"] as? Bool ?? false
|
||||
|
||||
@@ -47,8 +47,7 @@ public final class Article: Hashable, Sendable {
|
||||
|
||||
if let articleID = articleID {
|
||||
self.articleID = articleID
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
self.articleID = Article.calculatedArticleID(feedID: feedID, uniqueID: uniqueID)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,8 +26,7 @@ public struct Author: Codable, Hashable, Sendable {
|
||||
|
||||
if let authorID = authorID {
|
||||
self.authorID = authorID
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
var s = name ?? ""
|
||||
s += url ?? ""
|
||||
s += avatarURL ?? ""
|
||||
@@ -46,8 +45,7 @@ public struct Author: Codable, Hashable, Sendable {
|
||||
do {
|
||||
let authors = try decoder.decode([Author].self, from: data)
|
||||
return Set(authors)
|
||||
}
|
||||
catch {
|
||||
} catch {
|
||||
assertionFailure("JSON representation of Author array could not be decoded: \(jsonString) error: \(error)")
|
||||
}
|
||||
return nil
|
||||
@@ -75,8 +73,7 @@ extension Set where Element == Author {
|
||||
do {
|
||||
let jsonData = try encoder.encode(Array(self))
|
||||
return String(data: jsonData, encoding: .utf8)
|
||||
}
|
||||
catch {
|
||||
} catch {
|
||||
assertionFailure("JSON representation of Author array could not be encoded: \(self) error: \(error)")
|
||||
}
|
||||
return nil
|
||||
|
||||
@@ -50,8 +50,7 @@ private extension HTMLFeedFinder {
|
||||
if let existingFeedSpecifier = feedSpecifiersDictionary[feedSpecifier.urlString] {
|
||||
let mergedFeedSpecifier = existingFeedSpecifier.feedSpecifierByMerging(feedSpecifier)
|
||||
feedSpecifiersDictionary[feedSpecifier.urlString] = mergedFeedSpecifier
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
feedSpecifiersDictionary[feedSpecifier.urlString] = feedSpecifier
|
||||
}
|
||||
}
|
||||
|
||||
@@ -227,8 +227,7 @@ private extension MultilineTextFieldSizer {
|
||||
|
||||
if oneWidth < width && (oneWidth > smallNeighbor.width || smallNeighbor.width == 0) {
|
||||
smallNeighbor = (oneWidth, oneHeight)
|
||||
}
|
||||
else if oneWidth > width && (oneWidth < largeNeighbor.width || largeNeighbor.width == 0) {
|
||||
} else if oneWidth > width && (oneWidth < largeNeighbor.width || largeNeighbor.width == 0) {
|
||||
largeNeighbor = (oneWidth, oneHeight)
|
||||
}
|
||||
|
||||
|
||||
@@ -69,8 +69,7 @@ public extension NSOutlineView {
|
||||
selectRowAndScrollToVisible(row)
|
||||
return
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return // if there are no more items, we’re out of rows
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,8 +19,7 @@ public extension NSResponder {
|
||||
}
|
||||
if let _ = nomad.nextResponder {
|
||||
nomad = nomad.nextResponder!
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,8 +44,7 @@ public final class UserApp {
|
||||
if app == runningApplication {
|
||||
break
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if !app.isTerminated {
|
||||
runningApplication = app
|
||||
break
|
||||
@@ -58,8 +57,7 @@ public final class UserApp {
|
||||
icon = runningApplication.icon
|
||||
if let bundleURL = runningApplication.bundleURL {
|
||||
path = bundleURL.path
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
path = NSWorkspace.shared.urlForApplication(withBundleIdentifier: bundleID)?.path
|
||||
}
|
||||
if icon == nil, let path = path {
|
||||
@@ -74,8 +72,7 @@ public final class UserApp {
|
||||
icon = NSWorkspace.shared.icon(forFile: path)
|
||||
}
|
||||
existsOnDisk = true
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
existsOnDisk = false
|
||||
icon = nil
|
||||
}
|
||||
|
||||
@@ -53,8 +53,7 @@ nonisolated public final class BinaryDiskCache: Sendable {
|
||||
do {
|
||||
try _setData(data, forKey: key)
|
||||
} catch {}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
do {
|
||||
try _deleteData(forKey: key)
|
||||
} catch {}
|
||||
|
||||
@@ -70,8 +70,7 @@ public final class DatabaseLookupTable: Sendable {
|
||||
for object in objects {
|
||||
if let relatedObjects = object.relatedObjectsWithName(relationshipName), !relatedObjects.isEmpty {
|
||||
objectsWithRelationships += [object]
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
objectsWithNoRelationships += [object]
|
||||
}
|
||||
}
|
||||
|
||||
+1
-2
@@ -39,8 +39,7 @@ public extension DatabaseRelatedObjectsTable {
|
||||
for databaseID in databaseIDs {
|
||||
if let cachedObject = cache[databaseID] {
|
||||
cachedObjects += [cachedObject]
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
databaseIDsToFetch.insert(databaseID)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,8 +27,7 @@ struct RelatedObjectIDsMap: Sendable {
|
||||
let relatedObjectID: String = lookupValue.relatedObjectID
|
||||
if d[objectID] == nil {
|
||||
d[objectID] = Set([relatedObjectID])
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
d[objectID]!.insert(relatedObjectID)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,8 +68,7 @@ public struct FeedParser {
|
||||
case .unknown, .notAFeed:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
catch { throw error }
|
||||
} catch { throw error }
|
||||
}
|
||||
|
||||
public static func parse(_ parserData: ParserData) async throws -> ParsedFeed? {
|
||||
@@ -77,8 +76,7 @@ public struct FeedParser {
|
||||
parse(parserData) { parsedFeed, error in
|
||||
if let error {
|
||||
continuation.resume(throwing: error)
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
continuation.resume(returning: parsedFeed)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,8 +54,7 @@ public struct RSSInJSONParser {
|
||||
|
||||
return ParsedFeed(type: .rssInJSON, title: title, homePageURL: homePageURL, feedURL: feedURL, language: feedLanguage, feedDescription: feedDescription, nextURL: nil, iconURL: nil, faviconURL: nil, authors: nil, expired: false, hubs: nil, items: items)
|
||||
|
||||
}
|
||||
catch { throw error }
|
||||
} catch { throw error }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -149,8 +148,7 @@ private extension RSSInJSONParser {
|
||||
return Set([oneTag])
|
||||
}
|
||||
return nil
|
||||
}
|
||||
else if let categoryArray = itemDictionary["category"] as? JSONArray {
|
||||
} else if let categoryArray = itemDictionary["category"] as? JSONArray {
|
||||
return Set(categoryArray.compactMap{ $0["#value"] as? String })
|
||||
}
|
||||
return nil
|
||||
|
||||
@@ -65,8 +65,7 @@ public struct ParsedItem: Hashable, Sendable {
|
||||
public func hash(into hasher: inout Hasher) {
|
||||
if let syncServiceID = syncServiceID {
|
||||
hasher.combine(syncServiceID)
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
hasher.combine(uniqueID)
|
||||
hasher.combine(feedURL)
|
||||
}
|
||||
|
||||
@@ -134,8 +134,7 @@ final class AtomParserTests: XCTestCase {
|
||||
let author = article.authors!.first!
|
||||
if author.name == "Daring Fireball Department of Commerce" {
|
||||
XCTAssertNil(author.url)
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
XCTAssertEqual(author.name, "John Gruber")
|
||||
XCTAssertEqual(author.url, "http://daringfireball.net/")
|
||||
}
|
||||
|
||||
@@ -34,8 +34,7 @@ public extension URL {
|
||||
|
||||
if isHTTPSURL() {
|
||||
return absoluteString.stringByRemovingCaseInsensitivePrefix(URLConstants.prefixHTTPS)
|
||||
}
|
||||
else if isHTTPURL() {
|
||||
} else if isHTTPURL() {
|
||||
return absoluteString.stringByRemovingCaseInsensitivePrefix(URLConstants.prefixHTTP)
|
||||
}
|
||||
|
||||
|
||||
@@ -42,15 +42,13 @@ nonisolated extension Transport {
|
||||
DispatchQueue.main.async {
|
||||
completion(.success((response, decoded)))
|
||||
}
|
||||
}
|
||||
catch {
|
||||
} catch {
|
||||
DispatchQueue.main.async {
|
||||
completion(.failure(error))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
completion(.success((response, nil)))
|
||||
}
|
||||
|
||||
|
||||
@@ -43,8 +43,7 @@ import Articles
|
||||
|
||||
if let feedName = feedName {
|
||||
self.feedName = ArticleStringFormatter.truncatedFeedName(feedName)
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
self.feedName = ""
|
||||
}
|
||||
|
||||
|
||||
@@ -646,8 +646,7 @@ struct FeedNode: Hashable, Sendable {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
self.mainFeedCollectionViewController?.navigationItem.subtitle = ""
|
||||
// If unread count > 0, add unread string to timeline
|
||||
if let _ = timelineFeed, timelineUnreadCount > 0 {
|
||||
@@ -1385,8 +1384,7 @@ struct FeedNode: Hashable, Sendable {
|
||||
func showInAppBrowser() {
|
||||
if currentArticle != nil {
|
||||
articleViewController?.openInAppBrowser()
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
mainFeedCollectionViewController.openInAppBrowser()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user