Class: RuboCop::Cop::SketchupPerformance::SelectionBulkChanges
- Inherits:
-
SketchUp::Cop
- Object
- SketchUp::WorkaroundCop
- SketchUp::Cop
- RuboCop::Cop::SketchupPerformance::SelectionBulkChanges
- Includes:
- RangeHelp
- Defined in:
- lib/rubocop/sketchup/cop/performance/selection_bulk.rb
Overview
Prefer changing selection in bulk instead of modifying selection within loops. It’s much faster to change the selection in bulk. UI updates are triggered when you update the selection, so reduce the amount of calls.
Constant Summary collapse
- MSG =
'Prefer changing selection in bulk instead of modifying '\ 'selection within loops.'
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
Instance Method Details
#iterator?(node) ⇒ Boolean
61 62 63 64 65 66 67 |
# File 'lib/rubocop/sketchup/cop/performance/selection_bulk.rb', line 61 def iterator?(node) node.is_a?(RuboCop::AST::ForNode) || node.is_a?(RuboCop::AST::UntilNode) || node.is_a?(RuboCop::AST::WhileNode) || block_loop?(node) || numeric_loop?(node) end |
#on_send(node) ⇒ Object
69 70 71 72 73 74 |
# File 'lib/rubocop/sketchup/cop/performance/selection_bulk.rb', line 69 def on_send(node) return unless selection?(node) return unless node.ancestors.any?(&method(:iterator?)) add_offense(node, location: range_with_receiver(node)) end |