Class: RuboCop::Cop::SketchupSuggestions::SketchupFindSupportFile

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

Overview

Avoid ‘Sketchup.find_support_file` to find your extension’s files.

Users might install your extension to locations other than the default Plugins directory. If you use ‘Sketchup.find_support_file` to build a path for files in your extension it will fail in these scenarios.

Instead prefer to use ‘__FILE__` or `__dir__` to build paths relative to your source files. This have the added benefit of allowing you to load your extensions directly from external directories under version control.

Constant Summary collapse

MSG =
'Avoid `Sketchup.find_support_file` to find your '\
"extension's files."

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

inherited, #relevant_file?

Instance Method Details

#on_send(node) ⇒ Object



30
31
32
33
34
# File 'lib/rubocop/sketchup/cop/suggestions/sketchup_find_support_file.rb', line 30

def on_send(node)
  return unless sketchup_find_support_file?(node)

  add_offense(node, location: :expression)
end