Class: RuboCop::Cop::RBS::Lint::ImplicitlyReturnsNil
- Inherits:
-
RBS::CopBase
- Object
- Base
- RBS::CopBase
- RuboCop::Cop::RBS::Lint::ImplicitlyReturnsNil
- Extended by:
- AutoCorrector
- Defined in:
- lib/rubocop/cop/rbs/lint/implicitly_returns_nil.rb
Overview
This cop checks for conflicts between ‘implicitly-returns-nil` annotations and return types.
Constant Summary collapse
- MSG =
"There is a conflict between `%<annotation>s` and return type `%<return_type>s`."
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
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/rubocop/cop/rbs/lint/implicitly_returns_nil.rb', line 26 def on_rbs_def(decl) decl.overloads.each do |overload| annotation = find_implicitly_returns_nil(decl) || find_implicitly_returns_nil(overload) next unless annotation next unless overload_returns_nil?(overload) return_type = overload.method_type.type.return_type.to_s range = location_to_range(annotation.location) = format(MSG, annotation: annotation.location.source, return_type:) add_offense(range, message:) end end |