Skip to content

Commit ef5df30

Browse files
authored
Merge pull request #31 from YogaGlo/master
(feature): Add ignores_warnings property
2 parents be180a3 + cc30a4d commit ef5df30

File tree

5 files changed

+76
-2
lines changed

5 files changed

+76
-2
lines changed

.rubocop.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Lint/UselessAssignment:
1212
- '**/spec/**/*'
1313

1414
# HoundCI doesn't like this rule
15-
Style/DotPosition:
15+
Layout/DotPosition:
1616
Enabled: false
1717

1818
# Cop supports --auto-correct.

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,12 @@ xcode_summary.ignored_results { |result|
110110
xcode_summary.report 'xcodebuild.json'
111111
```
112112

113+
You can use `ignores_warnings` to supress warnings and shows only errors.
114+
115+
```ruby
116+
xcode_summary.ignores_warnings = true
117+
```
118+
113119
You can use `inline_mode`.
114120
When this value is enabled, each warnings and errors are commented on each lines.
115121

lib/xcode_summary/plugin.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@ class DangerXcodeSummary < Plugin
6060
# @return [Boolean]
6161
attr_accessor :inline_mode
6262

63+
# Defines if warnings should be included or not
64+
# Defaults to `false`.
65+
# @param [Boolean] value
66+
# @return [Boolean]
67+
attr_accessor :ignores_warnings
68+
6369
# rubocop:disable Lint/DuplicateMethods
6470
def project_root
6571
root = @project_root || Dir.pwd
@@ -86,6 +92,10 @@ def test_summary
8692
def inline_mode
8793
@inline_mode || false
8894
end
95+
96+
def ignores_warnings
97+
@ignores_warnings || false
98+
end
8999
# rubocop:enable Lint/DuplicateMethods
90100

91101
# Reads a file with JSON Xcode summary and reports it.
@@ -148,6 +158,10 @@ def messages(xcode_summary)
148158
end
149159

150160
def warnings(xcode_summary)
161+
if ignores_warnings
162+
return []
163+
end
164+
151165
warnings = [
152166
xcode_summary.fetch(:warnings, []).map { |message| Result.new(message, nil) },
153167
xcode_summary.fetch(:ld_warnings, []).map { |message| Result.new(message, nil) },

spec/fixtures/warnings_errors.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"warnings": [
3+
"some warning",
4+
"another warning"
5+
],
6+
"ld_warnings": [
7+
8+
],
9+
"compile_warnings": [
10+
11+
],
12+
"errors": [
13+
"some error",
14+
"another error"
15+
],
16+
"compile_errors": [
17+
18+
],
19+
"file_missing_errors": [
20+
21+
],
22+
"undefined_symbols_errors": [
23+
24+
],
25+
"duplicate_symbols_errors": [
26+
27+
],
28+
"tests_failures": {
29+
},
30+
"tests_summary_messages": [
31+
]
32+
}

spec/xcode_summary_spec.rb

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ module Danger
156156
expect(@dangerfile.status_report[:warnings]).to eq ['another warning']
157157
end
158158

159-
it 'report waring and error counts with no errors' do
159+
it 'report warning and error counts with no errors' do
160160
result = @xcode_summary.warning_error_count('spec/fixtures/errors.json')
161161
expect(result).to eq '{"warnings":0,"errors":1}'
162162
end
@@ -166,6 +166,28 @@ module Danger
166166
expect(result).to eq '{"warnings":1,"errors":0}'
167167
end
168168
end
169+
170+
context 'with ignores_warnings' do
171+
before do
172+
@xcode_summary.ignores_warnings = true
173+
end
174+
175+
it 'asserts no ld warnings' do
176+
@xcode_summary.report('spec/fixtures/ld_warnings.json')
177+
expect(@dangerfile.status_report[:warnings]).to eq []
178+
end
179+
180+
it 'asserts no errors' do
181+
@xcode_summary.report('spec/fixtures/warnings_errors.json')
182+
expect(@dangerfile.status_report[:warnings]).to eq []
183+
expect(@dangerfile.status_report[:errors]).to eq ['some error', 'another error']
184+
end
185+
186+
it 'report warning and error counts with no warning' do
187+
result = @xcode_summary.warning_error_count('spec/fixtures/warnings_errors.json')
188+
expect(result).to eq '{"warnings":0,"errors":2}'
189+
end
190+
end
169191
end
170192
end
171193

0 commit comments

Comments
 (0)