Class: RuboCop::Cop::SketchupPerformance::OperationDisableUI

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

Overview

Operations should disable the UI for performance gain.

Examples:

model = Sketchup.active_model
model.start_operation('Operation Name', true)
# <model changes>
model.commit_operation

Constant Summary collapse

MSG =
'Operations should disable the UI for performance gain.'

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



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/rubocop/sketchup/cop/performance/operation_disable_ui.rb', line 16

def on_send(node)
  _, method_name, *args = *node
  return unless method_name == :start_operation

  if args.size < 2
    add_offense(node, location: :selector)
    return
  end
  argument = args[1]
  disable_ui = argument.truthy_literal?
  return if disable_ui

  add_offense(argument, location: :expression)
end