class RuboCop::Cop::SketchupRequirements::GlobalMethods
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 define global methods.
Constants
- MSG
Public Instance Methods
on_def(node)
click to toggle source
# File lib/rubocop/sketchup/cop/requirements/global_methods.rb, line 45 def on_def(node) if class_method?(node) class_method_parent = class_method(node) namespace = Namespace.new(class_method_parent.to_s) else # If a method is defined inside a block then parent_module_name # will return nil. return if node.parent_module_name.nil? namespace = Namespace.new(node.parent_module_name) end return unless namespace.top_level? add_offense(node, location: :name) end
Also aliased as: on_defs