danger-swiftlint 0.10.0 → 0.10.1

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
  SHA1:
3
- metadata.gz: b690ceed1ab30f9d77d77b4381819f85873324a4
4
- data.tar.gz: f74150df221117b74ff2a12d968e9ef1b9593027
3
+ metadata.gz: f71b06256f2784921e22fbdc37355c02c0e254b3
4
+ data.tar.gz: c1ea5e23bfb6ad68c56a00df4576c5d0b10298a3
5
5
  SHA512:
6
- metadata.gz: 9f0a240500772bd1c3b92b4a92baabf663222ba7c6f85ccdcb9ee6412d55a056f8c2a9a4198f513c5f3a252675ad12c68b4cdc7cae86adb56f42629d6f89ec61
7
- data.tar.gz: 5490dcabc7c0a31355c1bb0cb5083b0293a03d2a52658e9f74ec9193586d7a11b0a3ec7b8a4600f4c5dcd3f3455fcb0004dbe85e1492d95cf82f85b052064181
6
+ metadata.gz: bb46882114d80a100b1c4a5cc932c923becc6540c3f893378df3a5c0120b5ae3f5bfcdc29653f19064145a8c0f2fb480764058b61a3fc1c81202159c19aeb403
7
+ data.tar.gz: 260ae84694e2b4193376b4df088048f53d0c830f94d66c3bf408fe5efe7bfa727bde836c360db6765af3e699b5c1d648fc7719b0d1c6a5234783df318fce8443
@@ -4,6 +4,11 @@
4
4
 
5
5
  - Nothing yet!
6
6
 
7
+ ## 0.10.1
8
+
9
+ - Expands config paths to be absolute when passed to `swiftlint`.
10
+ - Adds verbose logging option.
11
+
7
12
  ## 0.10.0
8
13
 
9
14
  - Adds `additional_swiftlint_args` option. See[#57](https://github.com/ashfurrow/danger-swiftlint/issues/57).
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- danger-swiftlint (0.9.0)
4
+ danger-swiftlint (0.10.0)
5
5
  danger
6
6
  rake (> 10)
7
7
  thor (~> 0.19)
@@ -21,7 +21,7 @@ GEM
21
21
  colored2 (3.1.2)
22
22
  cork (0.3.0)
23
23
  colored2 (~> 3.1)
24
- danger (5.5.1)
24
+ danger (5.5.3)
25
25
  claide (~> 1.0)
26
26
  claide-plugins (>= 0.9.2)
27
27
  colored2 (~> 3.1)
data/README.md CHANGED
@@ -50,6 +50,8 @@ swiftlint.lint_files additional_swiftlint_args: '--lenient'
50
50
 
51
51
  You can use the `SWIFTLINT_VERSION` environment variable to override the default version installed via the `rake install` task.
52
52
 
53
+ Finally, if something's not working correctly, you can debug this plugin by using setting `swiftlint.verbose = true`.
54
+
53
55
  ## Attribution
54
56
 
55
57
  Original structure, sequence, and organization of repo taken from [danger-prose](https://github.com/dbgrandi/danger-prose) by [David Grandinetti](https://github.com/dbgrandi/).
@@ -28,6 +28,9 @@ module Danger
28
28
  # Allows you to specify a directory from where swiftlint will be run.
29
29
  attr_accessor :directory
30
30
 
31
+ # Provides additional logging diagnostic information.
32
+ attr_accessor :verbose
33
+
31
34
  # Lints Swift files. Will fail if `swiftlint` cannot be installed correctly.
32
35
  # Generates a `markdown` list of warnings for the prose in a corpus of .markdown and .md files.
33
36
  #
@@ -41,20 +44,23 @@ module Danger
41
44
  raise "swiftlint is not installed" unless swiftlint.is_installed?
42
45
 
43
46
  config = if config_file
44
- config_file
47
+ File.expand_path(config_file)
45
48
  elsif File.file?('.swiftlint.yml')
46
- '.swiftlint.yml'
49
+ File.expand_path('.swiftlint.yml')
47
50
  else
48
51
  nil
49
52
  end
53
+ log "Using config file: #{config}"
50
54
 
51
55
  dir_selected = directory ? File.expand_path(directory) : Dir.pwd
56
+ log "Swiftlint will be run from #{dir_selected}"
52
57
 
53
58
  # Extract excluded paths
54
59
  excluded_paths = excluded_files_from_config(config)
55
60
 
56
61
  # Extract swift files (ignoring excluded ones)
57
62
  files = find_swift_files(files, excluded_paths, dir_selected)
63
+ log "Swiftlint will lint the following files: #{files.join(', ')}"
58
64
 
59
65
  # Prepare swiftlint options
60
66
  options = {
@@ -63,9 +69,11 @@ module Danger
63
69
  quiet: true,
64
70
  pwd: dir_selected
65
71
  }
72
+ log "linting with options: #{options}"
66
73
 
67
74
  # Lint each file and collect the results
68
75
  issues = run_swiftlint(files, options, additional_swiftlint_args)
76
+ log "Received from Swiftlint: #{issues}"
69
77
 
70
78
  # Filter warnings and errors
71
79
  warnings = issues.select { |issue| issue['severity'] == 'Warning' }
@@ -83,10 +91,10 @@ module Danger
83
91
  message << markdown_issues(errors, 'Errors') unless errors.empty?
84
92
  markdown message
85
93
 
86
- # Fail Danger on errors
87
- if fail_on_error && errors.count > 0
88
- fail "Failed due to SwiftLint errors"
89
- end
94
+ # Fail Danger on errors
95
+ if fail_on_error && errors.count > 0
96
+ fail "Failed due to SwiftLint errors"
97
+ end
90
98
  end
91
99
  end
92
100
  end
@@ -177,8 +185,8 @@ module Danger
177
185
  def send_inline_comment (results, method)
178
186
  dir = "#{Dir.pwd}/"
179
187
  results.each do |r|
180
- filename = r['file'].gsub(dir, "")
181
- send(method, r['reason'], file: filename, line: r['line'])
188
+ filename = r['file'].gsub(dir, "")
189
+ send(method, r['reason'], file: filename, line: r['line'])
182
190
  end
183
191
  end
184
192
 
@@ -188,5 +196,9 @@ module Danger
188
196
  def swiftlint
189
197
  Swiftlint.new(binary_path)
190
198
  end
199
+
200
+ def log(text)
201
+ puts(text) if @verbose
202
+ end
191
203
  end
192
204
  end
@@ -1,4 +1,4 @@
1
1
  module DangerSwiftlint
2
- VERSION = "0.10.0".freeze
2
+ VERSION = "0.10.1".freeze
3
3
  SWIFTLINT_VERSION = "0.20.1".freeze
4
4
  end
@@ -156,6 +156,51 @@ module Danger
156
156
  @swiftlint.lint_files
157
157
  end
158
158
 
159
+ it 'default config is nil, unspecified' do
160
+ allow(@swiftlint.git).to receive(:added_files).and_return([])
161
+ allow(@swiftlint.git).to receive(:modified_files).and_return([
162
+ 'spec/fixtures/SwiftFile.swift',
163
+ ])
164
+
165
+ expect_any_instance_of(Swiftlint).to receive(:lint)
166
+ .with(hash_including(:config => nil), '')
167
+ .once
168
+ .and_return(@swiftlint_response)
169
+
170
+ @swiftlint.lint_files
171
+ end
172
+
173
+ it 'expands default config file (if present) to absolute path' do
174
+ allow(@swiftlint.git).to receive(:added_files).and_return([])
175
+ allow(@swiftlint.git).to receive(:modified_files).and_return([
176
+ 'spec/fixtures/SwiftFile.swift',
177
+ ])
178
+ expect(File).to receive(:file?).and_return(true)
179
+ expect(YAML).to receive(:load_file).and_return({})
180
+
181
+ expect_any_instance_of(Swiftlint).to receive(:lint)
182
+ .with(hash_including(:config => File.expand_path('.swiftlint.yml')), '')
183
+ .once
184
+ .and_return(@swiftlint_response)
185
+
186
+ @swiftlint.lint_files
187
+ end
188
+
189
+ it 'expands specified config file to absolute path' do
190
+ allow(@swiftlint.git).to receive(:added_files).and_return([])
191
+ allow(@swiftlint.git).to receive(:modified_files).and_return([
192
+ 'spec/fixtures/SwiftFile.swift',
193
+ ])
194
+
195
+ expect_any_instance_of(Swiftlint).to receive(:lint)
196
+ .with(hash_including(:config => File.expand_path('spec/fixtures/some_config.yml')), '')
197
+ .once
198
+ .and_return(@swiftlint_response)
199
+
200
+ @swiftlint.config_file = 'spec/fixtures/some_config.yml'
201
+ @swiftlint.lint_files
202
+ end
203
+
159
204
  it 'does not lint deleted files paths' do
160
205
  # Danger (4.3.0 at the time of writing) returns deleted files in the
161
206
  # modified fiels array, which kinda makes sense.
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.10.0
4
+ version: 0.10.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: 2017-10-04 00:00:00.000000000 Z
15
+ date: 2017-10-07 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: danger
@@ -197,7 +197,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
197
197
  version: '0'
198
198
  requirements: []
199
199
  rubyforge_project:
200
- rubygems_version: 2.6.13
200
+ rubygems_version: 2.6.11
201
201
  signing_key:
202
202
  specification_version: 4
203
203
  summary: A Danger plugin for linting Swift with SwiftLint.