Class: RuboCop::Cop::SketchupSuggestions::Compatibility
- Inherits:
-
SketchUp::Cop
- Object
- SketchUp::WorkaroundCop
- SketchUp::Cop
- RuboCop::Cop::SketchupSuggestions::Compatibility
- Includes:
- 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::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
44 45 46 47 48 49 |
# File 'lib/rubocop/sketchup/cop/suggestions/compatibility.rb', line 44 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
20 21 22 23 24 25 |
# File 'lib/rubocop/sketchup/cop/suggestions/compatibility.rb', line 20 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
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/rubocop/sketchup/cop/suggestions/compatibility.rb', line 27 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 |