Class: RuboCop::Cop::SketchupRequirements::MinimalRegistration
- Inherits:
-
SketchUp::Cop
- Object
- SketchUp::WorkaroundCop
- SketchUp::Cop
- RuboCop::Cop::SketchupRequirements::MinimalRegistration
- Defined in:
- lib/rubocop/sketchup/cop/requirements/minimal_registration.rb
Overview
Don’t load extension files in the root file registering the extension. Extensions should not load additional files when it’s disabled.
Constant Summary collapse
- MSG =
"Don't load extension files in the root file registering the "\ 'extension.'
Constants included from SketchUp::Config
SketchUp::Config::DEFAULT_CONFIGURATION
Constants inherited from SketchUp::Cop
SketchUp::Cop::SKETCHUP_DEPARTMENT_SEVERITY
Instance Method Summary collapse
- #extension_file?(filename) ⇒ Boolean
- #investigate(processed_source) ⇒ Object
- #on_send(node) ⇒ Object
Methods included from SketchUp::ExtensionProject
#config_path, #extension_directory, #extension_root_file, #extension_root_files, #path_relative_to_source, #relative_source_path, #root_file?, #source_path
Methods inherited from SketchUp::Cop
Instance Method Details
#extension_file?(filename) ⇒ Boolean
53 54 55 56 57 58 |
# File 'lib/rubocop/sketchup/cop/requirements/minimal_registration.rb', line 53 def extension_file?(filename) return false unless filename.include?('/') first_directory = filename.split('/').first @extension_basename.casecmp(first_directory) == 0 end |
#investigate(processed_source) ⇒ Object
46 47 48 49 50 51 |
# File 'lib/rubocop/sketchup/cop/requirements/minimal_registration.rb', line 46 def investigate(processed_source) if root_file?(processed_source) filename = processed_source.buffer.name @extension_basename = File.basename(filename, '.*') end end |
#on_send(node) ⇒ Object
60 61 62 63 64 65 66 67 68 |
# File 'lib/rubocop/sketchup/cop/requirements/minimal_registration.rb', line 60 def on_send(node) return unless @extension_basename filename = require_filename(node) return if filename.nil? return unless extension_file?(filename) add_offense(node) end |