diff --git a/.swiftlint.yml b/.swiftlint.yml index 9462d37..21c4253 100644 --- a/.swiftlint.yml +++ b/.swiftlint.yml @@ -2,12 +2,9 @@ disabled_rules: - force_cast - large_tuple - line_length + - identifier_name # paths to ignore during linting excluded: - Pods - Resources - - Twig/Libraries - -identifier_name: - min_length: 1 diff --git a/Pine/AppDelegate.swift b/Pine/AppDelegate.swift index d11aee6..2786704 100644 --- a/Pine/AppDelegate.swift +++ b/Pine/AppDelegate.swift @@ -91,7 +91,7 @@ class AppDelegate: NSObject, NSApplicationDelegate { DocumentController.shared.openDocument( withContentsOf: file, display: true, - completionHandler: { _,_,_ in + completionHandler: { _, _, _ in Utils.getCurrentMainWindowController()?.window?.makeKeyAndOrderFront(nil) } ) diff --git a/Pine/Controllers/DocumentController.swift b/Pine/Controllers/DocumentController.swift index cdbce41..c803f55 100644 --- a/Pine/Controllers/DocumentController.swift +++ b/Pine/Controllers/DocumentController.swift @@ -32,7 +32,7 @@ class DocumentController: NSDocumentController { withContentsOf: url, display: true, completionHandler: completionHandler - ); + ) } currentWindowController.syncWindowSidebars() @@ -62,7 +62,7 @@ class DocumentController: NSDocumentController { DocumentController.shared.openDocument( withContentsOf: fileAsURL, display: true, - completionHandler: { _,_,_ in } + completionHandler: { _, _, _ in } ) return @@ -83,7 +83,7 @@ class DocumentController: NSDocumentController { DocumentController.shared.openDocument( withContentsOf: filePathURL, display: true, - completionHandler: { _,_,_ in } + completionHandler: { _, _, _ in } ) return diff --git a/Pine/Controllers/MarkdownViewController.swift b/Pine/Controllers/MarkdownViewController.swift index bd528b0..d9c935d 100644 --- a/Pine/Controllers/MarkdownViewController.swift +++ b/Pine/Controllers/MarkdownViewController.swift @@ -228,9 +228,9 @@ class MarkdownViewController: NSViewController, NSTextViewDelegate, HighlightDel /// Whenever typing attributes in the text view are changed, regenerate the preview func textView( _ textView: NSTextView, - shouldChangeTypingAttributes oldTypingAttributes: [String : Any] = [:], - toAttributes newTypingAttributes: [NSAttributedString.Key : Any] = [:]) -> [NSAttributedString.Key : Any] - { + shouldChangeTypingAttributes oldTypingAttributes: [String: Any] = [:], + toAttributes newTypingAttributes: [NSAttributedString.Key: Any] = [:] + ) -> [NSAttributedString.Key: Any] { self.generatePreview() return newTypingAttributes } @@ -334,7 +334,10 @@ extension MarkdownViewController: NSTouchBarDelegate { return touchBar } - func touchBar(_ touchBar: NSTouchBar, makeItemForIdentifier identifier: NSTouchBarItem.Identifier) -> NSTouchBarItem? { + func touchBar( + _ touchBar: NSTouchBar, + makeItemForIdentifier identifier: NSTouchBarItem.Identifier + ) -> NSTouchBarItem? { let item = NSCustomTouchBarItem(identifier: identifier) switch identifier { diff --git a/Pine/Controllers/Preferences/PreferencesSidebarViewController.swift b/Pine/Controllers/Preferences/PreferencesSidebarViewController.swift index 9c2bf6f..07cc523 100644 --- a/Pine/Controllers/Preferences/PreferencesSidebarViewController.swift +++ b/Pine/Controllers/Preferences/PreferencesSidebarViewController.swift @@ -18,7 +18,7 @@ class PreferencesSidebarViewController: NSViewController { override func viewDidLoad() { super.viewDidLoad() - + sidebar.delegate = self sidebar.dataSource = self diff --git a/Pine/Controllers/Preferences/PreferencesSplitViewController.swift b/Pine/Controllers/Preferences/PreferencesSplitViewController.swift index 89ee24e..942d57d 100644 --- a/Pine/Controllers/Preferences/PreferencesSplitViewController.swift +++ b/Pine/Controllers/Preferences/PreferencesSplitViewController.swift @@ -11,7 +11,7 @@ import Cocoa class PreferencesSplitViewController: NSSplitViewController { override func splitView(_ splitView: NSSplitView, effectiveRect proposedEffectiveRect: NSRect, forDrawnRect drawnRect: NSRect, ofDividerAt dividerIndex: Int) -> NSRect { - return NSZeroRect + return .zero } } diff --git a/Pine/Controllers/Preferences/PreferencesViewController.swift b/Pine/Controllers/Preferences/PreferencesViewController.swift index efb36d8..01e0f66 100644 --- a/Pine/Controllers/Preferences/PreferencesViewController.swift +++ b/Pine/Controllers/Preferences/PreferencesViewController.swift @@ -9,7 +9,7 @@ import Cocoa class PreferencesViewController: NSViewController { - + @IBOutlet weak var scrollView: NSScrollView! private var stackView: NSStackView! @@ -65,20 +65,17 @@ class PreferencesViewController: NSViewController { switch category { case .ui: views = uiStackView.getViews() - break case .markdown: views = markdownStackView.getViews() - break case .document: views = documentStackView.getViews() - break } for (index, view) in views.enumerated() { stackView.addArrangedSubview(view) // Add a seperator underneath all views except last - if (index != views.count - 1) { + if index != views.count - 1 { let hr = NSBox() hr.boxType = .separator @@ -104,5 +101,5 @@ class PreferencesViewController: NSViewController { NSLayoutConstraint.activate(stackViewConstraints) } - + } diff --git a/Pine/Controllers/Preferences/PreferencesWindowController.swift b/Pine/Controllers/Preferences/PreferencesWindowController.swift index d9a856a..5c17a52 100644 --- a/Pine/Controllers/Preferences/PreferencesWindowController.swift +++ b/Pine/Controllers/Preferences/PreferencesWindowController.swift @@ -19,4 +19,3 @@ class PreferencesWindowController: NSWindowController, NSWindowDelegate { } } - diff --git a/Pine/Controllers/SidebarViewController.swift b/Pine/Controllers/SidebarViewController.swift index 1d416dc..56ee8f3 100644 --- a/Pine/Controllers/SidebarViewController.swift +++ b/Pine/Controllers/SidebarViewController.swift @@ -246,7 +246,7 @@ extension SidebarViewController: NSOutlineViewDataSource { /// The NSTableRowView instance to be used func outlineView(_ outlineView: NSOutlineView, rowViewForItem item: Any) -> NSTableRowView? { - return SidebarTableRowView(frame: NSZeroRect) + return SidebarTableRowView(frame: .zero) } } @@ -290,4 +290,3 @@ extension SidebarViewController: NSMenuDelegate { } } - diff --git a/Pine/Extensions/NSTextView.swift b/Pine/Extensions/NSTextView.swift index a283428..b792637 100644 --- a/Pine/Extensions/NSTextView.swift +++ b/Pine/Extensions/NSTextView.swift @@ -93,8 +93,8 @@ extension NSTextView { atLineStart: Bool = false, newLineIfSelected: Bool = false ) { - var leftString: String? = nil - var rightString: String? = nil + var leftString: String? + var rightString: String? if let l = left { leftString = String(l) @@ -167,5 +167,5 @@ extension NSTextView { self.replace(right: match) } - + } diff --git a/Pine/Extensions/NSView.swift b/Pine/Extensions/NSView.swift index 8c6add9..520c7b0 100644 --- a/Pine/Extensions/NSView.swift +++ b/Pine/Extensions/NSView.swift @@ -14,5 +14,5 @@ extension NSView { wantsLayer = true layer?.backgroundColor = color.cgColor } - + } diff --git a/Pine/Views/Preferences/PreferencesStackView.swift b/Pine/Views/Preferences/PreferencesStackView.swift index c95fdc8..5bb82aa 100644 --- a/Pine/Views/Preferences/PreferencesStackView.swift +++ b/Pine/Views/Preferences/PreferencesStackView.swift @@ -24,7 +24,7 @@ class PreferencesStackView: NSStackView { private var prefView: NSStackView! init(name: String) { - super.init(frame: NSZeroRect) + super.init(frame: .zero) self.name = name self.hasSection = false diff --git a/Pine/Views/Preferences/UIStackView.swift b/Pine/Views/Preferences/UIStackView.swift index 33d0408..1c3b6a3 100644 --- a/Pine/Views/Preferences/UIStackView.swift +++ b/Pine/Views/Preferences/UIStackView.swift @@ -43,7 +43,7 @@ class UIStackView: NSStackView, PreferenceStackView, NSFontChanging { view.addPreferences([ syntaxDropdown, - revealThemesButton, + revealThemesButton ]) view.addBooleanArea( diff --git a/Pine/Views/SidebarTableRowView.swift b/Pine/Views/SidebarTableRowView.swift index 9601f1d..87ffced 100644 --- a/Pine/Views/SidebarTableRowView.swift +++ b/Pine/Views/SidebarTableRowView.swift @@ -12,12 +12,12 @@ class SidebarTableRowView: NSTableRowView { // Draw a custom selection override func drawSelection(in dirtyRect: NSRect) { - let selectionRect = NSInsetRect(self.bounds, 0, 0) + let selectionRect = self.bounds NSColor.selectedControlColor.setStroke() NSColor.selectedControlColor.setFill() - let selectionPath = NSBezierPath.init(roundedRect: selectionRect, xRadius: 0, yRadius: 0) + let selectionPath = NSBezierPath(roundedRect: selectionRect, xRadius: 0, yRadius: 0) selectionPath.fill() selectionPath.stroke() } diff --git a/PineTests/TextViewTests.swift b/PineTests/TextViewTests.swift index 389d34d..3b960ae 100644 --- a/PineTests/TextViewTests.swift +++ b/PineTests/TextViewTests.swift @@ -48,7 +48,7 @@ class TextViewTests: XCTestCase { textView.replace(left: "```\n", right: "\n```", newLineIfSelected: true) let newContents = textView.textStorage?.string - + XCTAssert(newContents == "\n```\n\n```\n") }