class RuboCop::Cop::SketchupRequirements::GlobalInclude

Extensions in SketchUp all share the same Ruby environment on the user's machine. Because of this it's important that each extension isolate itself to avoid clashing with other extensions.

Extensions submitted to Extension Warehouse is expected to not pollute the global namespace by including mix-in modules.

Constants

MSG

Public Instance Methods

on_send(node) click to toggle source
# File lib/rubocop/sketchup/cop/requirements/global_include.rb, line 23
def on_send(node)
  return unless global_include?(node)

  add_offense(node, location: :selector)
end

Private Instance Methods

global_include?(node) click to toggle source
# File lib/rubocop/sketchup/cop/requirements/global_include.rb, line 31
def global_include?(node)
  is_include?(node) && global_namespace?(node)
end
global_namespace?(node) click to toggle source
# File lib/rubocop/sketchup/cop/requirements/global_include.rb, line 35
def global_namespace?(node)
  %w[Kernel Object].include?(node.parent_module_name)
end