Skip to content

Commit a6c4787

Browse files
committed
license/sortpom: show aggregated message
1 parent e0b6a82 commit a6c4787

File tree

1 file changed

+33
-24
lines changed

1 file changed

+33
-24
lines changed

Dangerfile

Lines changed: 33 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -97,29 +97,34 @@ license_output = 'license.log'
9797
unless File.file?(license_output)
9898
warn("Couldn't find #{license_output}. Result of checking licenses is unknown")
9999
else
100-
errors_count = 0
100+
errors = []
101101
File.readlines(license_output)
102102
.select { |line| line.start_with? '[WARNING]' }
103103
.each do |line|
104104
errors_count += 1
105105
line.sub!('[WARNING] ', '')
106106
line.sub!(pwd, '')
107107
if line =~ /Missing header in: .*/
108-
parsed = line.match(/(?<msg>[^:]+) in: (?<file>.*)/)
108+
parsed = line.match(/(?<msg>Missing header in: )(?<file>.*)/)
109109
msg = parsed['msg']
110110
file = parsed['file']
111111
file = github.html_link("#{file}#L1")
112-
fail("license error in #{file}: #{msg}")
113-
else
114-
fail("license error: #{line}")
112+
line = "#{msg}#{file}"
115113
end
114+
errors << line
116115
end
117116

118-
link = 'https://github.com/php-coder/mystamps/wiki/check-license-header'
119-
if errors_count == 1
120-
message("license plugin reports about #{errors_count} error. Please, fix it by executing `mvn license:format`. See also: <a href=\"#{link}\">#{link}</a>")
121-
elsif errors_count > 0
122-
message("license plugin reports about #{errors_count} errors. Please, fix them by executing `mvn license:format`. See also: <a href=\"#{link}\">#{link}</a>")
117+
unless errors.empty?
118+
link = 'https://github.com/php-coder/mystamps/wiki/check-license-header'
119+
if errors_cnt == 1
120+
message("license plugin reports about #{errors_cnt} error. "\
121+
"Please, fix it by executing `mvn license:format`. "\
122+
"See also: <a href=\"#{link}\">#{link}</a>")
123+
elsif errors_cnt > 1
124+
message("license plugin reports about #{errors_cnt} errors. "\
125+
"Please, fix them by executing `mvn license:format`. "\
126+
"See also: <a href=\"#{link}\">#{link}</a>")
127+
end
123128
end
124129
end
125130

@@ -128,7 +133,7 @@ sortpom_output = 'pom.log'
128133
unless File.file?(sortpom_output)
129134
warn("Couldn't find #{sortpom_output}. Result of checking pom.xml is unknown")
130135
else
131-
errors_count = 0
136+
errors = []
132137
File.readlines(sortpom_output).each do |line|
133138
# don't process lines after this message
134139
if line.start_with? '[INFO] BUILD FAILURE'
@@ -140,21 +145,25 @@ else
140145
next
141146
end
142147

143-
# ignore summary message
144-
if line =~ /The file .* is not sorted/
145-
next
146-
end
147-
148-
errors_count += 1
149-
line.sub!('[ERROR] ', '')
150-
fail("pom.xml error: #{line}")
148+
line.!sub('[ERROR] ', '')
149+
errors << line
151150
end
152151

153-
link = 'https://github.com/php-coder/mystamps/wiki/sortpom',
154-
if errors_count == 1
155-
message("sortpom plugin reports about #{errors_count} error. Please, fix it by executing `mvn sortpom:sort`. See also: <a href=\"#{link}\">#{link}</a>")
156-
elsif errors_count > 0
157-
message("sortpom plugin reports about #{errors_count} errors. Please, fix them by executing `mvn sortpom:sort`. See also: <a href=\"#{link}\">#{link}</a>")
152+
unless errors.empty?
153+
link = 'https://github.com/php-coder/mystamps/wiki/sortpom',
154+
errors_cnt = errors.size()
155+
error_msgs = errors.join("\n")
156+
if errors_cnt == 1
157+
message("sortpom plugin reports about #{errors_cnt} error:\n"\
158+
"#{error_msgs}\n"\
159+
"Please, fix it by executing `mvn sortpom:sort`. "\
160+
"See also: <a href=\"#{link}\">#{link}</a>")
161+
elsif errors_cnt > 1
162+
message("sortpom plugin reports about #{errors_cnt} errors:\n"\
163+
"#{error_msgs}\n"\
164+
"Please, fix them by executing `mvn sortpom:sort`. "\
165+
"See also: <a href=\"#{link}\">#{link}</a>")
166+
end
158167
end
159168
end
160169

0 commit comments

Comments
 (0)