Class: RuboCop::Cop::SketchupSuggestions::Compatibility

Inherits:
SketchUp::Cop
  • Object
show all
Includes:
SketchUp::Features
Defined in:
lib/rubocop/sketchup/cop/suggestions/compatibility.rb

Constant Summary collapse

MSG =
"Incompatible feature with target SketchUp version".freeze

Constants included from SketchUp::Features

SketchUp::Features::FEATURES, SketchUp::Features::INSTANCE_METHODS, SketchUp::Features::OBSERVER_METHODS

Constants included from SketchUp::Config

SketchUp::Config::DEFAULT_CONFIGURATION

Instance Method Summary collapse

Methods inherited from SketchUp::Cop

inherited, #relevant_file?

Instance Method Details

#on_const(node) ⇒ Object



34
35
36
37
38
39
# File 'lib/rubocop/sketchup/cop/suggestions/compatibility.rb', line 34

def on_const(node)
  feature_name = node.const_name
  [:class, :module, :constant].each { |type|
    check_feature(node, type, feature_name)
  }
end

#on_def(node) ⇒ Object



12
13
14
15
16
# File 'lib/rubocop/sketchup/cop/suggestions/compatibility.rb', line 12

def on_def(node)
  return unless observer_method?(node)
  feature_name = "##{node.method_name}"
  check_feature(node, :method, feature_name)
end

#on_send(node) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/rubocop/sketchup/cop/suggestions/compatibility.rb', line 18

def on_send(node)
  if module_method?(node)
    feature_name = "#{node.receiver.const_name}.#{node.method_name}"
    check_feature(node, :method, feature_name)
  else
    # Instance methods are harder. It's difficult to infer the type of
    # the receiver. If we only check the method name in isolation we
    # will get too many false positives with method names matching
    # methods in Ruby itself and other older features.
    # We try to match names that are unlikely to cause much noise.
    return unless checkable_instance_method?(node)
    feature_name = "##{node.method_name}"
    check_feature(node, :method, feature_name)
  end
end