Class: RuboCop::Cop::SketchupSuggestions::Compatibility
- Inherits:
-
SketchUp::Cop
- Object
- SketchUp::WorkaroundCop
- SketchUp::Cop
- RuboCop::Cop::SketchupSuggestions::Compatibility
- Includes:
- SketchUp, SketchUp::Features
- Defined in:
- lib/rubocop/sketchup/cop/suggestions/compatibility.rb
Overview
It’s easy to lose track of what API feature was added in what version or SketchUp. You can configure your target SketchUp version and be notified if you use features introduced in newer versions.
Constant Summary collapse
- MSG =
'Incompatible feature with target SketchUp version'.freeze
Constants included from SketchUp
SketchUp::CONFIG, SketchUp::VERSION
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
Instance Method Details
#on_const(node) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/rubocop/sketchup/cop/suggestions/compatibility.rb', line 45 def on_const(node) if node.parent && node.parent.module_definition? # This catches definition of classes and modules. namespace = Namespace.new(node.parent_module_name) return unless namespace.top_level? end feature_name = node.const_name [:class, :module, :constant].each { |type| check_feature(node, type, feature_name) } end |
#on_def(node) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/rubocop/sketchup/cop/suggestions/compatibility.rb', line 21 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
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/rubocop/sketchup/cop/suggestions/compatibility.rb', line 28 def on_send(node) feature_name = '' if module_method?(node) feature_name = "#{node.receiver.const_name}.#{node.method_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}" end check_feature(node, :method, feature_name) end |