Class: RuboCop::Cop::Standard::SemanticBlocks
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Standard::SemanticBlocks
- Extended by:
- AutoCorrector
- Includes:
- IgnoredMethods
- Defined in:
- lib/standard/cop/semantic_blocks.rb
Instance Method Summary collapse
Instance Method Details
#on_block(node) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/standard/cop/semantic_blocks.rb', line 21 def on_block(node) return if ignored_node?(node) || proper_block_style?(node) || (!node.braces? && rescue_child_block?(node)) add_offense(node.loc.begin, message: (node)) do |corrector| return if correction_would_break_code?(node) if node.braces? replace_braces_with_do_end(corrector, node.loc) else replace_do_end_with_braces(corrector, node.loc) end end end |
#on_send(node) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/standard/cop/semantic_blocks.rb', line 7 def on_send(node) return unless node.arguments? return if node.parenthesized? || node.operator_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 |