From d98ee23b029c43776de889f78ebed3cb1cced8da Mon Sep 17 00:00:00 2001 From: Robert Waffen Date: Mon, 1 Jul 2024 17:17:03 +0200 Subject: [PATCH 1/2] feat(check:trailing_whitespace): collect all problems, report and then exit Signed-off-by: Robert Waffen --- lib/voxpupuli/test/rake.rb | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/voxpupuli/test/rake.rb b/lib/voxpupuli/test/rake.rb index fd2c101..7397b4b 100644 --- a/lib/voxpupuli/test/rake.rb +++ b/lib/voxpupuli/test/rake.rb @@ -12,15 +12,22 @@ namespace :check do desc 'Check for trailing whitespace' task :trailing_whitespace do + errors = [] + Dir.glob('**/*.md', File::FNM_DOTMATCH).sort.each do |filename| next if filename =~ %r{^((modules|acceptance|\.?vendor|spec/fixtures|pkg)/|REFERENCE.md)} File.foreach(filename).each_with_index do |line, index| if line =~ %r{\s\n$} - puts "#{filename} has trailing whitespace on line #{index + 1}" - exit 1 + errors << "#{filename} has trailing whitespace on line #{index + 1}" end end end + + unless errors.empty? + errors.each { |error| puts error } + exit 1 + end end end + Rake::Task[:check].enhance ['check:trailing_whitespace'] From dfc76bba4a63bb579223ae48b5c63aeec3d6d03a Mon Sep 17 00:00:00 2001 From: Robert Waffen Date: Mon, 1 Jul 2024 19:33:59 +0200 Subject: [PATCH 2/2] Update lib/voxpupuli/test/rake.rb Co-authored-by: Ewoud Kohl van Wijngaarden --- lib/voxpupuli/test/rake.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/voxpupuli/test/rake.rb b/lib/voxpupuli/test/rake.rb index 7397b4b..92ec99e 100644 --- a/lib/voxpupuli/test/rake.rb +++ b/lib/voxpupuli/test/rake.rb @@ -23,7 +23,7 @@ end end - unless errors.empty? + if errors.any? errors.each { |error| puts error } exit 1 end