Class: RuboCop::Cop::RBS::Lint::DuplicateOverload
- Inherits:
-
RBS::CopBase
- Object
- Base
- RBS::CopBase
- RuboCop::Cop::RBS::Lint::DuplicateOverload
- Defined in:
- lib/rubocop/cop/rbs/lint/duplicate_overload.rb
Overview
Checks that there are no repeated overload bodies. This cop ignores the difference of return type.
Constant Summary collapse
- MSG =
'Duplicate overload arguments detected.'
Instance Attribute Summary
Attributes inherited from RBS::CopBase
Instance Method Summary collapse
Methods inherited from RBS::CopBase
documentation_url, #investigation_rbs, #location_to_range, #on_new_investigation, #on_other_file, #on_rbs_attribute, #on_rbs_class, #on_rbs_constant, #on_rbs_global, #on_rbs_interface, #on_rbs_module, #on_rbs_new_investigation, #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_def(decl) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/rubocop/cop/rbs/lint/duplicate_overload.rb', line 18 def on_rbs_def(decl) overloads = decl.overloads overloads.each_with_index do |overload, idx| next if idx == overloads.size - 1 next_overloads = overloads[(idx + 1)..-1] next_overloads.each do |next_overload| a = method_type_with_untyped_return_type(overload.method_type) b = method_type_with_untyped_return_type(next_overload.method_type) next unless a == b range = location_to_range(next_overload.method_type.location) add_offense(range) end end end |