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'
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 inherited from SketchUp::Cop
SketchUp::Cop::SKETCHUP_DEPARTMENT_SEVERITY
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
49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/rubocop/sketchup/cop/suggestions/compatibility.rb', line 49 def on_const(node) if node.parent && module_definition?(node.parent) # 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
25 26 27 28 29 30 |
# File 'lib/rubocop/sketchup/cop/suggestions/compatibility.rb', line 25 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
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/rubocop/sketchup/cop/suggestions/compatibility.rb', line 32 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 |