danger-swiftlint 0.19.2 → 0.20.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e454d76dbacac01e067ad464c69c2996cf698432ebf7ea7bf8cf02f5006ed12e
4
- data.tar.gz: 24d2c962266a42183681377f188ee912fbabff22d82c1e9a73d4e2505bcad87b
3
+ metadata.gz: 8a64dedaa81fb282247ffe2cbc5e13f5dc6f3d5e9ce9ab61e897d005aca35102
4
+ data.tar.gz: 3eeaafa30861ae658cbeee4201f24460046a2a7d0d150e847318ff4919f5679e
5
5
  SHA512:
6
- metadata.gz: 96c6c495b5405ef4b67e1bf7fb3bc1de7275b45eff99739157a2d9ca3c3f4a0ea41127f3a36c722bfdd61f6a41c32201bb8db0155cf5bda8319499cec5a35fc5
7
- data.tar.gz: b6f532d0b70508dd7493984adfc49285b9f43f8a6c57a63c36672457fb3c35e13367fa5373eb648732b811d3ea4a2149e6c7914c425b02e817c446fc55a4ca57
6
+ metadata.gz: 5f6b2f29d79a17c03762310ead3ed2d4ab70d8cd68684d98711fb2d256737495e9ff4309f47469cab5edf8a1d6950bb8a188cd770c53c9aa4a8261dd20df22ad
7
+ data.tar.gz: 9b6c2fbc47d8d75e637d2e205d644c36831237731ee6d3b4291811786039157584cf61dab01bda6d94a40a463fe2766a409b5eb38bfaab5801fa6da7b8f9bf3f
@@ -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' }
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DangerSwiftlint
4
- VERSION = '0.19.2'
4
+ VERSION = '0.20.0'
5
5
  SWIFTLINT_VERSION = '0.31.0'
6
6
  end
@@ -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.19.2
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-14 00:00:00.000000000 Z
15
+ date: 2019-03-19 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: danger