Skip to content

Commit

Permalink
Fix a few SwiftLint warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
lukakerr committed Mar 14, 2019
1 parent 53fc9a3 commit b7f681b
Show file tree
Hide file tree
Showing 15 changed files with 27 additions and 32 deletions.
5 changes: 1 addition & 4 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion Pine/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
DocumentController.shared.openDocument(
withContentsOf: file,
display: true,
completionHandler: { _,_,_ in
completionHandler: { _, _, _ in
Utils.getCurrentMainWindowController()?.window?.makeKeyAndOrderFront(nil)
}
)
Expand Down
6 changes: 3 additions & 3 deletions Pine/Controllers/DocumentController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class DocumentController: NSDocumentController {
withContentsOf: url,
display: true,
completionHandler: completionHandler
);
)
}

currentWindowController.syncWindowSidebars()
Expand Down Expand Up @@ -62,7 +62,7 @@ class DocumentController: NSDocumentController {
DocumentController.shared.openDocument(
withContentsOf: fileAsURL,
display: true,
completionHandler: { _,_,_ in }
completionHandler: { _, _, _ in }
)

return
Expand All @@ -83,7 +83,7 @@ class DocumentController: NSDocumentController {
DocumentController.shared.openDocument(
withContentsOf: filePathURL,
display: true,
completionHandler: { _,_,_ in }
completionHandler: { _, _, _ in }
)

return
Expand Down
11 changes: 7 additions & 4 deletions Pine/Controllers/MarkdownViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class PreferencesSidebarViewController: NSViewController {

override func viewDidLoad() {
super.viewDidLoad()

sidebar.delegate = self
sidebar.dataSource = self

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

}
9 changes: 3 additions & 6 deletions Pine/Controllers/Preferences/PreferencesViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Cocoa

class PreferencesViewController: NSViewController {

@IBOutlet weak var scrollView: NSScrollView!

private var stackView: NSStackView!
Expand Down Expand Up @@ -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

Expand All @@ -104,5 +101,5 @@ class PreferencesViewController: NSViewController {

NSLayoutConstraint.activate(stackViewConstraints)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,3 @@ class PreferencesWindowController: NSWindowController, NSWindowDelegate {
}

}

3 changes: 1 addition & 2 deletions Pine/Controllers/SidebarViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

}
Expand Down Expand Up @@ -290,4 +290,3 @@ extension SidebarViewController: NSMenuDelegate {
}

}

6 changes: 3 additions & 3 deletions Pine/Extensions/NSTextView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -167,5 +167,5 @@ extension NSTextView {

self.replace(right: match)
}

}
2 changes: 1 addition & 1 deletion Pine/Extensions/NSView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ extension NSView {
wantsLayer = true
layer?.backgroundColor = color.cgColor
}

}
2 changes: 1 addition & 1 deletion Pine/Views/Preferences/PreferencesStackView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Pine/Views/Preferences/UIStackView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class UIStackView: NSStackView, PreferenceStackView, NSFontChanging {

view.addPreferences([
syntaxDropdown,
revealThemesButton,
revealThemesButton
])

view.addBooleanArea(
Expand Down
4 changes: 2 additions & 2 deletions Pine/Views/SidebarTableRowView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down
2 changes: 1 addition & 1 deletion PineTests/TextViewTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}

Expand Down

0 comments on commit b7f681b

Please sign in to comment.