danger-swiftlint 0.17.5 → 0.18.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
- SHA1:
3
- metadata.gz: f5939f208eecce698f379e691a8ce42d8c99c6f7
4
- data.tar.gz: d1581c29cd30db64e06d4e17fa1243db98258c0d
2
+ SHA256:
3
+ metadata.gz: deadbe6d57c929c594070425f46f30801dc55fce99f384b9773d4feceaefecea
4
+ data.tar.gz: bf49b1851d79915d02db6b6ddb4ffd7701677fe23cab3b6e38a9b0cbc0f86aa8
5
5
  SHA512:
6
- metadata.gz: 6176320c263544e8208dc8b0f059de386b3e634d2782662d6494914b28e44e9fc418a496f9306844e4148711de4cdc09ea0a05d7b8872a0ef0d06f82d4cd7983
7
- data.tar.gz: 32011ada543a29f5cce86402e7a1d49920dcb137385d928c95a64751067dc08a933b5a766bf638ab842dae827118ada2b322788ba502c3885aeb685dbd455d30
6
+ metadata.gz: f217f055c54cdbc7ef59b54a526ade9ca38afffb7767d2c549c5ae4036bba484973f95dee8367175ea955f901f49a5e3c34b95c2ef2ad5107d5fc44edfa33b09
7
+ data.tar.gz: b405c26b1046a2f5b81d059a9dae12c9f1584e1c4b08568a5b9d4a2031312c7b244682bed57570da23f90d5075ae4ddf40c0f368fd9507d67ca5a0e00f0f0f69
@@ -35,6 +35,9 @@ module Danger
35
35
  # Provides additional logging diagnostic information.
36
36
  attr_accessor :verbose
37
37
 
38
+ # Whether all files should be linted in one pass
39
+ attr_accessor :lint_all_files
40
+
38
41
  # Lints Swift files. Will fail if `swiftlint` cannot be installed correctly.
39
42
  # Generates a `markdown` list of warnings for the prose in a corpus of
40
43
  # .markdown and .md files.
@@ -88,7 +91,7 @@ module Danger
88
91
  log "linting with options: #{options}"
89
92
 
90
93
  # Lint each file and collect the results
91
- issues = run_swiftlint(files, options, additional_swiftlint_args)
94
+ issues = run_swiftlint(files, lint_all_files, options, additional_swiftlint_args)
92
95
  other_issues_count = 0
93
96
  unless @max_num_violations.nil?
94
97
  other_issues_count = issues.count - @max_num_violations if issues.count > @max_num_violations
@@ -123,13 +126,22 @@ module Danger
123
126
  # Run swiftlint on each file and aggregate collect the issues
124
127
  #
125
128
  # @return [Array] swiftlint issues
126
- def run_swiftlint(files, options, additional_swiftlint_args)
127
- files
128
- .map { |file| options.merge(path: file) }
129
- .map { |full_options| swiftlint.lint(full_options, additional_swiftlint_args) }
130
- .reject { |s| s == '' }
131
- .map { |s| JSON.parse(s).flatten }
132
- .flatten
129
+ def run_swiftlint(files, lint_all_files, options, additional_swiftlint_args)
130
+ if lint_all_files
131
+ result = swiftlint.lint(options, additional_swiftlint_args)
132
+ if result == ''
133
+ {}
134
+ else
135
+ JSON.parse(result).flatten
136
+ end
137
+ else
138
+ files
139
+ .map { |file| options.merge(path: file) }
140
+ .map { |full_options| swiftlint.lint(full_options, additional_swiftlint_args) }
141
+ .reject { |s| s == '' }
142
+ .map { |s| JSON.parse(s).flatten }
143
+ .flatten
144
+ end
133
145
  end
134
146
 
135
147
  # Find swift files from the files glob
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DangerSwiftlint
4
- VERSION = '0.17.5'
4
+ VERSION = '0.18.0'
5
5
  SWIFTLINT_VERSION = '0.28.1'
6
6
  end
@@ -353,6 +353,22 @@ module Danger
353
353
  @swiftlint.config_file = 'spec/fixtures/environment_variable_config.yml'
354
354
  @swiftlint.lint_files
355
355
  end
356
+
357
+ it 'runs SwiftLint only once if lint_all_files is set' do
358
+ allow(@swiftlint.git).to receive(:added_files).and_return([])
359
+ allow(@swiftlint.git).to receive(:modified_files).and_return([
360
+ 'spec/fixtures/SwiftFile.swift',
361
+ 'spec/fixtures/SwiftFile2.swift'
362
+ ])
363
+
364
+ expect_any_instance_of(Swiftlint).to receive(:lint)
365
+ .with(hash_including(config: nil), '')
366
+ .once
367
+ .and_return(@swiftlint_response)
368
+
369
+ @swiftlint.lint_all_files = true
370
+ @swiftlint.lint_files
371
+ end
356
372
  end
357
373
  end
358
374
  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.17.5
4
+ version: 0.18.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: 2018-11-20 00:00:00.000000000 Z
15
+ date: 2018-11-29 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: danger
@@ -181,7 +181,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
181
181
  version: '0'
182
182
  requirements: []
183
183
  rubyforge_project:
184
- rubygems_version: 2.6.11
184
+ rubygems_version: 2.7.6
185
185
  signing_key:
186
186
  specification_version: 4
187
187
  summary: A Danger plugin for linting Swift with SwiftLint.