Class: RuboCop::Cop::SketchupSuggestions::SketchupRequire

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

Overview

Omit file extensions when using Sketchup.require to allow encrypted files to be loaded.

Constant Summary collapse

MSG =
"Don't hard code file extensions with Sketchup.require".freeze
TOOLS_RUBY_FILES =
%w[extensions.rb langhandler.rb sketchup.rb]

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


47
48
49
50
51
52
53
54
55
56
# File 'lib/rubocop/sketchup/cop/suggestions/sketchup_require.rb', line 47

def on_send(node)
  if sketchup_require?(node)
    filename = sketchup_require(node)
  elsif sketchup_extension_new?(node)
    filename = sketchup_extension_new(node)
  else
    return
  end
  add_offense(node, location: :expression) unless valid_filename?(filename)
end