danger-swiftlint 0.10.0 → 0.10.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/Changelog.md +5 -0
- data/Gemfile.lock +2 -2
- data/README.md +2 -0
- data/lib/danger_plugin.rb +20 -8
- data/lib/version.rb +1 -1
- data/spec/danger_plugin_spec.rb +45 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f71b06256f2784921e22fbdc37355c02c0e254b3
|
4
|
+
data.tar.gz: c1ea5e23bfb6ad68c56a00df4576c5d0b10298a3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bb46882114d80a100b1c4a5cc932c923becc6540c3f893378df3a5c0120b5ae3f5bfcdc29653f19064145a8c0f2fb480764058b61a3fc1c81202159c19aeb403
|
7
|
+
data.tar.gz: 260ae84694e2b4193376b4df088048f53d0c830f94d66c3bf408fe5efe7bfa727bde836c360db6765af3e699b5c1d648fc7719b0d1c6a5234783df318fce8443
|
data/Changelog.md
CHANGED
@@ -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).
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
danger-swiftlint (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.
|
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/).
|
data/lib/danger_plugin.rb
CHANGED
@@ -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
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
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
|
-
|
181
|
-
|
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
|
data/lib/version.rb
CHANGED
data/spec/danger_plugin_spec.rb
CHANGED
@@ -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.
|
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-
|
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.
|
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.
|