Class: RuboCop::Cop::Yast::Builtins
- Inherits:
-
RuboCop::Cop
- Object
- RuboCop::Cop
- RuboCop::Cop::Yast::Builtins
- 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."
- BUILTINS_NODES =
[ # Builtins.* s(:const, nil, :Builtins), # Yast::Builtins.* s(:const, s(:const, nil, :Yast), :Builtins), # ::Yast::Builtins.* s(:const, s(:const, s(:cbase), :Yast), :Builtins) ]
Instance Attribute Summary collapse
-
#default_handler ⇒ Object
readonly
Returns the value of attribute default_handler.
-
#handlers ⇒ Object
readonly
Returns the value of attribute handlers.
Instance Method Summary collapse
- #autocorrect(node) ⇒ Object
-
#initialize(config = nil, options = nil) ⇒ Builtins
constructor
A new instance of Builtins.
- #on_send(node) ⇒ Object
Constructor Details
Instance Attribute Details
#default_handler ⇒ Object (readonly)
Returns the value of attribute default_handler.
15 16 17 |
# File 'lib/rubocop/cop/yast/builtins.rb', line 15 def default_handler @default_handler end |
#handlers ⇒ Object (readonly)
Returns the value of attribute handlers.
15 16 17 |
# File 'lib/rubocop/cop/yast/builtins.rb', line 15 def handlers @handlers end |
Instance Method Details
#autocorrect(node) ⇒ Object
45 46 47 48 49 |
# File 'lib/rubocop/cop/yast/builtins.rb', line 45 def autocorrect(node) _builtins, method_name, *_args = *node @corrections << builtin_handler(method_name).correction(node) end |
#on_send(node) ⇒ Object
35 36 37 38 39 40 41 42 43 |
# File 'lib/rubocop/cop/yast/builtins.rb', line 35 def on_send(node) receiver, method_name, *_args = *node # not an Yast builtin call or not an offense return if !BUILTINS_NODES.include?(receiver) || !builtin_handler(method_name).offense?(node) add_offense(node, :selector, format(MSG, method_name)) end |