Skip to content

Style/BlockDelimiters: EnforcedStyle: semantic can cause Lint/Syntax for empty one-liner block #13353

@stdedos

Description

@stdedos
File.open('a', 'w') { }

Expected behavior

Describe here how you expected RuboCop to behave in this particular situation.

idk. I decided to use AllowBracesOnProceduralOneLiners also.

Actual behavior

Describe here what actually happened.
Please use rubocop --debug when pasting rubocop output as it contains additional information.

$ ./rubocop -a t.rb 
t.rb:1:21: F: Lint/Syntax: unexpected token tIDENTIFIER                         
(Using Ruby 2.7 parser; configure using TargetRubyVersion parameter, under AllCops)
File.open('a', 'w') doend
                    ^^^^^
t.rb:1:21: C: [Corrected] Style/BlockDelimiters: Prefer do...end over {...} for procedural blocks.
File.open('a', 'w') { }
                    ^
t.rb:1:22: C: [Corrected] Layout/SpaceInsideBlockBraces: Space inside empty braces detected.
File.open('a', 'w') { }
                     ^
 1/1 file |======================= 100 =======================>| Time: 00:00:01 

1 file inspected, 3 offenses detected, 2 offenses corrected

Steps to reproduce the problem

This is extremely important! Providing us with a reliable way to reproduce
a problem will expedite its solution.

RuboCop version

Include the output of rubocop -V or bundle exec rubocop -V if using Bundler.
If you see extension cop versions (e.g. rubocop-performance, rubocop-rspec, and others)
output by rubocop -V, include them as well. Here's an example:

$ [bundle exec] rubocop -V
1.67.0 (using Parser 3.3.5.0, rubocop-ast 1.32.3, analyzing as Ruby 3.3, running on ruby 3.3.5) [x86_64-linux]
  - rubocop-performance 1.22.1
  - rubocop-rspec 3.1.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy