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_method define_singleton_method eval extend instance_eval method_missing module_eval module_function public_send remove_method singleton_method undef_method ].freeze
- RESTRICT_ON_SEND =
(BANNED_METHODS + %i[prepend send]).freeze
- TOP_LEVEL_CONSTS =
%i[Mutex Thread].freeze
Instance Method Summary collapse
- #on_const(node) ⇒ Object
-
#on_sclass(node) ⇒ Object
‘class << self` compiles 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 |
# File 'lib/rubocop/cop/spinel/unsupported.rb', line 42 def on_sclass(node) add_offense(node, message: "Spinel does not support singleton classes.") end |
#on_send(node) ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/rubocop/cop/spinel/unsupported.rb', line 26 def on_send(node) # `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 |