danger-swiftlint 0.26.0 → 0.29.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/swiftlint/Rakefile +2 -6
- data/lib/danger_plugin.rb +7 -5
- data/lib/version.rb +3 -2
- data/spec/danger_plugin_spec.rb +30 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d720b57c16c8aff2cce79424d89a1842fa8b75429b76ffd9ec8996dbad156165
|
4
|
+
data.tar.gz: f31202cd4c98f1060bbe1ea0e533f4dc97796ec6eff28f27baf806f77fa1944a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ca97ce0a8f2c819dd0dda81b68bb7ef7244ac0f454b9f7769eb927c9ed85944c185cfb641d8b3517c0b0b7972991de058cf953fc450404c2d37532b47ddcf1fe
|
7
|
+
data.tar.gz: 6ed0689373d2fe221abbd1f9be170d1b8a1e8087e53640a3b157273c9b63ca391125b40241b5e17e27c4217531424e0759ff562ad934e57097f67d2001d0e0df
|
data/ext/swiftlint/Rakefile
CHANGED
@@ -12,14 +12,10 @@ namespace :swiftlint do
|
|
12
12
|
ASSET = 'portable_swiftlint.zip'
|
13
13
|
URL = "#{REPO}/releases/download/#{VERSION}/#{ASSET}"
|
14
14
|
DESTINATION = File.expand_path(File.join(File.dirname(__FILE__), 'bin'))
|
15
|
+
SWIFTLINT_MD5_HASH = DangerSwiftlint::SWIFTLINT_HASH
|
15
16
|
|
16
17
|
puts "Downloading swiftlint@#{VERSION}"
|
17
|
-
sh
|
18
|
-
"mkdir -p '#{DESTINATION}'",
|
19
|
-
"curl -s -L #{URL} -o #{ASSET}",
|
20
|
-
"unzip -q #{ASSET} -d '#{DESTINATION}'",
|
21
|
-
"rm #{ASSET}"
|
22
|
-
].join(' && ')
|
18
|
+
sh "sh downloadSwiftlint.sh -u #{URL} -d #{DESTINATION} -a #{ASSET} -dh #{SWIFTLINT_MD5_HASH}"
|
23
19
|
end
|
24
20
|
end
|
25
21
|
|
data/lib/danger_plugin.rb
CHANGED
@@ -210,11 +210,13 @@ module Danger
|
|
210
210
|
# @return [Array] swift files
|
211
211
|
def find_swift_files(dir_selected, files = nil, excluded_paths = [], included_paths = [])
|
212
212
|
# Assign files to lint
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
213
|
+
if files.nil?
|
214
|
+
renamed_files_hash = git.renamed_files.map { |rename| [rename[:before], rename[:after]] }.to_h
|
215
|
+
post_rename_modified_files = git.modified_files.map { |modified_file| renamed_files_hash[modified_file] || modified_file }
|
216
|
+
files = (post_rename_modified_files - git.deleted_files) + git.added_files
|
217
|
+
else
|
218
|
+
files = Dir.glob(files)
|
219
|
+
end
|
218
220
|
# Filter files to lint
|
219
221
|
excluded_paths_list = Find.find(*excluded_paths).to_a
|
220
222
|
included_paths_list = Find.find(*included_paths).to_a
|
data/lib/version.rb
CHANGED
data/spec/danger_plugin_spec.rb
CHANGED
@@ -143,6 +143,7 @@ module Danger
|
|
143
143
|
it 'uses git diff when files are not provided' do
|
144
144
|
allow(@swiftlint.git).to receive(:modified_files).and_return(['spec/fixtures/SwiftFile.swift'])
|
145
145
|
allow(@swiftlint.git).to receive(:added_files).and_return([])
|
146
|
+
allow(@swiftlint.git).to receive(:renamed_files).and_return([])
|
146
147
|
allow_any_instance_of(Swiftlint).to receive(:lint)
|
147
148
|
.with(anything, '',
|
148
149
|
{ 'SCRIPT_INPUT_FILE_COUNT' => '1',
|
@@ -187,6 +188,7 @@ module Danger
|
|
187
188
|
'spec/fixtures/some_dir/SwiftFile.swift',
|
188
189
|
'spec/fixtures/SwiftFile.swift'
|
189
190
|
])
|
191
|
+
allow(@swiftlint.git).to receive(:renamed_files).and_return([])
|
190
192
|
|
191
193
|
expect_any_instance_of(Swiftlint).to receive(:lint)
|
192
194
|
.with(anything, '',
|
@@ -212,10 +214,29 @@ module Danger
|
|
212
214
|
# JSON object.
|
213
215
|
|
214
216
|
allow_any_instance_of(Swiftlint).to receive(:lint).and_return('')
|
217
|
+
allow(@swiftlint.git).to receive(:renamed_files).and_return([])
|
215
218
|
|
216
219
|
expect { @swiftlint.lint_files }.not_to raise_error
|
217
220
|
end
|
218
221
|
|
222
|
+
it 'crashes if renamed_files is not configured properly' do
|
223
|
+
allow(@swiftlint.git).to receive(:modified_files).and_return([
|
224
|
+
'spec/fixtures/SwiftFileThatWasRenamedToSomethingElse.swift'
|
225
|
+
])
|
226
|
+
expect { @swiftlint.lint_files }.to raise_error(NoMethodError)
|
227
|
+
end
|
228
|
+
|
229
|
+
it 'does not crash if a modified file was renamed' do
|
230
|
+
allow(@swiftlint.git).to receive(:modified_files).and_return([
|
231
|
+
'spec/fixtures/SwiftFileThatWasRenamedToSomethingElse.swift'
|
232
|
+
])
|
233
|
+
allow(@swiftlint.git).to receive(:renamed_files).and_return([
|
234
|
+
{ before: 'spec/fixtures/SwiftFileThatWasRenamedToSomethingElse.swift',
|
235
|
+
after: 'spec/fixtures/SwiftFile.swift' }
|
236
|
+
])
|
237
|
+
expect { @swiftlint.lint_files }.not_to raise_error
|
238
|
+
end
|
239
|
+
|
219
240
|
it 'does not lint files in the excluded paths' do
|
220
241
|
allow(@swiftlint.git).to receive(:added_files).and_return([])
|
221
242
|
allow(@swiftlint.git).to receive(:modified_files).and_return([
|
@@ -223,7 +244,7 @@ module Danger
|
|
223
244
|
'spec/fixtures/excluded_dir/SwiftFileThatShouldNotBeIncluded.swift',
|
224
245
|
'spec/fixtures/excluded_dir/SwiftFile WithEscaped+CharactersThatShouldNotBeIncluded.swift'
|
225
246
|
])
|
226
|
-
|
247
|
+
allow(@swiftlint.git).to receive(:renamed_files).and_return([])
|
227
248
|
expect_any_instance_of(Swiftlint).to receive(:lint)
|
228
249
|
.with(anything, '',
|
229
250
|
{ 'SCRIPT_INPUT_FILE_COUNT' => '1',
|
@@ -241,6 +262,7 @@ module Danger
|
|
241
262
|
'spec/fixtures/SwiftFile.swift',
|
242
263
|
'spec/fixtures/some_dir/SwiftFile.swift'
|
243
264
|
])
|
265
|
+
allow(@swiftlint.git).to receive(:renamed_files).and_return([])
|
244
266
|
|
245
267
|
expect_any_instance_of(Swiftlint).to receive(:lint)
|
246
268
|
.with(anything, '',
|
@@ -259,6 +281,7 @@ module Danger
|
|
259
281
|
'spec/fixtures/SwiftFile.swift',
|
260
282
|
'spec/fixtures/some_dir/SwiftFile.swift'
|
261
283
|
])
|
284
|
+
allow(@swiftlint.git).to receive(:renamed_files).and_return([])
|
262
285
|
|
263
286
|
expect_any_instance_of(Swiftlint).to receive(:lint)
|
264
287
|
.with(anything, '',
|
@@ -277,6 +300,7 @@ module Danger
|
|
277
300
|
allow(@swiftlint.git).to receive(:modified_files).and_return([
|
278
301
|
'spec/fixtures/SwiftFile.swift'
|
279
302
|
])
|
303
|
+
allow(@swiftlint.git).to receive(:renamed_files).and_return([])
|
280
304
|
|
281
305
|
expect_any_instance_of(Swiftlint).to receive(:lint)
|
282
306
|
.once
|
@@ -291,6 +315,7 @@ module Danger
|
|
291
315
|
allow(@swiftlint.git).to receive(:modified_files).and_return([
|
292
316
|
'spec/fixtures/SwiftFile.swift'
|
293
317
|
])
|
318
|
+
allow(@swiftlint.git).to receive(:renamed_files).and_return([])
|
294
319
|
|
295
320
|
expect_any_instance_of(Swiftlint).to receive(:lint)
|
296
321
|
.once
|
@@ -305,6 +330,7 @@ module Danger
|
|
305
330
|
allow(@swiftlint.git).to receive(:modified_files).and_return([
|
306
331
|
'spec/fixtures/SwiftFile.swift'
|
307
332
|
])
|
333
|
+
allow(@swiftlint.git).to receive(:renamed_files).and_return([])
|
308
334
|
|
309
335
|
expect_any_instance_of(Swiftlint).to receive(:lint)
|
310
336
|
.with(hash_including(config: nil), '', anything)
|
@@ -319,6 +345,7 @@ module Danger
|
|
319
345
|
allow(@swiftlint.git).to receive(:modified_files).and_return([
|
320
346
|
'spec/fixtures/SwiftFile.swift'
|
321
347
|
])
|
348
|
+
allow(@swiftlint.git).to receive(:renamed_files).and_return([])
|
322
349
|
|
323
350
|
expect_any_instance_of(Swiftlint).to receive(:lint)
|
324
351
|
.with(hash_including(config: 'spec/fixtures/some_config.yml'), '', anything)
|
@@ -342,6 +369,7 @@ module Danger
|
|
342
369
|
allow(@swiftlint.git).to receive(:deleted_files).and_return([
|
343
370
|
'spec/fixtures/DeletedFile.swift'
|
344
371
|
])
|
372
|
+
allow(@swiftlint.git).to receive(:renamed_files).and_return([])
|
345
373
|
|
346
374
|
expect_any_instance_of(Swiftlint).to receive(:lint)
|
347
375
|
.with(anything, '',
|
@@ -578,6 +606,7 @@ module Danger
|
|
578
606
|
'spec/fixtures/excluded_dir/SwiftFileThatShouldNotBeIncluded.swift',
|
579
607
|
'spec/fixtures/excluded_dir/SwiftFile WithEscaped+CharactersThatShouldNotBeIncluded.swift'
|
580
608
|
])
|
609
|
+
allow(@swiftlint.git).to receive(:renamed_files).and_return([])
|
581
610
|
|
582
611
|
expect_any_instance_of(Swiftlint).to receive(:lint)
|
583
612
|
.once
|
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.29.1
|
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: 2021-
|
15
|
+
date: 2021-09-07 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: danger
|
@@ -180,7 +180,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
180
180
|
- !ruby/object:Gem::Version
|
181
181
|
version: '0'
|
182
182
|
requirements: []
|
183
|
-
rubygems_version: 3.
|
183
|
+
rubygems_version: 3.2.20
|
184
184
|
signing_key:
|
185
185
|
specification_version: 4
|
186
186
|
summary: A Danger plugin for linting Swift with SwiftLint.
|