danger-swiftlint 0.9.0 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/Changelog.md +4 -0
- data/Gemfile.lock +11 -9
- data/README.md +6 -0
- data/ext/swiftlint/swiftlint.rb +8 -7
- data/lib/danger_plugin.rb +4 -4
- data/lib/version.rb +1 -1
- data/spec/danger_plugin_spec.rb +17 -9
- data/spec/swiftlint_spec.rb +3 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b690ceed1ab30f9d77d77b4381819f85873324a4
|
4
|
+
data.tar.gz: f74150df221117b74ff2a12d968e9ef1b9593027
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9f0a240500772bd1c3b92b4a92baabf663222ba7c6f85ccdcb9ee6412d55a056f8c2a9a4198f513c5f3a252675ad12c68b4cdc7cae86adb56f42629d6f89ec61
|
7
|
+
data.tar.gz: 5490dcabc7c0a31355c1bb0cb5083b0293a03d2a52658e9f74ec9193586d7a11b0a3ec7b8a4600f4c5dcd3f3455fcb0004dbe85e1492d95cf82f85b052064181
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.4.1
|
data/Changelog.md
CHANGED
@@ -4,6 +4,10 @@
|
|
4
4
|
|
5
5
|
- Nothing yet!
|
6
6
|
|
7
|
+
## 0.10.0
|
8
|
+
|
9
|
+
- Adds `additional_swiftlint_args` option. See[#57](https://github.com/ashfurrow/danger-swiftlint/issues/57).
|
10
|
+
|
7
11
|
## 0.9.0
|
8
12
|
|
9
13
|
- Fixes linting of superfluous files in subdirectories. See [#53](https://github.com/ashfurrow/danger-swiftlint/pull/53).
|
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.9.0)
|
5
5
|
danger
|
6
6
|
rake (> 10)
|
7
7
|
thor (~> 0.19)
|
@@ -9,8 +9,8 @@ PATH
|
|
9
9
|
GEM
|
10
10
|
remote: https://rubygems.org/
|
11
11
|
specs:
|
12
|
-
addressable (2.5.
|
13
|
-
public_suffix (
|
12
|
+
addressable (2.5.2)
|
13
|
+
public_suffix (>= 2.0.2, < 4.0)
|
14
14
|
bacon (1.2.0)
|
15
15
|
claide (1.0.2)
|
16
16
|
claide-plugins (0.9.2)
|
@@ -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.
|
24
|
+
danger (5.5.1)
|
25
25
|
claide (~> 1.0)
|
26
26
|
claide-plugins (>= 0.9.2)
|
27
27
|
colored2 (~> 3.1)
|
@@ -30,10 +30,11 @@ GEM
|
|
30
30
|
faraday-http-cache (~> 1.0)
|
31
31
|
git (~> 1)
|
32
32
|
kramdown (~> 1.5)
|
33
|
+
no_proxy_fix
|
33
34
|
octokit (~> 4.7)
|
34
35
|
terminal-table (~> 1)
|
35
36
|
diff-lcs (1.3)
|
36
|
-
faraday (0.
|
37
|
+
faraday (0.13.1)
|
37
38
|
multipart-post (>= 1.2, < 3)
|
38
39
|
faraday-http-cache (1.3.1)
|
39
40
|
faraday (~> 0.8)
|
@@ -54,7 +55,7 @@ GEM
|
|
54
55
|
guard (~> 2.1)
|
55
56
|
guard-compat (~> 1.1)
|
56
57
|
rspec (>= 2.99.0, < 4.0)
|
57
|
-
kramdown (1.
|
58
|
+
kramdown (1.15.0)
|
58
59
|
listen (3.0.7)
|
59
60
|
rb-fsevent (>= 0.9.3)
|
60
61
|
rb-inotify (>= 0.9.7)
|
@@ -68,6 +69,7 @@ GEM
|
|
68
69
|
multipart-post (2.0.0)
|
69
70
|
nap (1.1.0)
|
70
71
|
nenv (0.3.0)
|
72
|
+
no_proxy_fix (0.1.1)
|
71
73
|
notiffany (0.1.1)
|
72
74
|
nenv (~> 0.1)
|
73
75
|
shellany (~> 0.0)
|
@@ -80,8 +82,8 @@ GEM
|
|
80
82
|
coderay (~> 1.1.0)
|
81
83
|
method_source (~> 0.8.1)
|
82
84
|
slop (~> 3.4)
|
83
|
-
public_suffix (
|
84
|
-
rake (12.
|
85
|
+
public_suffix (3.0.0)
|
86
|
+
rake (12.1.0)
|
85
87
|
rb-fsevent (0.9.8)
|
86
88
|
rb-inotify (0.9.8)
|
87
89
|
ffi (>= 0.5.0)
|
@@ -125,4 +127,4 @@ DEPENDENCIES
|
|
125
127
|
rspec (~> 3.4)
|
126
128
|
|
127
129
|
BUNDLED WITH
|
128
|
-
1.15.
|
130
|
+
1.15.1
|
data/README.md
CHANGED
@@ -42,6 +42,12 @@ If you want lint errors to fail Danger, you can use `fail_on_error` option.
|
|
42
42
|
swiftlint.lint_files fail_on_error: true
|
43
43
|
```
|
44
44
|
|
45
|
+
If you need to specify options for `swiftlint` that can _only_ be specified by command line arguments, use the `additional_swiftlint_args` option.
|
46
|
+
|
47
|
+
```rb
|
48
|
+
swiftlint.lint_files additional_swiftlint_args: '--lenient'
|
49
|
+
```
|
50
|
+
|
45
51
|
You can use the `SWIFTLINT_VERSION` environment variable to override the default version installed via the `rake install` task.
|
46
52
|
|
47
53
|
## Attribution
|
data/ext/swiftlint/swiftlint.rb
CHANGED
@@ -5,19 +5,19 @@ class Swiftlint
|
|
5
5
|
end
|
6
6
|
|
7
7
|
# Runs swiftlint
|
8
|
-
def run(cmd='lint', options={})
|
8
|
+
def run(cmd='lint', additional_swiftlint_args='', options={})
|
9
9
|
# change pwd before run swiftlint
|
10
10
|
if options.has_key? :pwd
|
11
11
|
Dir.chdir options.delete(:pwd)
|
12
12
|
end
|
13
13
|
|
14
14
|
# run swiftlint with provided options
|
15
|
-
`#{swiftlint_path} #{cmd} #{swiftlint_arguments(options)}`
|
15
|
+
`#{swiftlint_path} #{cmd} #{swiftlint_arguments(options, additional_swiftlint_args)}`
|
16
16
|
end
|
17
17
|
|
18
18
|
# Shortcut for running the lint command
|
19
|
-
def lint(options)
|
20
|
-
run('lint', options)
|
19
|
+
def lint(options, additional_swiftlint_args)
|
20
|
+
run('lint', additional_swiftlint_args, options)
|
21
21
|
end
|
22
22
|
|
23
23
|
# Return true if swiftlint is installed or false otherwise
|
@@ -35,8 +35,8 @@ class Swiftlint
|
|
35
35
|
# Parse options into shell arguments how swift expect it to be
|
36
36
|
# more information: https://github.com/Carthage/Commandant
|
37
37
|
# @param options (Hash) hash containing swiftlint options
|
38
|
-
def swiftlint_arguments options
|
39
|
-
options.
|
38
|
+
def swiftlint_arguments (options, additional_swiftlint_args)
|
39
|
+
(options.
|
40
40
|
# filter not null
|
41
41
|
select {|key, value| !value.nil?}.
|
42
42
|
# map booleans arguments equal true
|
@@ -48,7 +48,8 @@ class Swiftlint
|
|
48
48
|
# prepend '--' into the argument
|
49
49
|
map { |key, value| ["--#{key}", value] }.
|
50
50
|
# reduce everything into a single string
|
51
|
-
reduce('') { |args, option| "#{args} #{option[0]} #{option[1]}"
|
51
|
+
reduce('') { |args, option| "#{args} #{option[0]} #{option[1]}"} +
|
52
|
+
" #{additional_swiftlint_args}").
|
52
53
|
# strip leading spaces
|
53
54
|
strip
|
54
55
|
end
|
data/lib/danger_plugin.rb
CHANGED
@@ -36,7 +36,7 @@ module Danger
|
|
36
36
|
# if nil, modified and added files from the diff will be used.
|
37
37
|
# @return [void]
|
38
38
|
#
|
39
|
-
def lint_files(files=nil, inline_mode: false, fail_on_error: false)
|
39
|
+
def lint_files(files=nil, inline_mode: false, fail_on_error: false, additional_swiftlint_args: "")
|
40
40
|
# Fails if swiftlint isn't installed
|
41
41
|
raise "swiftlint is not installed" unless swiftlint.is_installed?
|
42
42
|
|
@@ -65,7 +65,7 @@ module Danger
|
|
65
65
|
}
|
66
66
|
|
67
67
|
# Lint each file and collect the results
|
68
|
-
issues = run_swiftlint(files, options)
|
68
|
+
issues = run_swiftlint(files, options, additional_swiftlint_args)
|
69
69
|
|
70
70
|
# Filter warnings and errors
|
71
71
|
warnings = issues.select { |issue| issue['severity'] == 'Warning' }
|
@@ -94,10 +94,10 @@ module Danger
|
|
94
94
|
# Run swiftlint on each file and aggregate collect the issues
|
95
95
|
#
|
96
96
|
# @return [Array] swiftlint issues
|
97
|
-
def run_swiftlint(files, options)
|
97
|
+
def run_swiftlint(files, options, additional_swiftlint_args)
|
98
98
|
files
|
99
99
|
.map { |file| options.merge({path: file})}
|
100
|
-
.map { |full_options| swiftlint.lint(full_options)}
|
100
|
+
.map { |full_options| swiftlint.lint(full_options, additional_swiftlint_args)}
|
101
101
|
.reject { |s| s == '' }
|
102
102
|
.map { |s| JSON.parse(s).flatten }
|
103
103
|
.flatten
|
data/lib/version.rb
CHANGED
data/spec/danger_plugin_spec.rb
CHANGED
@@ -44,7 +44,7 @@ module Danger
|
|
44
44
|
|
45
45
|
it 'accept files as arguments' do
|
46
46
|
expect_any_instance_of(Swiftlint).to receive(:lint)
|
47
|
-
.with(hash_including(:path => File.expand_path('spec/fixtures/SwiftFile.swift')))
|
47
|
+
.with(hash_including(:path => File.expand_path('spec/fixtures/SwiftFile.swift')), '')
|
48
48
|
.and_return(@swiftlint_response)
|
49
49
|
|
50
50
|
@swiftlint.lint_files("spec/fixtures/*.swift")
|
@@ -54,11 +54,19 @@ module Danger
|
|
54
54
|
expect(output).to include("SwiftFile.swift | 13 | Force casts should be avoided.")
|
55
55
|
end
|
56
56
|
|
57
|
+
it 'accepts additional cli arguments' do
|
58
|
+
expect_any_instance_of(Swiftlint).to receive(:lint)
|
59
|
+
.with(hash_including(:path => File.expand_path('spec/fixtures/SwiftFile.swift')), '--lenient')
|
60
|
+
.and_return(@swiftlint_response)
|
61
|
+
|
62
|
+
@swiftlint.lint_files("spec/fixtures/*.swift", additional_swiftlint_args: '--lenient')
|
63
|
+
end
|
64
|
+
|
57
65
|
it 'uses git diff when files are not provided' do
|
58
66
|
allow(@swiftlint.git).to receive(:modified_files).and_return(['spec/fixtures/SwiftFile.swift'])
|
59
67
|
allow(@swiftlint.git).to receive(:added_files).and_return([])
|
60
68
|
allow_any_instance_of(Swiftlint).to receive(:lint)
|
61
|
-
.with(hash_including(:path => File.expand_path('spec/fixtures/SwiftFile.swift')))
|
69
|
+
.with(hash_including(:path => File.expand_path('spec/fixtures/SwiftFile.swift')), '')
|
62
70
|
.and_return(@swiftlint_response)
|
63
71
|
|
64
72
|
@swiftlint.lint_files
|
@@ -71,7 +79,7 @@ module Danger
|
|
71
79
|
@swiftlint.directory = 'spec/fixtures/some_dir'
|
72
80
|
|
73
81
|
allow_any_instance_of(Swiftlint).to receive(:lint)
|
74
|
-
.with(hash_including(:pwd => File.expand_path(@swiftlint.directory)))
|
82
|
+
.with(hash_including(:pwd => File.expand_path(@swiftlint.directory)), '')
|
75
83
|
.and_return(@swiftlint_response)
|
76
84
|
|
77
85
|
@swiftlint.lint_files(["spec/fixtures/some_dir/SwiftFile.swift"])
|
@@ -91,7 +99,7 @@ module Danger
|
|
91
99
|
])
|
92
100
|
|
93
101
|
expect_any_instance_of(Swiftlint).to receive(:lint)
|
94
|
-
.with(hash_including(:path => File.expand_path('spec/fixtures/some_dir/SwiftFile.swift')))
|
102
|
+
.with(hash_including(:path => File.expand_path('spec/fixtures/some_dir/SwiftFile.swift')), '')
|
95
103
|
.once
|
96
104
|
.and_return(@swiftlint_response)
|
97
105
|
|
@@ -125,7 +133,7 @@ module Danger
|
|
125
133
|
])
|
126
134
|
|
127
135
|
expect_any_instance_of(Swiftlint).to receive(:lint)
|
128
|
-
.with(hash_including(:path => File.expand_path('spec/fixtures/SwiftFile.swift')))
|
136
|
+
.with(hash_including(:path => File.expand_path('spec/fixtures/SwiftFile.swift')), '')
|
129
137
|
.once
|
130
138
|
.and_return(@swiftlint_response)
|
131
139
|
|
@@ -140,7 +148,7 @@ module Danger
|
|
140
148
|
])
|
141
149
|
|
142
150
|
expect_any_instance_of(Swiftlint).to receive(:lint)
|
143
|
-
.with(hash_including(:path => File.expand_path('spec/fixtures/SwiftFile.swift')))
|
151
|
+
.with(hash_including(:path => File.expand_path('spec/fixtures/SwiftFile.swift')), '')
|
144
152
|
.once
|
145
153
|
.and_return(@swiftlint_response)
|
146
154
|
|
@@ -163,7 +171,7 @@ module Danger
|
|
163
171
|
])
|
164
172
|
|
165
173
|
expect_any_instance_of(Swiftlint).to receive(:lint)
|
166
|
-
.with(hash_including(:path => File.expand_path('spec/fixtures/SwiftFile.swift')))
|
174
|
+
.with(hash_including(:path => File.expand_path('spec/fixtures/SwiftFile.swift')), '')
|
167
175
|
.once
|
168
176
|
.and_return(@swiftlint_response)
|
169
177
|
|
@@ -172,10 +180,10 @@ module Danger
|
|
172
180
|
|
173
181
|
it 'generates errors instead of markdown when use inline mode' do
|
174
182
|
allow_any_instance_of(Swiftlint).to receive(:lint)
|
175
|
-
.with(hash_including(:path => File.expand_path('spec/fixtures/SwiftFile.swift')))
|
183
|
+
.with(hash_including(:path => File.expand_path('spec/fixtures/SwiftFile.swift')), '')
|
176
184
|
.and_return(@swiftlint_response)
|
177
185
|
|
178
|
-
@swiftlint.lint_files("spec/fixtures/*.swift", inline_mode: true, fail_on_error: false)
|
186
|
+
@swiftlint.lint_files("spec/fixtures/*.swift", inline_mode: true, fail_on_error: false, additional_swiftlint_args: '')
|
179
187
|
|
180
188
|
status = @swiftlint.status_report
|
181
189
|
expect(status[:errors]).to_not be_empty
|
data/spec/swiftlint_spec.rb
CHANGED
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.10.0
|
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-
|
15
|
+
date: 2017-10-04 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: danger
|