Class: RuboCop::Cop::Spinel::Unsupported
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Spinel::Unsupported
- Defined in:
- lib/rubocop/cop/spinel/unsupported.rb
Constant Summary collapse
- BANNED_METHODS =
%i[ class_eval const_get define_singleton_method eval extend method_missing module_eval public_send remove_method singleton_method undef_method ].freeze
- RESTRICT_ON_SEND =
(BANNED_METHODS + %i[define_method instance_eval module_function prepend send]).freeze
- TOP_LEVEL_CONSTS =
%i[Mutex Thread].freeze
Instance Method Summary collapse
- #on_const(node) ⇒ Object
-
#on_sclass(node) ⇒ Object
class << selfcompiles in Spinel but does not work correctly. - #on_send(node) ⇒ Object
Instance Method Details
#on_const(node) ⇒ Object
34 35 36 37 38 39 |
# File 'lib/rubocop/cop/spinel/unsupported.rb', line 34 def on_const(node) return unless top_level_const?(node) return unless TOP_LEVEL_CONSTS.include?(node.const_name.to_sym) add_offense(node, message: (node.const_name)) end |
#on_sclass(node) ⇒ Object
class << self compiles in Spinel but does not work correctly.
42 43 44 45 46 |
# File 'lib/rubocop/cop/spinel/unsupported.rb', line 42 def on_sclass(node) return if supported_singleton_accessor?(node) add_offense(node, message: "Spinel does not support singleton classes.") end |
#on_send(node) ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/rubocop/cop/spinel/unsupported.rb', line 23 def on_send(node) return handle_define_method(node) if node.method_name == :define_method return handle_instance_eval(node) if node.method_name == :instance_eval return handle_module_function(node) if node.method_name == :module_function # `prepend` is only unsupported as a module/class feature. return handle_prepend(node) if node.method_name == :prepend return if allowed_send?(node) add_offense(node.loc.selector, message: (node.method_name)) end |