danger-swiftlint 0.24.1 → 0.25.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/swiftlint/swiftlint.rb +10 -3
- data/lib/danger_plugin.rb +3 -4
- data/lib/version.rb +2 -2
- data/spec/danger_plugin_spec.rb +2 -1
- data/spec/swiftlint_spec.rb +15 -1
- metadata +6 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2acb2fde07b59fcb04f29d9e82eb3a9d195ab4af4116defcde1ea77c8ba1df26
|
4
|
+
data.tar.gz: 89ee290c7e49090017c7f74b2a618ffd970a41f57fe470682de55fd7ad39b2da
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e5460d0a048ea06577fffc36b312811a0e545fd661706b322fa7a0f9e35900388b975363d1e7b2d54175e8f333c84e1254f5d1ecc7b436ceb2e9491713af48ca
|
7
|
+
data.tar.gz: 5f6791e6f7a700c7a1be573b032615d8db75acb313d9c775296048e30a4e0aadec6e39c12533c7ccd1bb1d1d802b2a590c5ef2c005a6aa3a335177f3b3d497ba
|
data/ext/swiftlint/swiftlint.rb
CHANGED
@@ -8,14 +8,21 @@ class Swiftlint
|
|
8
8
|
|
9
9
|
# Runs swiftlint
|
10
10
|
def run(cmd = 'lint', additional_swiftlint_args = '', options = {}, env = nil)
|
11
|
-
# change pwd before
|
12
|
-
|
11
|
+
# allow for temporary change to pwd before running swiftlint
|
12
|
+
pwd = options.delete(:pwd)
|
13
|
+
command = "#{swiftlint_path} #{cmd} #{swiftlint_arguments(options, additional_swiftlint_args)}"
|
13
14
|
|
14
15
|
# Add `env` to environment
|
15
16
|
update_env(env)
|
16
17
|
begin
|
17
18
|
# run swiftlint with provided options
|
18
|
-
|
19
|
+
if pwd
|
20
|
+
Dir.chdir(pwd) do
|
21
|
+
`#{command}`
|
22
|
+
end
|
23
|
+
else
|
24
|
+
`#{command}`
|
25
|
+
end
|
19
26
|
ensure
|
20
27
|
# Remove any ENV variables we might have added
|
21
28
|
restore_env()
|
data/lib/danger_plugin.rb
CHANGED
@@ -69,7 +69,7 @@ module Danger
|
|
69
69
|
|
70
70
|
config_file_path = if config_file
|
71
71
|
config_file
|
72
|
-
elsif File.file?('.swiftlint.yml')
|
72
|
+
elsif !lint_all_files && File.file?('.swiftlint.yml')
|
73
73
|
File.expand_path('.swiftlint.yml')
|
74
74
|
end
|
75
75
|
log "Using config file: #{config_file_path}"
|
@@ -354,8 +354,7 @@ module Danger
|
|
354
354
|
def git_modified_lines(file)
|
355
355
|
git_range_info_line_regex = /^@@ .+\+(?<line_number>\d+),/
|
356
356
|
git_modified_line_regex = /^\+(?!\+|\+)/
|
357
|
-
git_removed_line_regex =
|
358
|
-
git_not_removed_line_regex = /^[^-]/
|
357
|
+
git_removed_line_regex = /^\-(?!\-|\-)/
|
359
358
|
file_info = git.diff_for_file(file)
|
360
359
|
line_number = 0
|
361
360
|
lines = []
|
@@ -367,7 +366,7 @@ module Danger
|
|
367
366
|
when git_modified_line_regex
|
368
367
|
lines << line_number
|
369
368
|
end
|
370
|
-
line_number += 1 if line_number > 0
|
369
|
+
line_number += 1 if line_number > 0 && !git_removed_line_regex.match?(line)
|
371
370
|
line_number = starting_line_number if line_number == 0 && starting_line_number > 0
|
372
371
|
end
|
373
372
|
lines
|
data/lib/version.rb
CHANGED
data/spec/danger_plugin_spec.rb
CHANGED
@@ -419,7 +419,8 @@ module Danger
|
|
419
419
|
allow(@swiftlint.git.diff_for_file).to receive(:patch).and_return(git_diff)
|
420
420
|
modified_lines = @swiftlint.git_modified_lines("spec/fixtures/SwiftFile.swift")
|
421
421
|
expect(modified_lines).to_not be_empty
|
422
|
-
expect(modified_lines.length).to eql(
|
422
|
+
expect(modified_lines.length).to eql(24)
|
423
|
+
expect(modified_lines).to eql([15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 42])
|
423
424
|
end
|
424
425
|
|
425
426
|
it 'Get git modified files info' do
|
data/spec/swiftlint_spec.rb
CHANGED
@@ -25,9 +25,23 @@ describe Swiftlint do
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
+
it 'changes directory when a pwd option is specified' do
|
29
|
+
expect(Dir).to receive(:chdir) do |*args, &block|
|
30
|
+
expect(args).to match_array([Dir.pwd])
|
31
|
+
expect(block).not_to be_nil
|
32
|
+
end
|
33
|
+
swiftlint.run('lint', '', pwd: Dir.pwd)
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'does not change directory when no pwd option is specified' do
|
37
|
+
allow(swiftlint).to receive(:`)
|
38
|
+
expect(Dir).not_to receive(:chdir)
|
39
|
+
swiftlint.run('lint', '')
|
40
|
+
end
|
41
|
+
|
28
42
|
it 'runs lint by default with options being optional' do
|
29
43
|
expect(swiftlint).to receive(:`).with(including('swiftlint lint'))
|
30
|
-
swiftlint.run
|
44
|
+
swiftlint.run('lint', '')
|
31
45
|
end
|
32
46
|
|
33
47
|
it 'runs accepting symbolized options' do
|
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.25.0
|
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: 2021-03-30 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: danger
|
@@ -165,7 +165,7 @@ homepage: https://github.com/ashfurrow/danger-ruby-swiftlint
|
|
165
165
|
licenses:
|
166
166
|
- MIT
|
167
167
|
metadata: {}
|
168
|
-
post_install_message:
|
168
|
+
post_install_message:
|
169
169
|
rdoc_options: []
|
170
170
|
require_paths:
|
171
171
|
- lib
|
@@ -180,9 +180,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
180
180
|
- !ruby/object:Gem::Version
|
181
181
|
version: '0'
|
182
182
|
requirements: []
|
183
|
-
|
184
|
-
|
185
|
-
signing_key:
|
183
|
+
rubygems_version: 3.1.2
|
184
|
+
signing_key:
|
186
185
|
specification_version: 4
|
187
186
|
summary: A Danger plugin for linting Swift with SwiftLint.
|
188
187
|
test_files:
|