danger-swiftlint 0.10.2 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/danger_plugin.rb +15 -0
- data/lib/version.rb +1 -1
- data/spec/danger_plugin_spec.rb +16 -0
- 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: c3e7ed119f894d13115a6147e512b018678edd8e
|
4
|
+
data.tar.gz: 9ead229790970463d5f2e7c8afcf03067a6decad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 36d6752da9448acccea5208d1eb5453163cc1b5b17308a2c230840ae4bce72c3bd70681c83f71f2f7f2aef156edd570eeb37e50ff37b779b83685fffce5d2cd1
|
7
|
+
data.tar.gz: b4eae3d9a68e20dc5c1551862fd154f626edad9af58af3a2ad5d5e3adfebdf8ca14fdd0a501fc4a05ecb753bcb2fe04bd78da60bd878a20cd5a77c653a2f05dc
|
data/lib/danger_plugin.rb
CHANGED
@@ -29,6 +29,9 @@ module Danger
|
|
29
29
|
# Allows you to specify a directory from where swiftlint will be run.
|
30
30
|
attr_accessor :directory
|
31
31
|
|
32
|
+
# Maximum number of issues to be reported.
|
33
|
+
attr_accessor :max_num_violations
|
34
|
+
|
32
35
|
# Provides additional logging diagnostic information.
|
33
36
|
attr_accessor :verbose
|
34
37
|
|
@@ -74,6 +77,11 @@ module Danger
|
|
74
77
|
|
75
78
|
# Lint each file and collect the results
|
76
79
|
issues = run_swiftlint(files, options, additional_swiftlint_args)
|
80
|
+
other_issues_count = 0
|
81
|
+
unless @max_num_violations.nil?
|
82
|
+
other_issues_count = issues.count - @max_num_violations if issues.count > @max_num_violations
|
83
|
+
issues = issues.take(@max_num_violations)
|
84
|
+
end
|
77
85
|
log "Received from Swiftlint: #{issues}"
|
78
86
|
|
79
87
|
# Filter warnings and errors
|
@@ -84,11 +92,13 @@ module Danger
|
|
84
92
|
# Report with inline comment
|
85
93
|
send_inline_comment(warnings, 'warn')
|
86
94
|
send_inline_comment(errors, 'fail')
|
95
|
+
warn other_issues_message(other_issues_count) if other_issues_count.positive?
|
87
96
|
elsif warnings.count.positive? || errors.count.positive?
|
88
97
|
# Report if any warning or error
|
89
98
|
message = +"### SwiftLint found issues\n\n"
|
90
99
|
message << markdown_issues(warnings, 'Warnings') unless warnings.empty?
|
91
100
|
message << markdown_issues(errors, 'Errors') unless errors.empty?
|
101
|
+
message << "\n#{other_issues_message(other_issues_count)}" if other_issues_count.positive?
|
92
102
|
markdown message
|
93
103
|
|
94
104
|
# Fail Danger on errors
|
@@ -193,6 +203,11 @@ module Danger
|
|
193
203
|
end
|
194
204
|
end
|
195
205
|
|
206
|
+
def other_issues_message(issues_count)
|
207
|
+
violations = issues_count == 1 ? 'violation' : 'violations'
|
208
|
+
"SwiftLint also found #{issues_count} more #{violations} with this PR."
|
209
|
+
end
|
210
|
+
|
196
211
|
# Make SwiftLint object for binary_path
|
197
212
|
#
|
198
213
|
# @return [SwiftLint]
|
data/lib/version.rb
CHANGED
data/spec/danger_plugin_spec.rb
CHANGED
@@ -56,6 +56,22 @@ module Danger
|
|
56
56
|
expect(output).to include('SwiftFile.swift | 13 | Force casts should be avoided.')
|
57
57
|
end
|
58
58
|
|
59
|
+
it 'sets maxium number of violations' do
|
60
|
+
swiftlint_response = '[{ "rule_id" : "force_cast", "reason" : "Force casts should be avoided.", "character" : 19, "file" : "/Users/me/this_repo/spec//fixtures/SwiftFile.swift", "severity" : "Error", "type" : "Force Cast", "line" : 13 }, { "rule_id" : "force_cast", "reason" : "Force casts should be avoided.", "character" : 19, "file" : "/Users/me/this_repo/spec//fixtures/SwiftFile.swift", "severity" : "Error", "type" : "Force Cast", "line" : 14 }]'
|
61
|
+
expect_any_instance_of(Swiftlint).to receive(:lint)
|
62
|
+
.with(hash_including(path: File.expand_path('spec/fixtures/SwiftFile.swift')), '')
|
63
|
+
.and_return(swiftlint_response)
|
64
|
+
|
65
|
+
@swiftlint.max_num_violations = 1
|
66
|
+
@swiftlint.lint_files('spec/fixtures/*.swift')
|
67
|
+
|
68
|
+
output = @swiftlint.status_report[:markdowns].first.to_s
|
69
|
+
expect(output).to include('SwiftLint found issues')
|
70
|
+
expect(output).to include('SwiftFile.swift | 13 | Force casts should be avoided.')
|
71
|
+
expect(output).to include('SwiftLint also found 1 more violation with this PR.')
|
72
|
+
expect(output).to_not include('SwiftFile.swift | 14 | Force casts should be avoided.')
|
73
|
+
end
|
74
|
+
|
59
75
|
it 'accepts additional cli arguments' do
|
60
76
|
expect_any_instance_of(Swiftlint).to receive(:lint)
|
61
77
|
.with(hash_including(path: File.expand_path('spec/fixtures/SwiftFile.swift')), '--lenient')
|
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.11.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-10-
|
15
|
+
date: 2017-10-26 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: danger
|