danger-swiftlint 0.37.0 → 0.37.1
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 +8 -1
- data/lib/version.rb +1 -1
- data/spec/danger_plugin_spec.rb +35 -0
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ff11fd5cb49834d9d5495ea2e86c06dc2438d099034c9f3eb2882f6c07e096cb
|
4
|
+
data.tar.gz: 5a3fa5e6a9f73b0795b2f9468b2b48b2d11e5e0290bc48b793a0a62644bbf212
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ae7534cc07aaee284fe90a84abbe13ae21b63cb14a9daacd2e2a56cf91b0d3e127babaf4147c2622575043736236df80e52c9ec5b6c76330dd1aaf74f0fe9632
|
7
|
+
data.tar.gz: ab63d18d2253be8fce920b92095c2e863250edeabfc0cabf35d58cefd91061808465a057f8bb743237f6415da4fc34864c89c7ce2b255e2b915f8169b178bb1f
|
data/lib/danger_plugin.rb
CHANGED
@@ -332,7 +332,7 @@ module Danger
|
|
332
332
|
# @return [Array] swiftlint issues
|
333
333
|
def filter_git_diff_issues(issues)
|
334
334
|
modified_files_info = git_modified_files_info()
|
335
|
-
return issues.select { |i|
|
335
|
+
return issues.select { |i|
|
336
336
|
modified_files_info["#{i['file']}"] != nil && modified_files_info["#{i['file']}"].include?(i['line'].to_i)
|
337
337
|
}
|
338
338
|
end
|
@@ -347,6 +347,13 @@ module Danger
|
|
347
347
|
modified_lines = git_modified_lines(file)
|
348
348
|
modified_files_info[File.expand_path(file)] = modified_lines
|
349
349
|
}
|
350
|
+
git.renamed_files.each { |pair|
|
351
|
+
before_file = pair[:before]
|
352
|
+
after_file = pair[:after]
|
353
|
+
modified_lines = git_modified_lines(before_file)
|
354
|
+
modified_files_info[File.expand_path(after_file)] = modified_lines
|
355
|
+
}
|
356
|
+
|
350
357
|
modified_files_info
|
351
358
|
end
|
352
359
|
|
data/lib/version.rb
CHANGED
data/spec/danger_plugin_spec.rb
CHANGED
@@ -444,6 +444,7 @@ module Danger
|
|
444
444
|
allow(@swiftlint.git).to receive(:deleted_files).and_return([
|
445
445
|
'spec/fixtures/DeletedFile.swift'
|
446
446
|
])
|
447
|
+
allow(@swiftlint.git).to receive(:renamed_files).and_return([])
|
447
448
|
git_diff = File.read("spec/fixtures/SwiftFile.diff")
|
448
449
|
allow(@swiftlint.git).to receive(:diff_for_file).and_return(git_diff)
|
449
450
|
allow(@swiftlint.git.diff_for_file).to receive(:patch).and_return(git_diff)
|
@@ -461,6 +462,7 @@ module Danger
|
|
461
462
|
allow(@swiftlint.git).to receive(:deleted_files).and_return([
|
462
463
|
'spec/fixtures/DeletedFile.swift'
|
463
464
|
])
|
465
|
+
allow(@swiftlint.git).to receive(:renamed_files).and_return([])
|
464
466
|
git_diff = File.read("spec/fixtures/SwiftFile.diff")
|
465
467
|
allow(@swiftlint.git).to receive(:diff_for_file).and_return(git_diff)
|
466
468
|
allow(@swiftlint.git.diff_for_file).to receive(:patch).and_return(git_diff)
|
@@ -485,6 +487,39 @@ module Danger
|
|
485
487
|
expect(status[:warnings]).to eql(["Force casts should be avoided.\n`force_cast` `SwiftFile.swift:16`"])
|
486
488
|
end
|
487
489
|
|
490
|
+
it 'issues violations in renamed_files' do
|
491
|
+
allow(@swiftlint.git).to receive(:added_files).and_return([])
|
492
|
+
allow(@swiftlint.git).to receive(:modified_files).and_return([])
|
493
|
+
allow(@swiftlint.git).to receive(:deleted_files).and_return([])
|
494
|
+
renamed_info = {
|
495
|
+
before: "spec/fixtures/BeforeRenamedSwiftFile.swift",
|
496
|
+
after: "spec/fixtures/SwiftFile.swift"
|
497
|
+
}
|
498
|
+
allow(@swiftlint.git).to receive(:renamed_files).and_return([renamed_info])
|
499
|
+
git_diff = File.read("spec/fixtures/SwiftFile.diff")
|
500
|
+
allow(@swiftlint.git).to receive(:diff_for_file).and_return(git_diff)
|
501
|
+
allow(@swiftlint.git.diff_for_file).to receive(:patch).and_return(git_diff)
|
502
|
+
|
503
|
+
swiftlint_violations_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" : 14 },
|
504
|
+
{ "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 }]'
|
505
|
+
|
506
|
+
violations_json = JSON.parse(swiftlint_violations_response)
|
507
|
+
violations_json[0][:file] = File.expand_path('spec/fixtures/SwiftFile.swift')
|
508
|
+
violations_json[1][:file] = File.expand_path('spec/fixtures/SwiftFile.swift')
|
509
|
+
swiftlint_violations_response= violations_json.to_json
|
510
|
+
allow_any_instance_of(Swiftlint).to receive(:lint)
|
511
|
+
.with(anything, '',
|
512
|
+
{ 'SCRIPT_INPUT_FILE_COUNT' => '1',
|
513
|
+
'SCRIPT_INPUT_FILE_0' => a_string_ending_with('spec/fixtures/SwiftFile.swift') })
|
514
|
+
.and_return(swiftlint_violations_response)
|
515
|
+
|
516
|
+
@swiftlint.filter_issues_in_diff = true
|
517
|
+
@swiftlint.lint_files('spec/fixtures/*.swift', inline_mode: true, fail_on_error: false, additional_swiftlint_args: '')
|
518
|
+
|
519
|
+
status = @swiftlint.status_report
|
520
|
+
expect(status[:warnings]).to eql(["Force casts should be avoided.\n`force_cast` `SwiftFile.swift:16`"])
|
521
|
+
end
|
522
|
+
|
488
523
|
context '#strict' do
|
489
524
|
before(:each) do
|
490
525
|
allow_any_instance_of(Swiftlint).to receive(:lint)
|
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.37.
|
4
|
+
version: 0.37.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ash Furrow
|
@@ -9,10 +9,10 @@ authors:
|
|
9
9
|
- Orta Therox
|
10
10
|
- Thiago Felix
|
11
11
|
- Giovanni Lodi
|
12
|
-
autorequire:
|
12
|
+
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date:
|
15
|
+
date: 2025-02-24 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: danger
|
@@ -166,7 +166,7 @@ homepage: https://github.com/ashfurrow/danger-ruby-swiftlint
|
|
166
166
|
licenses:
|
167
167
|
- MIT
|
168
168
|
metadata: {}
|
169
|
-
post_install_message:
|
169
|
+
post_install_message:
|
170
170
|
rdoc_options: []
|
171
171
|
require_paths:
|
172
172
|
- lib
|
@@ -181,8 +181,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
181
181
|
- !ruby/object:Gem::Version
|
182
182
|
version: '0'
|
183
183
|
requirements: []
|
184
|
-
rubygems_version: 3.
|
185
|
-
signing_key:
|
184
|
+
rubygems_version: 3.5.21
|
185
|
+
signing_key:
|
186
186
|
specification_version: 4
|
187
187
|
summary: A Danger plugin for linting Swift with SwiftLint.
|
188
188
|
test_files:
|