danger-swiftlint 0.24.4 → 0.27.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
2
  SHA256:
3
- metadata.gz: 683d845df224c2d9d4739b53011fa985ec25808d941781d82329761e9a5f4a08
4
- data.tar.gz: bf54a06f76d88406230b451440aae8b42bbca2c2b517140e3fb20b533826be75
3
+ metadata.gz: 4a979dbfbd991937d41dad406c1dd157e2110af61cf3854cdf6cf16da24b4c01
4
+ data.tar.gz: d1f7c58afd46ed7202b33e11f59e56f00c5f50e8ffc1a37254695c87bcda6b3a
5
5
  SHA512:
6
- metadata.gz: cf25410d65d64ca8bc7e55a6482ab06d1e2d50b7ab30ef8ab6a3fc0951bd689948169e3b9d5f33ddd2dd4bbb8224f4a8290927fe8042a1e63c5437c49699f46a
7
- data.tar.gz: 43a48cd8e46d7fd0474047252f5c8ac75a50de2647922d6251f1ba57f820af083234583b89465b0bda957a86208a96078c8c6d94b0d665b9d193ad1aadb428a0
6
+ metadata.gz: 0753bc62476184adb833077774cf266e5c2fec07931edb4cb3b633ae960d3454200172fcf1cb9720ea6cecdde6df3d33faa726afba03e73122401a274dd57d1a
7
+ data.tar.gz: 2e46137121434ea0ae42ec6c27b7f345e20ec65ae65494670b45764a70db87284d41e3a78f7b52942dd22a25fd2d9993623df729408a9b4381dec385f1e9b68e
@@ -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
@@ -46,7 +46,7 @@ module Danger
46
46
 
47
47
  # Errors found
48
48
  attr_accessor :errors
49
-
49
+
50
50
  # All issues found
51
51
  attr_accessor :issues
52
52
 
@@ -67,12 +67,12 @@ module Danger
67
67
  # Fails if swiftlint isn't installed
68
68
  raise 'swiftlint is not installed' unless swiftlint.installed?
69
69
 
70
- config_file_path = if config_file
71
- config_file
72
- elsif File.file?('.swiftlint.yml')
73
- File.expand_path('.swiftlint.yml')
74
- end
75
- log "Using config file: #{config_file_path}"
70
+ config_file_path = config_file
71
+ if config_file_path
72
+ log "Using config file: #{config_file_path}"
73
+ else
74
+ log 'Config file was not specified.'
75
+ end
76
76
 
77
77
  dir_selected = directory ? File.expand_path(directory) : Dir.pwd
78
78
  log "Swiftlint will be run from #{dir_selected}"
@@ -124,7 +124,7 @@ module Danger
124
124
  issues = issues.take(@max_num_violations)
125
125
  end
126
126
  log "Received from Swiftlint: #{issues}"
127
-
127
+
128
128
  # filter out any unwanted violations with the passed in select_block
129
129
  if select_block && !no_comment
130
130
  issues = issues.select { |issue| select_block.call(issue) }
@@ -133,7 +133,7 @@ module Danger
133
133
  # Filter warnings and errors
134
134
  @warnings = issues.select { |issue| issue['severity'] == 'Warning' }
135
135
  @errors = issues.select { |issue| issue['severity'] == 'Error' }
136
-
136
+
137
137
  # Early exit so we don't comment
138
138
  return if no_comment
139
139
 
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.4'
5
- SWIFTLINT_VERSION = '0.40.1'
4
+ VERSION = '0.27.0'
5
+ SWIFTLINT_VERSION = '0.43.1'
6
6
  end
@@ -314,24 +314,6 @@ module Danger
314
314
  @swiftlint.lint_files
315
315
  end
316
316
 
317
- it 'expands default config file (if present) to absolute path' do
318
- allow(@swiftlint.git).to receive(:added_files).and_return([])
319
- allow(@swiftlint.git).to receive(:modified_files).and_return([
320
- 'spec/fixtures/SwiftFile.swift'
321
- ])
322
- expect(File).to receive(:file?).and_return(true)
323
- expect(File).to receive(:exist?).and_return(true)
324
- expect(File).to receive(:open).and_return(StringIO.new)
325
- expect(YAML).to receive(:safe_load).and_return({})
326
-
327
- expect_any_instance_of(Swiftlint).to receive(:lint)
328
- .with(hash_including(config: File.expand_path('.swiftlint.yml')), '', anything)
329
- .once
330
- .and_return(@swiftlint_response)
331
-
332
- @swiftlint.lint_files
333
- end
334
-
335
317
  it 'expands specified config file to absolute path' do
336
318
  allow(@swiftlint.git).to receive(:added_files).and_return([])
337
319
  allow(@swiftlint.git).to receive(:modified_files).and_return([
@@ -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.4
4
+ version: 0.27.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-08-27 00:00:00.000000000 Z
15
+ date: 2021-08-23 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,8 +180,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
180
180
  - !ruby/object:Gem::Version
181
181
  version: '0'
182
182
  requirements: []
183
- rubygems_version: 3.0.6
184
- signing_key:
183
+ rubygems_version: 3.2.20
184
+ signing_key:
185
185
  specification_version: 4
186
186
  summary: A Danger plugin for linting Swift with SwiftLint.
187
187
  test_files: