lib/plugins/pre-commit/message/formatter.rb in java-checkstyle-1.0.3 vs lib/plugins/pre-commit/message/formatter.rb in java-checkstyle-1.0.4
- old
+ new
@@ -4,12 +4,12 @@
# Responsible for format a given output
class Formatter
##
# Format output for a given +errors+ details
#
- # @param [Hash] JSON errors details
- # @return [String] formatted output (may return nil)
+ # @param checkstyle [Domain::Checkstyle] Checkstyle details
+ # @return [String] formatted output or nil when has no errors
# @raise ArgumentError when input is empty
#
def format(checkstyle)
throw ArgumentError.new if checkstyle.nil?
return nil if checkstyle.good?
@@ -26,12 +26,10 @@
def format_single(bad_file)
"File errors: #{bad_file.name} \n" + format_errors(bad_file.errors)
end
def format_errors(errors)
- errors.reduce('') do |out, error|
- out + line(error)
- end
+ errors.reduce('') { |a, e| a + line(e) }
end
def line(error)
" line: #{error['line']}:#{error['column']}"\
" error: #{error['message']}\n"