@@ -9,12 +9,21 @@ require 'nokogiri'
9
9
10
10
pwd = Dir . pwd + '/'
11
11
12
- def print_errors_summary ( program , errors , link )
12
+ def print_errors_summary ( program , errors , link = '' )
13
+ return if errors == 0
14
+
15
+ msg = ''
13
16
if errors == 1
14
- message ( "#{ program } reports about #{ errors } error. Please, fix it. See also: <a href= \" #{ link } \" > #{ link } </a>" )
17
+ msg = "#{ program } reported about #{ errors } error. Please, fix it."
15
18
elsif errors > 0
16
- message ( "#{ program } reports about #{ errors } errors. Please, fix them. See also: <a href=\" #{ link } \" >#{ link } </a>" )
19
+ msg = "#{ program } reported about #{ errors } errors. Please, fix them."
20
+ end
21
+
22
+ unless link . empty?
23
+ msg << " See also: <a href=\" #{ link } \" >#{ link } </a>"
17
24
end
25
+
26
+ message ( msg )
18
27
end
19
28
20
29
# Handle `mvn checkstyle:check` results
@@ -205,6 +214,40 @@ else
205
214
end
206
215
end
207
216
217
+ # Handle `bootlint` output
218
+ #
219
+ # Example:
220
+ # src/main/webapp/WEB-INF/views/series/info.html:123:12 E013 Only columns (`.col-*-*`) may be children of `.row`s
221
+ # src/main/webapp/WEB-INF/views/site/events.html:197:7 E013 Only columns (`.col-*-*`) may be children of `.row`s
222
+ #
223
+ # For details, look up the lint problem IDs in the Bootlint wiki:
224
+ # https://github.com/twbs/bootlint/wiki
225
+ # 3 lint error(s) found across 20 file(s).
226
+ #
227
+ bootlint_output = 'bootlint.log'
228
+ unless File . file? ( bootlint_output )
229
+ warn ( "Couldn't find #{ bootlint_output } . Result of bootlint is unknown" )
230
+ else
231
+ errors_count = 0
232
+ File . readlines ( bootlint_output ) . each do |line |
233
+ if line !~ /:\d +:\d +/
234
+ next
235
+ end
236
+
237
+ errors_count += 1
238
+
239
+ parsed = line . match ( /^(?<file>[^:]+):(?<line>\d +):\d + (?<code>[^ ]+) (?<msg>.*)/ )
240
+ msg = parsed [ 'msg' ]
241
+ lineno = parsed [ 'line' ]
242
+ file = parsed [ 'file' ]
243
+ code = parsed [ 'code' ]
244
+ file = github . html_link ( "#{ file } #L#{ lineno } " )
245
+ fail ( "bootlint error in #{ file } :\n #{ code } : #{ msg } . ([Details](https://github.com/twbs/bootlint/wiki/#{ code } ))" )
246
+ end
247
+ # TODO: add link to wiki page (#316)
248
+ print_errors_summary 'bootlint' , errors_count
249
+ end
250
+
208
251
# Handle `rflint` output
209
252
#
210
253
# Example:
0 commit comments