lib/rubocop/formatter/html_formatter.rb in rubocop-0.40.0 vs lib/rubocop/formatter/html_formatter.rb in rubocop-0.41.0
- old
+ new
@@ -93,21 +93,17 @@
end
end
def highlighted_source_line(offense)
location = offense.location
+ source_line = location.source_line
- source_line = if location.first_line == location.last_line
- location.source_line
- else
- "#{location.source_line} #{ELLIPSES}"
- end
-
escape(source_line[0...offense.highlighted_area.begin_pos]) +
"<span class=\"highlight #{offense.severity}\">" +
escape(offense.highlighted_area.source) +
'</span>' +
- escape(source_line[offense.highlighted_area.end_pos..-1])
+ escape(source_line[offense.highlighted_area.end_pos..-1]) +
+ (location.first_line == location.last_line ? '' : " #{ELLIPSES}")
end
def escape(s)
# Single quotes not escaped in Ruby 1.9, so add extra substitution.
CGI.escapeHTML(s).gsub(/'/, ''')