Class: RuboCop::Cop::Yast::Builtins

Inherits:
RuboCop::Cop show all
Includes:
AST::Sexp
Defined in:
lib/rubocop/cop/yast/builtins.rb

Overview

This cop checks for using obsoleted Yast Builtins calls

Constant Summary collapse

MSG =
"Builtin call `%s` is obsolete, use native Ruby function instead."
ALLOWED_FUNCTIONS =

white list of allowed Builtins calls

[
  # locale dependent sorting in not available in Ruby stdlib
  :lsort
]
BUILTINS_NODES =
[
  s(:const, nil, :Builtins),
  s(:const, s(:cbase), :Builtins)
]

Instance Method Summary collapse

Instance Method Details

#on_send(node) ⇒ Object



23
24
25
26
27
28
29
30
# File 'lib/rubocop/cop/yast/builtins.rb', line 23

def on_send(node)
  receiver, method_name, *_args = *node

  return if !BUILTINS_NODES.include?(receiver) ||
      ALLOWED_FUNCTIONS.include?(method_name)

  add_offense(node, :selector, format(MSG, method_name))
end