danger-swiftlint 0.19.2 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/danger_plugin.rb +6 -1
- data/lib/version.rb +1 -1
- data/spec/danger_plugin_spec.rb +24 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8a64dedaa81fb282247ffe2cbc5e13f5dc6f3d5e9ce9ab61e897d005aca35102
|
4
|
+
data.tar.gz: 3eeaafa30861ae658cbeee4201f24460046a2a7d0d150e847318ff4919f5679e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5f6b2f29d79a17c03762310ead3ed2d4ab70d8cd68684d98711fb2d256737495e9ff4309f47469cab5edf8a1d6950bb8a188cd770c53c9aa4a8261dd20df22ad
|
7
|
+
data.tar.gz: 9b6c2fbc47d8d75e637d2e205d644c36831237731ee6d3b4291811786039157584cf61dab01bda6d94a40a463fe2766a409b5eb38bfaab5801fa6da7b8f9bf3f
|
data/lib/danger_plugin.rb
CHANGED
@@ -48,7 +48,7 @@ module Danger
|
|
48
48
|
# if nil, modified and added files from the diff will be used.
|
49
49
|
# @return [void]
|
50
50
|
#
|
51
|
-
def lint_files(files = nil, inline_mode: false, fail_on_error: false, additional_swiftlint_args: '')
|
51
|
+
def lint_files(files = nil, inline_mode: false, fail_on_error: false, additional_swiftlint_args: '', &select_block)
|
52
52
|
# Fails if swiftlint isn't installed
|
53
53
|
raise 'swiftlint is not installed' unless swiftlint.installed?
|
54
54
|
|
@@ -98,6 +98,11 @@ module Danger
|
|
98
98
|
issues = issues.take(@max_num_violations)
|
99
99
|
end
|
100
100
|
log "Received from Swiftlint: #{issues}"
|
101
|
+
|
102
|
+
# filter out any unwanted violations with the passed in select_block
|
103
|
+
if select_block
|
104
|
+
issues.select! { |issue| select_block.call(issue) }
|
105
|
+
end
|
101
106
|
|
102
107
|
# Filter warnings and errors
|
103
108
|
warnings = issues.select { |issue| issue['severity'] == 'Warning' }
|
data/lib/version.rb
CHANGED
data/spec/danger_plugin_spec.rb
CHANGED
@@ -42,6 +42,8 @@ module Danger
|
|
42
42
|
allow(@swiftlint.git).to receive(:modified_files).and_return([])
|
43
43
|
|
44
44
|
@swiftlint_response = '[{ "rule_id" : "force_cast", "reason" : "Force casts should be avoided.", "character" : 19, "file" : "/Users/me/this_repo/spec//fixtures/SwiftFile.swift", "severity" : "Error", "type" : "Force Cast", "line" : 13 }]'
|
45
|
+
@swiftlint_multiviolation_response = '[{ "rule_id" : "force_cast", "reason" : "Force casts should be avoided.", "character" : 19, "file" : "/Users/me/this_repo/spec//fixtures/SwiftFile.swift", "severity" : "Error", "type" : "Force Cast", "line" : 13 },
|
46
|
+
{ "rule_id" : "force_cast", "reason" : "Force casts should be avoided.", "character" : 10, "file" : "/Users/me/this_repo/spec//fixtures/SwiftFile.swift", "severity" : "Error", "type" : "Force Cast", "line" : 16 }]'
|
45
47
|
end
|
46
48
|
|
47
49
|
after(:each) do
|
@@ -380,6 +382,28 @@ module Danger
|
|
380
382
|
@swiftlint.lint_all_files = true
|
381
383
|
@swiftlint.lint_files
|
382
384
|
end
|
385
|
+
|
386
|
+
it 'filters violations based on select block' do
|
387
|
+
allow_any_instance_of(Swiftlint).to receive(:lint)
|
388
|
+
.with(hash_including(pwd: File.expand_path('.')), '')
|
389
|
+
.and_return(@swiftlint_multiviolation_response)
|
390
|
+
|
391
|
+
@swiftlint.lint_files(['spec/fixtures/some\ dir/SwiftFile.swift'], inline_mode: true) { |violation|
|
392
|
+
violation["line"] != 16
|
393
|
+
}
|
394
|
+
status = @swiftlint.status_report
|
395
|
+
expect(status[:warnings]).to eql(["Force casts should be avoided.\n`force_cast` `SwiftFile.swift:13`"])
|
396
|
+
end
|
397
|
+
|
398
|
+
it 'filters nothing out if not passed a select block' do
|
399
|
+
allow_any_instance_of(Swiftlint).to receive(:lint)
|
400
|
+
.with(hash_including(pwd: File.expand_path('.')), '')
|
401
|
+
.and_return(@swiftlint_multiviolation_response)
|
402
|
+
|
403
|
+
@swiftlint.lint_files(['spec/fixtures/some\ dir/SwiftFile.swift'], inline_mode: true)
|
404
|
+
status = @swiftlint.status_report
|
405
|
+
expect(status[:warnings].length).to eql(2)
|
406
|
+
end
|
383
407
|
end
|
384
408
|
end
|
385
409
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: danger-swiftlint
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.20.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ash Furrow
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2019-03-
|
15
|
+
date: 2019-03-19 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: danger
|