Class: RuboCop::Cop::SketchupRequirements::GemInstall

Inherits:
SketchUp::Cop show all
Includes:
RangeHelp, SketchUp::NoCommentDisable
Defined in:
lib/rubocop/sketchup/cop/requirements/gem_install.rb

Overview

It’s tempting to use gems in an extension. However, there are issues if consuming them via Gem.install;

  • Net::HTTP is unreliable. (SSL certificate issues, OpenSSL performance freeze under Windows)

  • Compiled extensions cannot be installed like this as they require DevKit.

  • While downloading and installing SketchUp freezes. (Bad thing if done automatically upon loading the extensions - especially without user notice. It’s easy to think SU have stopped working)

  • Version collisions. If multiple extensions want to use different versions of a gem they will clash if the versions aren’t compatible with the features they use.

They only way to ensure extensions doesn’t clash is to namespace everything into extension namespace. This means making a copy of the gem you want to use and wrap it in your own namespace.

Constant Summary collapse

MSG =
'`Gem.install` is unreliable in SketchUp, and can cause '\
'extensions to clash.'

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



36
37
38
39
40
41
# File 'lib/rubocop/sketchup/cop/requirements/gem_install.rb', line 36

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

  range = range_with_receiver(node)
  add_offense(node, location: range)
end