Skip to content

Commit 9d99cfd

Browse files
authored
Run SwiftLint on danger-swiftlint (#37)
* Run SwiftLint on danger-swiftlint * swiftlint
1 parent 840b716 commit 9d99cfd

File tree

8 files changed

+177
-29
lines changed

8 files changed

+177
-29
lines changed

.github/workflows/Danger.yml

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Danger
2+
3+
on: pull_request
4+
5+
jobs:
6+
danger:
7+
8+
runs-on: macos-latest
9+
10+
steps:
11+
- uses: actions/checkout@v1
12+
with:
13+
submodules: true
14+
15+
- name: Setup ruby
16+
uses: actions/setup-ruby@v1
17+
with:
18+
ruby-version: '2.6'
19+
20+
- name: Select Xcode
21+
run: sudo xcode-select -s /Applications/Xcode_11.4.app
22+
23+
- name: Cache RubyGems
24+
uses: actions/cache@v1
25+
with:
26+
path: vendor/bundle
27+
key: ${{ runner.os }}-gem-${{ hashFiles('**/Gemfile.lock') }}
28+
restore-keys: |
29+
${{ runner.os }}-gem-
30+
31+
- name: Cache Mint packages
32+
uses: actions/cache@v1
33+
with:
34+
path: ${{ env.MINT_PATH }}
35+
key: ${{ runner.os }}-mint-${{ hashFiles('**/Mintfile') }}
36+
restore-keys: |
37+
${{ runner.os }}-mint-
38+
39+
- name: Bundle install
40+
run: |
41+
gem install bundler
42+
bundle config path vendor/bundle
43+
bundle install --jobs 4 --retry 3
44+
45+
- name: Install Mint and Packages
46+
run: |
47+
brew install mint
48+
mint bootstrap --link
49+
50+
- name: Run Danger
51+
run: bundle exec danger
52+
env:
53+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
54+
55+
env:
56+
MINT_PATH: mint

.swiftlint.yml

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
included:
2+
- Lib/KeyHolder
3+
- Lib/KeyHolderTests
4+
opt_in_rules:
5+
- empty_count
6+
- explicit_init
7+
- closure_spacing
8+
- overridden_super_call
9+
- redundant_nil_coalescing
10+
- private_outlet
11+
- nimble_operator
12+
- operator_usage_whitespace
13+
- closure_end_indentation
14+
- first_where
15+
- prohibited_super_call
16+
- vertical_parameter_alignment_on_call
17+
- unneeded_parentheses_in_closure_argument
18+
- extension_access_modifier
19+
- literal_expression_end_indentation
20+
- joined_default_parameter
21+
- contains_over_first_not_nil
22+
- override_in_extension
23+
- private_action
24+
- quick_discouraged_call
25+
- quick_discouraged_focused_test
26+
- quick_discouraged_pending_test
27+
- single_test_class
28+
- sorted_first_last
29+
- yoda_condition
30+
disabled_rules:
31+
- nesting
32+
- function_parameter_count
33+
identifier_name:
34+
excluded:
35+
- i
36+
- x
37+
- y
38+
line_length: 300

Dangerfile

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
github.dismiss_out_of_range_messages
2+
swiftlint.config_file = '.swiftlint.yml'
3+
swiftlint.lint_files(inline_mode: true)

Gemfile

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
source 'https://rubygems.org'
22

33
gem 'cocoapods'
4+
gem "danger"
5+
gem "danger-swiftlint"

Gemfile.lock

+54
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,17 @@ GEM
77
minitest (~> 5.1)
88
thread_safe (~> 0.3, >= 0.3.4)
99
tzinfo (~> 1.1)
10+
addressable (2.7.0)
11+
public_suffix (>= 2.0.2, < 5.0)
1012
algoliasearch (1.27.2)
1113
httpclient (~> 2.8, >= 2.8.3)
1214
json (>= 1.5.1)
1315
atomos (0.1.3)
1416
claide (1.0.3)
17+
claide-plugins (0.9.2)
18+
cork
19+
nap
20+
open4 (~> 1.3)
1521
cocoapods (1.9.1)
1622
activesupport (>= 4.0.2, < 5)
1723
claide (>= 1.0.2, < 2.0)
@@ -51,28 +57,74 @@ GEM
5157
cocoapods-try (1.2.0)
5258
colored2 (3.1.2)
5359
concurrent-ruby (1.1.6)
60+
cork (0.3.0)
61+
colored2 (~> 3.1)
62+
danger (7.0.0)
63+
claide (~> 1.0)
64+
claide-plugins (>= 0.9.2)
65+
colored2 (~> 3.1)
66+
cork (~> 0.1)
67+
faraday (>= 0.9.0, < 2.0)
68+
faraday-http-cache (~> 2.0)
69+
git (~> 1.6)
70+
kramdown (~> 2.0)
71+
kramdown-parser-gfm (~> 1.0)
72+
no_proxy_fix
73+
octokit (~> 4.7)
74+
terminal-table (~> 1)
75+
danger-swiftlint (0.24.2)
76+
danger
77+
rake (> 10)
78+
thor (~> 0.19)
5479
escape (0.0.4)
5580
ethon (0.12.0)
5681
ffi (>= 1.3.0)
82+
faraday (1.0.1)
83+
multipart-post (>= 1.2, < 3)
84+
faraday-http-cache (2.2.0)
85+
faraday (>= 0.8)
5786
ffi (1.12.2)
5887
fourflusher (2.3.1)
5988
fuzzy_match (2.0.4)
6089
gh_inspector (1.1.3)
90+
git (1.7.0)
91+
rchardet (~> 1.8)
6192
httpclient (2.8.3)
6293
i18n (0.9.5)
6394
concurrent-ruby (~> 1.0)
6495
json (2.3.0)
96+
kramdown (2.2.1)
97+
rexml
98+
kramdown-parser-gfm (1.1.0)
99+
kramdown (~> 2.0)
65100
minitest (5.14.0)
66101
molinillo (0.6.6)
102+
multipart-post (2.1.1)
67103
nanaimo (0.2.6)
68104
nap (1.1.0)
69105
netrc (0.11.0)
106+
no_proxy_fix (0.1.2)
107+
octokit (4.18.0)
108+
faraday (>= 0.9)
109+
sawyer (~> 0.8.0, >= 0.5.3)
110+
open4 (1.3.4)
111+
public_suffix (4.0.4)
112+
rake (13.0.1)
113+
rchardet (1.8.0)
114+
rexml (3.2.4)
70115
ruby-macho (1.4.0)
116+
sawyer (0.8.2)
117+
addressable (>= 2.3.5)
118+
faraday (> 0.8, < 2.0)
119+
terminal-table (1.8.0)
120+
unicode-display_width (~> 1.1, >= 1.1.1)
121+
thor (0.20.3)
71122
thread_safe (0.3.6)
72123
typhoeus (1.3.1)
73124
ethon (>= 0.9.0)
74125
tzinfo (1.2.7)
75126
thread_safe (~> 0.1)
127+
unicode-display_width (1.7.0)
76128
xcodeproj (1.16.0)
77129
CFPropertyList (>= 2.3.3, < 4.0)
78130
atomos (~> 0.1.3)
@@ -85,6 +137,8 @@ PLATFORMS
85137

86138
DEPENDENCIES
87139
cocoapods
140+
danger
141+
danger-swiftlint
88142

89143
BUNDLED WITH
90144
2.0.2

Lib/KeyHolder/RecordView.swift

+17-16
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ public protocol RecordViewDelegate: class {
2222
func recordViewDidEndRecording(_ recordView: RecordView)
2323
}
2424

25-
@IBDesignable open class RecordView: NSView {
25+
@IBDesignable
26+
open class RecordView: NSView {
2627

2728
// MARK: - Properties
2829
@IBInspectable open var backgroundColor: NSColor = .white {
@@ -306,14 +307,14 @@ public protocol RecordViewDelegate: class {
306307

307308
// Clean Flag
308309
let delay = 0.3 * Double(NSEC_PER_SEC)
309-
let time = DispatchTime.now() + Double(Int64(delay)) / Double(NSEC_PER_SEC)
310+
let time = DispatchTime.now() + Double(Int64(delay)) / Double(NSEC_PER_SEC)
310311
DispatchQueue.main.asyncAfter(deadline: time, execute: { [weak self] in
311312
self?.doubleTapModifier = NSEvent.ModifierFlags(rawValue: 0)
312313
})
313314
} else {
314315
inputModifiers = NSEvent.ModifierFlags(rawValue: 0)
315316
}
316-
317+
317318
super.flagsChanged(with: theEvent)
318319
}
319320

@@ -350,14 +351,14 @@ extension RecordView {
350351
}
351352

352353
// MARK: - Recording
353-
extension RecordView {
354-
public func beginRecording() -> Bool {
354+
public extension RecordView {
355+
func beginRecording() -> Bool {
355356
if !isEnabled { return false }
356357
if isRecording { return true }
357358

358359
needsDisplay = true
359360

360-
if let delegate = delegate , !delegate.recordViewShouldBeginRecording(self) {
361+
if let delegate = delegate, !delegate.recordViewShouldBeginRecording(self) {
361362
NSSound.beep()
362363
return false
363364
}
@@ -371,7 +372,7 @@ extension RecordView {
371372
return true
372373
}
373374

374-
public func endRecording() {
375+
func endRecording() {
375376
if !isRecording { return }
376377

377378
inputModifiers = NSEvent.ModifierFlags(rawValue: 0)
@@ -391,40 +392,40 @@ extension RecordView {
391392
}
392393

393394
// MARK: - Clear Keys
394-
extension RecordView {
395-
public func clear() {
395+
public extension RecordView {
396+
func clear() {
396397
keyCombo = nil
397398
inputModifiers = NSEvent.ModifierFlags(rawValue: 0)
398399
needsDisplay = true
399400
didChange?(nil)
400401
delegate?.recordViewDidClearShortcut(self)
401402
}
402403

403-
@objc public func clearAndEndRecording() {
404+
@objc func clearAndEndRecording() {
404405
clear()
405406
endRecording()
406407
}
407408
}
408409

409410
// MARK: - Modifiers
410-
extension RecordView {
411-
fileprivate func validateModifiers(_ modifiers: NSEvent.ModifierFlags?) -> Bool {
411+
private extension RecordView {
412+
func validateModifiers(_ modifiers: NSEvent.ModifierFlags?) -> Bool {
412413
guard let modifiers = modifiers else { return false }
413414
return KeyTransformer.carbonFlags(from: modifiers) != 0
414415
}
415416
}
416417

417418
// MARK: - Bool Extension
418-
extension Bool {
419-
fileprivate var intValue: Int {
419+
private extension Bool {
420+
var intValue: Int {
420421
return NSNumber(value: self).intValue
421422
}
422423
}
423424

424425
// MARK: - NSColor Extensio
425426
// nmacOS 10.14 polyfill
426-
extension NSColor {
427-
fileprivate static let controlAccentPolyfill: NSColor = {
427+
private extension NSColor {
428+
static let controlAccentPolyfill: NSColor = {
428429
if #available(macOS 10.14, *) {
429430
return NSColor.controlAccentColor
430431
} else {

Lib/KeyHolderTests/KeyHolderTests.swift

+6-13
Original file line numberDiff line numberDiff line change
@@ -14,27 +14,20 @@ import XCTest
1414
@testable import KeyHolder
1515

1616
class KeyHolderTests: XCTestCase {
17-
17+
1818
override func setUp() {
1919
super.setUp()
20-
// Put setup code here. This method is called before the invocation of each test method in the class.
2120
}
22-
21+
2322
override func tearDown() {
24-
// Put teardown code here. This method is called after the invocation of each test method in the class.
2523
super.tearDown()
2624
}
27-
28-
func testExample() {
29-
// This is an example of a functional test case.
30-
// Use XCTAssert and related functions to verify your tests produce the correct results.
31-
}
32-
25+
26+
func testExample() {}
27+
3328
func testPerformanceExample() {
34-
// This is an example of a performance test case.
3529
self.measure {
36-
// Put the code you want to measure the time of here.
3730
}
3831
}
39-
32+
4033
}

Mintfile

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

0 commit comments

Comments
 (0)