Class: RuboCop::Cop::Lint::LtsRuby::UnavailableMethod
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Lint::LtsRuby::UnavailableMethod
- Defined in:
- lib/rubocop/lts/ruby/cop/lint_lts_ruby/unavailable_method.rb
Overview
Reports known Ruby APIs that were introduced after the configured target.
RuboCop's TargetRubyVersion handles syntax and version-aware style rules, but it does not provide a complete runtime API compatibility database. This cop fills that gap for explicit receiver calls in the catalog.
Constant Summary collapse
- MSG =
"%<owner>s#%<method>s is unavailable before Ruby %<version>s."- RESTRICT_ON_SEND =
RuboCop::Lts::Ruby::Catalog::BY_METHOD.keys.freeze
Instance Method Summary collapse
Instance Method Details
#on_send(node) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/rubocop/lts/ruby/cop/lint_lts_ruby/unavailable_method.rb', line 20 def on_send(node) return unless node.receiver entries = RuboCop::Lts::Ruby::Catalog.lookup(node.method_name) return unless entries applicable_entries = entries.select { |entry| entry_applies?(node, entry) } applicable_entries.group_by(&:introduced_in).each_value do |same_version_entries| report_unavailable(node, same_version_entries) end end |