Class: RuboCop::Cop::RBS::Layout::TrailingWhitespace
- Inherits:
-
RBS::CopBase
- Object
- Base
- RBS::CopBase
- RuboCop::Cop::RBS::Layout::TrailingWhitespace
- Extended by:
- AutoCorrector
- Defined in:
- lib/rubocop/cop/rbs/layout/trailing_whitespace.rb
Overview
Constant Summary collapse
- MSG =
"Trailing whitespace detected."
Instance Attribute Summary
Attributes inherited from RBS::CopBase
Instance Method Summary collapse
Methods inherited from RBS::CopBase
#investigation_rbs, #location_to_range, #on_new_investigation, #on_other_file, #on_rbs_attribute, #on_rbs_class, #on_rbs_constant, #on_rbs_def, #on_rbs_global, #on_rbs_interface, #on_rbs_module, #on_rbs_parsing_error, #on_rbs_private, #on_rbs_public, #on_rbs_type_alias, #on_rbs_var, #parse_rbs, #rbs_buffer, #tokenize, #walk
Methods included from RBS::OnTypeHelper
Instance Method Details
#on_rbs_new_investigation ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/rubocop/cop/rbs/layout/trailing_whitespace.rb', line 22 def on_rbs_new_investigation total = 0 processed_source.raw_source.each_line do |line| total += line.length chomped = line.chomp next unless chomped.end_with?(' ', "\t") range = range_between( total - line.length + chomped.rstrip.length, total - line.length + chomped.length, ) add_offense(range) do |corrector| corrector.remove(range) end end end |