Remove extraneous get { from a bunch of read-only accessors.

This commit is contained in:
Brent Simmons 2018-02-14 13:14:25 -08:00
parent 192439abe7
commit 2f21dbf6be
44 changed files with 216 additions and 353 deletions

View File

@ -17,10 +17,8 @@ final class DeleteFromSidebarCommand: UndoableCommand {
let undoManager: UndoManager
let undoActionName: String
var redoActionName: String {
get {
return undoActionName
}
}
private let itemSpecifiers: [SidebarItemSpecifier]
@ -94,7 +92,6 @@ private struct SidebarItemSpecifier {
private let path: ContainerPath
private var container: Container? {
get {
if let parentFolder = parentFolder {
return parentFolder
}
@ -103,7 +100,6 @@ private struct SidebarItemSpecifier {
}
return nil
}
}
init?(node: Node) {

View File

@ -42,26 +42,18 @@ private func accountAndArticlesDictionary(_ articles: Set<Article>) -> [String:
extension Article {
var feed: Feed? {
get {
return account?.existingFeed(with: feedID)
}
}
var preferredLink: String? {
get {
return url ?? externalURL
}
}
var body: String? {
get {
return contentHTML ?? contentText ?? summary
}
}
var logicalDatePublished: Date {
get {
return datePublished ?? dateModified ?? status.dateArrived
}
}
}

View File

@ -31,10 +31,8 @@ final class FeedListFeed: Hashable, DisplayNameProvider {
}
var nameForDisplay: String { // DisplayNameProvider
get {
return name
}
}
init(name: String, url: String, homePageURL: String) {

View File

@ -17,10 +17,8 @@ final class FeedListFolder: Hashable, DisplayNameProvider {
let hashValue: Int
var nameForDisplay: String { // DisplayNameProvider
get {
return name
}
}
init(name: String, feeds: Set<FeedListFeed>) {

View File

@ -33,10 +33,8 @@ final class InspectorWindowController: NSWindowController {
}
var isOpen: Bool {
get {
return isWindowLoaded && window!.isVisible
}
}
private var inspectors: [InspectorViewController]!

View File

@ -126,13 +126,11 @@ class AddFeedController: AddFeedWindowControllerDelegate, FeedFinderDelegate {
private extension AddFeedController {
var urlStringFromPasteboard: String? {
get {
if let urlString = NSPasteboard.rs_urlString(from: NSPasteboard.general) {
return urlString.rs_normalizedURL()
}
return nil
}
}
struct AccountAndFolderSpecifier {
let account: Account

View File

@ -33,7 +33,6 @@ class AddFeedWindowController : NSWindowController {
fileprivate var folderTreeController: TreeController!
private var userEnteredTitle: String? {
get {
var s = nameTextField.stringValue
s = s.rs_stringWithCollapsedWhitespace()
if s.isEmpty {
@ -41,7 +40,6 @@ class AddFeedWindowController : NSWindowController {
}
return s
}
}
var hostWindow: NSWindow!

View File

@ -13,8 +13,6 @@ class MainWindowSplitView: NSSplitView {
private let splitViewDividerColor = NSColor(calibratedWhite: 0.65, alpha: 1.0)
override var dividerColor: NSColor {
get {
return splitViewDividerColor
}
}
}

View File

@ -75,10 +75,8 @@ class SidebarCell : NSTableCellView {
}
override var isFlipped: Bool {
get {
return true
}
}
private func commonInit() {

View File

@ -25,10 +25,8 @@ final class SidebarStatusBarView: NSView {
}
override var isFlipped: Bool {
get {
return true
}
}
override func awakeFromNib() {

View File

@ -27,16 +27,13 @@ class UnreadCountView : NSView {
}
}
var unreadCountString: String {
get {
return unreadCount < 1 ? "" : "\(unreadCount)"
}
}
private var intrinsicContentSizeIsValid = false
private var _intrinsicContentSize = NSZeroSize
override var intrinsicContentSize: NSSize {
get {
if !intrinsicContentSizeIsValid {
var size = NSZeroSize
if unreadCount > 0 {
@ -49,13 +46,10 @@ class UnreadCountView : NSView {
}
return _intrinsicContentSize
}
}
override var isFlipped: Bool {
get {
return true
}
}
override func invalidateIntrinsicContentSize() {

View File

@ -23,7 +23,6 @@ class TimelineTableRowView : NSTableRowView {
// }
private var cellView: TimelineTableCellView? {
get {
for oneSubview in subviews {
if let foundView = oneSubview as? TimelineTableCellView {
return foundView
@ -31,7 +30,6 @@ class TimelineTableRowView : NSTableRowView {
}
return nil
}
}
override var isEmphasized: Bool {
didSet {
@ -50,11 +48,8 @@ class TimelineTableRowView : NSTableRowView {
}
var gridRect: NSRect {
get {
// return NSMakeRect(floor(cellAppearance.boxLeftMargin), NSMaxY(bounds) - 1.0, NSWidth(bounds), 1)
return NSMakeRect(0.0, NSMaxY(bounds) - 1.0, NSWidth(bounds), 1)
}
}
override func drawSeparator(in dirtyRect: NSRect) {

View File

@ -18,16 +18,12 @@ class TimelineViewController: NSViewController, UndoableCommandRunner {
@IBOutlet var contextualMenuDelegate: TimelineContextualMenuDelegate?
var selectedArticles: [Article] {
get {
return Array(articles.articlesForIndexes(tableView.selectedRowIndexes))
}
}
var hasAtLeastOneSelectedArticle: Bool {
get {
return tableView.selectedRow != -1
}
}
var articles = ArticleArray() {
didSet {
@ -105,10 +101,8 @@ class TimelineViewController: NSViewController, UndoableCommandRunner {
}
private var oneSelectedArticle: Article? {
get {
return selectedArticles.count == 1 ? selectedArticles.first : nil
}
}
override func viewDidLoad() {

View File

@ -96,10 +96,8 @@ class PreferencesWindowController : NSWindowController, NSToolbarDelegate {
private extension PreferencesWindowController {
var currentView: NSView? {
get {
return window?.contentView?.subviews.first
}
}
func toolbarItemSpec(for identifier: String) -> PreferencesToolbarItemSpec? {

View File

@ -22,8 +22,6 @@ private var smartFeedIcon: NSImage = {
extension PseudoFeed {
var smallIcon: NSImage? {
get {
return smartFeedIcon
}
}
}

View File

@ -19,10 +19,8 @@ protocol SmartFeedDelegate: DisplayNameProvider, ArticleFetcher {
final class SmartFeed: PseudoFeed {
var nameForDisplay: String {
get {
return delegate.nameForDisplay
}
}
var unreadCount = 0 {
didSet {

View File

@ -102,16 +102,12 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
}
var refreshProgress: DownloadProgress {
get {
return delegate.refreshProgress
}
}
var supportsSubFolders: Bool {
get {
return delegate.supportsSubFolders
}
}
init?(dataFolder: String, settingsFile: String, type: AccountType, accountID: String) {

View File

@ -31,19 +31,14 @@ public final class AccountManager: UnreadCountProvider {
}
public var accounts: [Account] {
get {
return Array(accountsDictionary.values)
}
}
public var sortedAccounts: [Account] {
get {
return accountsSortedByName()
}
}
public var refreshInProgress: Bool {
get {
for account in accounts {
if account.refreshInProgress {
return true
@ -51,14 +46,11 @@ public final class AccountManager: UnreadCountProvider {
}
return false
}
}
public var combinedRefreshProgress: CombinedRefreshProgress {
get {
let downloadProgressArray = accounts.map { $0.refreshProgress }
return CombinedRefreshProgress(downloadProgressArray: downloadProgressArray)
}
}
public init() {

View File

@ -18,10 +18,8 @@ public extension Notification.Name {
public extension Feed {
public var account: Account? {
get {
return AccountManager.shared.existingAccount(with: accountID)
}
}
public func takeSettings(from parsedFeed: ParsedFeed) {
@ -59,15 +57,11 @@ public extension Feed {
public extension Article {
public var account: Account? {
get {
return AccountManager.shared.existingAccount(with: accountID)
}
}
public var feed: Feed? {
get {
return account?.existingFeed(with: feedID)
}
}
}

View File

@ -14,10 +14,8 @@ final class FeedbinAccountDelegate: AccountDelegate {
let supportsSubFolders = false
var refreshProgress: DownloadProgress {
get {
return DownloadProgress(numberOfTasks: 0) // TODO
}
}
func refreshAll(for: Account) {

View File

@ -29,10 +29,7 @@ public final class Folder: DisplayNameProvider, Container, UnreadCountProvider,
// MARK: - DisplayNameProvider
public var nameForDisplay: String {
get {
return name ?? Folder.untitledName
}
}
// MARK: - UnreadCountProvider
@ -84,7 +81,6 @@ public final class Folder: DisplayNameProvider, Container, UnreadCountProvider,
}
var dictionary: [String: Any] {
get {
var d = [String: Any]()
guard let account = account else {
@ -116,7 +112,6 @@ public final class Folder: DisplayNameProvider, Container, UnreadCountProvider,
return d
}
}
// MARK: Feeds

View File

@ -15,10 +15,8 @@ final class LocalAccountDelegate: AccountDelegate {
private let refresher = LocalAccountRefresher()
var refreshProgress: DownloadProgress {
get {
return refresher.progress
}
}
func refreshAll(for account: Account) {

View File

@ -19,10 +19,8 @@ final class LocalAccountRefresher {
}()
var progress: DownloadProgress {
get {
return downloadSession.progress
}
}
public func refreshFeeds(_ feeds: Set<Feed>) {

View File

@ -34,7 +34,6 @@ public final class Feed: DisplayNameProvider, UnreadCountProvider, Hashable {
// MARK: - DisplayNameProvider
public var nameForDisplay: String {
get {
if let s = editedName, !s.isEmpty {
return s
}
@ -43,7 +42,6 @@ public final class Feed: DisplayNameProvider, UnreadCountProvider, Hashable {
}
return NSLocalizedString("Untitled", comment: "Feed name")
}
}
// MARK: - UnreadCountProvider
@ -115,7 +113,6 @@ public final class Feed: DisplayNameProvider, UnreadCountProvider, Hashable {
}
public var dictionary: [String: Any] {
get {
var d = [String: Any]()
d[Key.url] = url
@ -155,7 +152,6 @@ public final class Feed: DisplayNameProvider, UnreadCountProvider, Hashable {
return d
}
}
// MARK: - Debug

View File

@ -110,10 +110,8 @@ extension Article: DatabaseObject {
}
public var databaseID: String {
get {
return articleID
}
}
public func relatedObjectsWithName(_ name: String) -> [DatabaseObject]? {

View File

@ -26,10 +26,8 @@ extension ArticleStatus {
extension ArticleStatus: DatabaseObject {
public var databaseID: String {
get {
return articleID
}
}
public func databaseDictionary() -> NSDictionary? {

View File

@ -57,10 +57,8 @@ private func optionalIntForColumn(_ row: FMResultSet, _ columnName: String) -> I
extension Attachment: DatabaseObject {
public var databaseID: String {
get {
return attachmentID
}
}
public func databaseDictionary() -> NSDictionary? {

View File

@ -45,10 +45,8 @@ extension Author {
extension Author: DatabaseObject {
public var databaseID: String {
get {
return authorID
}
}
public func databaseDictionary() -> NSDictionary? {

View File

@ -13,7 +13,6 @@ import Data
extension ParsedItem {
var articleID: String {
get {
if let s = syncServiceID {
return s
}
@ -21,4 +20,3 @@ extension ParsedItem {
return Article.calculatedArticleID(feedID: feedURL, uniqueID: uniqueID)
}
}
}

View File

@ -179,10 +179,8 @@ private final class StatusCache {
var dictionary = [String: ArticleStatus]()
var cachedStatuses: Set<ArticleStatus> {
get {
return Set(dictionary.values)
}
}
func add(_ statuses: Set<ArticleStatus>) {

View File

@ -27,8 +27,6 @@ public struct UnreadCountDictionary {
}
public subscript(_ feed: Feed) -> Int? {
get {
return dictionary[feed.feedID]
}
}
}

View File

@ -22,10 +22,8 @@ public final class BatchUpdate {
private var count = 0
public var isPerforming: Bool {
get {
return count > 0
}
}
public func perform(_ batchUpdateBlock: BatchUpdateBlock) {

View File

@ -11,8 +11,6 @@ import AppKit
public extension NSOutlineView {
var selectedItems: [AnyObject] {
get {
if selectionIsEmpty {
return [AnyObject]()
}
@ -21,7 +19,6 @@ public extension NSOutlineView {
return item(atRow: oneIndex) as AnyObject
}
}
}
var firstSelectedRow: Int? {

View File

@ -11,10 +11,8 @@ import AppKit
public extension NSTableView {
var selectionIsEmpty: Bool {
get {
return selectedRowIndexes.startIndex == selectedRowIndexes.endIndex
}
}
func indexesOfAvailableRowsPassingTest(_ test: (Int) -> Bool) -> IndexSet? {

View File

@ -52,11 +52,9 @@ struct RelatedObjectIDsMap {
}
subscript(_ objectID: String) -> Set<String>? {
get {
return dictionary[objectID]
}
}
}
struct LookupValue: Hashable {

View File

@ -39,8 +39,6 @@ public struct RelatedObjectsMap {
}
public subscript(_ objectID: String) -> [DatabaseObject]? {
get {
return dictionary[objectID]
}
}
}

View File

@ -25,10 +25,8 @@ public struct FeedSpecifier: Hashable {
public let source: Source
public let hashValue: Int
public var score: Int {
get {
return calculatedScore()
}
}
init(title: String?, urlString: String, source: Source) {

View File

@ -14,10 +14,8 @@ private let feedURLWordsToMatch = ["feed", "xml", "rss", "atom", "json"]
class HTMLFeedFinder {
var feedSpecifiers: Set<FeedSpecifier> {
get {
return Set(feedSpecifiersDictionary.values)
}
}
fileprivate var feedSpecifiersDictionary = [String: FeedSpecifier]()

View File

@ -21,22 +21,17 @@ public final class Node: Hashable {
private static var incrementingID = 0
public var isRoot: Bool {
get {
if let _ = parent {
return false
}
return true
}
}
public var numberOfChildNodes: Int {
get {
return childNodes?.count ?? 0
}
}
public var indexPath: IndexPath {
get {
if let parent = parent {
let parentPath = parent.indexPath
if let childIndex = parent.indexOfChild(self) {
@ -46,22 +41,17 @@ public final class Node: Hashable {
}
return IndexPath(index: 0) //root node
}
}
public var level: Int {
get {
if let parent = parent {
return parent.level + 1
}
return 0
}
}
public var isLeaf: Bool {
get {
return numberOfChildNodes < 1
}
}
public init(representedObject: AnyObject, parent: Node?) {

View File

@ -14,10 +14,8 @@ public final class DownloadObject: Hashable {
public var data = Data()
public var hashValue: Int {
get {
return url.hashValue
}
}
public init(url: URL) {

View File

@ -35,7 +35,6 @@ public final class DownloadProgress {
}
public var numberCompleted: Int {
get {
var n = numberOfTasks - numberRemaining
if n < 0 {
n = 0
@ -45,13 +44,10 @@ public final class DownloadProgress {
}
return n
}
}
public var isComplete: Bool {
get {
return numberRemaining < 1
}
}
public init(numberOfTasks: Int) {

View File

@ -294,10 +294,8 @@ private final class DownloadInfo {
var canceled = false
var statusCode: Int {
get {
return urlResponse?.forcedStatusCode ?? 0
}
}
init(_ representedObject: AnyObject, urlRequest: URLRequest) {

View File

@ -14,7 +14,6 @@ public struct HTTPConditionalGetInfo {
public let etag: String?
public var dictionary: [String: String] {
get {
var d = [String: String]()
if let lastModified = lastModified {
d[HTTPResponseHeader.lastModified] = lastModified
@ -24,7 +23,6 @@ public struct HTTPConditionalGetInfo {
}
return d
}
}
public init?(lastModified: String?, etag: String?) {

View File

@ -11,14 +11,11 @@ import Foundation
public extension URLResponse {
public var statusIsOK: Bool {
get {
return forcedStatusCode >= 200 && forcedStatusCode <= 299
}
}
public var forcedStatusCode: Int {
get {
// Return actual statusCode or -1 if there isnt one.
if let response = self as? HTTPURLResponse {
@ -27,7 +24,6 @@ public extension URLResponse {
return 0
}
}
}
public extension HTTPURLResponse {