Skip to content

Commit

Permalink
feat(check:trailing_whitespace): collect all problems, report and the…
Browse files Browse the repository at this point in the history
…n exit


Signed-off-by: Robert Waffen <[email protected]>
  • Loading branch information
rwaffen authored Jul 2, 2024
1 parent 0369193 commit 0dcbc9d
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/voxpupuli/test/rake.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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']

0 comments on commit 0dcbc9d

Please sign in to comment.