Class: RuboCop::Cop::Standard::BlockSingleLineBraces
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Standard::BlockSingleLineBraces
- Extended by:
- AutoCorrector
- Defined in:
- lib/standard/cop/block_single_line_braces.rb
Overview
Check for uses of braces around single line blocks, but allows either braces or do/end for multi-line blocks.
Instance Method Summary collapse
Instance Method Details
#on_block(node) ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'lib/standard/cop/block_single_line_braces.rb', line 31 def on_block(node) return if ignored_node?(node) return if proper_block_style?(node) = (node) add_offense(node.loc.begin, message: ) do |corrector| autocorrect(corrector, node) end end |
#on_send(node) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/standard/cop/block_single_line_braces.rb', line 16 def on_send(node) return unless node.arguments? return if node.parenthesized? return if node.operator_method? || node.assignment_method? node.arguments.each do |arg| get_blocks(arg) do |block| # If there are no parentheses around the arguments, then braces # and do-end have different meaning due to how they bind, so we # allow either. ignore_node(block) end end end |