@@ -23,12 +23,21 @@ require 'nokogiri'
23
23
24
24
pwd = Dir . pwd + '/'
25
25
26
- def print_errors_summary ( program , errors , link )
26
+ def print_errors_summary ( program , errors , link = '' )
27
+ return if errors == 0
28
+
29
+ msg = ''
27
30
if errors == 1
28
- message ( "#{ program } reports about #{ errors } error. Please, fix it. See also: <a href= \" #{ link } \" > #{ link } </a>" )
31
+ msg = "#{ program } reports about #{ errors } error. Please, fix it."
29
32
elsif errors > 0
30
- message ( "#{ program } reports about #{ errors } errors. Please, fix them. See also: <a href=\" #{ link } \" >#{ link } </a>" )
33
+ msg = "#{ program } reports about #{ errors } errors. Please, fix them."
34
+ end
35
+
36
+ unless link . empty?
37
+ msg << " See also: <a href=\" #{ link } \" >#{ link } </a>"
31
38
end
39
+
40
+ message ( msg )
32
41
end
33
42
34
43
# Handle `mvn checkstyle:check` results
@@ -170,6 +179,40 @@ else
170
179
end
171
180
end
172
181
182
+ # Handle `bootlint` output
183
+ #
184
+ # Example:
185
+ # src/main/webapp/WEB-INF/views/series/info.html:123:12 E013 Only columns (`.col-*-*`) may be children of `.row`s
186
+ # src/main/webapp/WEB-INF/views/site/events.html:197:7 E013 Only columns (`.col-*-*`) may be children of `.row`s
187
+ #
188
+ # For details, look up the lint problem IDs in the Bootlint wiki:
189
+ # https://github.com/twbs/bootlint/wiki
190
+ # 3 lint error(s) found across 20 file(s).
191
+ #
192
+ bootlint_output = 'bootlint.log'
193
+ unless File . file? ( bootlint_output )
194
+ warn ( "Couldn't find #{ bootlint_output } . Result of bootlint is unknown" )
195
+ else
196
+ errors_count = 0
197
+ File . readlines ( bootlint_output ) . each do |line |
198
+ if line !~ /:\d +:\d +/
199
+ next
200
+ end
201
+
202
+ errors_count += 1
203
+
204
+ parsed = line . match ( /^(?<file>[^:]+):(?<line>\d +):\d + (?<code>[^ ]+) (?<msg>.*)/ )
205
+ msg = parsed [ 'msg' ]
206
+ lineno = parsed [ 'line' ]
207
+ file = parsed [ 'file' ]
208
+ code = parsed [ 'code' ]
209
+ file = github . html_link ( "#{ file } #L#{ lineno } " )
210
+ fail ( "bootlint error in #{ file } :\n #{ code } : #{ msg } . ([Details](https://github.com/twbs/bootlint/wiki/#{ code } ))" )
211
+ end
212
+ # TODO: add link to wiki page (#316)
213
+ print_errors_summary 'bootlint' , errors_count
214
+ end
215
+
173
216
# Handle `rflint` output
174
217
rflint_output = 'rflint.log'
175
218
unless File . file? ( rflint_output )
0 commit comments