Class: RuboCop::Cop::SketchupRequirements::ObserversStartOperation

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

Constant Summary collapse

MSG =
'Observers should create transparent operations.'.freeze
OBSERVER_METHODS =
i[
  onActivateModel
  onNewModel
  onOpenModel
  onQuit
  onUnloadExtension

  onComponentInstanceAdded
  onComponentInstanceRemoved

  onComponentAdded
  onComponentPropertiesChanged
  onComponentRemoved
  onComponentTypeChanged

  onTextChanged

  onActiveSectionPlaneChanged
  onElementAdded
  onElementModified
  onElementRemoved
  onEraseEntities

  onChangeEntity
  onEraseEntity

  onClose
  onOpen

  onCurrentLayerChanged
  onLayerAdded
  onLayerChanged
  onLayerRemoved
  onRemoveAllLayers

  onMaterialAdd
  onMaterialChange
  onMaterialRefChange
  onMaterialRemove
  onMaterialSetCurrent
  onMaterialUndoRedo

  onActivePathChanged
  onAfterComponentSaveAs
  onBeforeComponentSaveAs
  onDeleteModel
  onEraseAll
  onExplode
  onPidChanged
  onPlaceComponent
  onPostSaveModel
  onPreSaveModel
  onSaveModel
  onTransactionAbort
  onTransactionCommit
  onTransactionEmpty
  onTransactionRedo
  onTransactionStart
  onTransactionUndo

  onOptionsProviderChanged

  onContentsModified
  onElementAdded
  onElementRemoved

  onRenderingOptionsChanged

  onSelectionAdded
  onSelectionBulkChange
  onSelectionCleared
  onSelectionRemoved

  onShadowInfoChanged

  onActiveToolChanged
  onToolStateChanged

  onViewChanged
]

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_def(node) ⇒ Object


100
101
102
103
104
105
106
107
108
109
# File 'lib/rubocop/sketchup/cop/requirements/observers_start_operation.rb', line 100

def on_def(node)
  return unless observer_event?(node)
  operations = start_operation(node)
  operations.each { |operation|
    _name, _disable_ui, _next_tr, transparent = operation.arguments
    next unless transparent.nil? || transparent.falsey_literal?
    location = operation_location(operation)
    add_offense(operation, location: location, severity: :error)
  }
end