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."- ALLOWED_FUNCTIONS =
white list of allowed Builtins calls
[ # locale dependent sorting in not available in Ruby stdlib :lsort, # gettext helpers :dgettext, :dngettext, :dpgettext, # crypt* helpers :crypt, :cryptmd5, :cryptblowfish, :cryptsha256, :cryptsha512 ]
- 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 Method Summary collapse
Instance Method Details
#autocorrect(node) ⇒ Object
46 47 48 49 50 51 52 53 54 |
# File 'lib/rubocop/cop/yast/builtins.rb', line 46 def autocorrect(node) @corrections << lambda do |corrector| _builtins, , args = *node new_code = builtins_replacement(, args) corrector.replace(node.loc.expression, new_code) if new_code end end |
#on_send(node) ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/rubocop/cop/yast/builtins.rb', line 37 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 |