From 0dcbc9dab758287b13b60a1eac455d1c9c7bafae Mon Sep 17 00:00:00 2001 From: Robert Waffen Date: Tue, 2 Jul 2024 11:37:01 +0200 Subject: [PATCH] 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..92ec99e 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 + + if errors.any? + errors.each { |error| puts error } + exit 1 + end end end + Rake::Task[:check].enhance ['check:trailing_whitespace']