Class: RuboCop::Cop::SketchupRequirements::InitializeEntity

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

Overview

SketchUp Entity objects (‘Face`, `Edge`, `Group` etc) should not be initialized using the `new` constructor. These objects are managed by SketchUp. Instead use the `Sketchup::Entities#add_*` methods to create them.

Constant Summary collapse

ENTITY_CLASSES =
i[
  ComponentDefinition
  ComponentInstance
  ConstructionLine
  ConstructionPoint
  Dimension
  DimensionLinear
  DimensionRadial
  Edge
  Face
  Group
  Image
  SectionPlane
  Text
  AttributeDictionaries
  AttributeDictionary
  Axes
  Behavior
  Curve
  DefinitionList
  Drawingelement
  EdgeUse
  Layer
  LayerFolder
  Layers
  LineStyle
  LineStyles
  Loop
  Material
  Materials
  Page
  Pages
  RenderingOptions
  ShadowInfo
  Style
  Styles
  Texture
  Vertex
].freeze
MSG_INITIALIZE_ENTITY =
'Entity objects (Face, Edge, Group etc) are ' \
'managed SketchUp. Instead of using the ' \
'`new` constructor, use the ' \
'`Sketchup::Entities#add_*` 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

inherited, #relevant_file?

Instance Method Details

#on_send(node) ⇒ Object



61
62
63
64
65
# File 'lib/rubocop/sketchup/cop/requirements/initialize_entity.rb', line 61

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

  add_offense(node, message: MSG_INITIALIZE_ENTITY)
end