danger-swiftlint 0.24.1 → 0.25.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c5e0ae1a58601a02041afbbc49b06015411d234ad6ff0f541832af053b860a18
4
- data.tar.gz: b13fa389a8c0e4de1d70cf4e87e6347577199aff4f4d338092436fb66217122f
3
+ metadata.gz: 2acb2fde07b59fcb04f29d9e82eb3a9d195ab4af4116defcde1ea77c8ba1df26
4
+ data.tar.gz: 89ee290c7e49090017c7f74b2a618ffd970a41f57fe470682de55fd7ad39b2da
5
5
  SHA512:
6
- metadata.gz: fea1c7af5a3e04955357c7f485fe8965509193df5152dbf6da935ffe3ca02de352790df418055d029b93c6f5b226c5bb1f06d4657313b98e244e47d8d1ef9116
7
- data.tar.gz: 78db4cb509956091213c021025be9399e99734e47e9d51f700a93a18249c21f9acc296b7ab7a00e219ed5664355dc5ba43e2e602cf292829831be4320a3a9e47
6
+ metadata.gz: e5460d0a048ea06577fffc36b312811a0e545fd661706b322fa7a0f9e35900388b975363d1e7b2d54175e8f333c84e1254f5d1ecc7b436ceb2e9491713af48ca
7
+ data.tar.gz: 5f6791e6f7a700c7a1be573b032615d8db75acb313d9c775296048e30a4e0aadec6e39c12533c7ccd1bb1d1d802b2a590c5ef2c005a6aa3a335177f3b3d497ba
@@ -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 run swiftlint
12
- Dir.chdir options.delete(:pwd) if options.key? :pwd
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
- `#{swiftlint_path} #{cmd} #{swiftlint_arguments(options, additional_swiftlint_args)}`
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
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DangerSwiftlint
4
- VERSION = '0.24.1'
5
- SWIFTLINT_VERSION = '0.38.0'
4
+ VERSION = '0.25.0'
5
+ SWIFTLINT_VERSION = '0.41.0'
6
6
  end
@@ -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(23)
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
@@ -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.24.1
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: 2020-02-11 00:00:00.000000000 Z
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
- rubyforge_project:
184
- rubygems_version: 2.7.6
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: