Skip to content

False positive for Style/EmptyElse when AllowComments: true with elsif-clause #13085

@ydah

Description

@ydah

Expected behavior

We expect that the following codes are not offenses:

if condition
  statement
elsif condition2
  statement2
else
  # some comment
end

Actual behavior

Offenses occur:

if condition
  statement
elsif condition2
  statement2
else
^^^^ Redundant `else`-clause.
  # some comment
end

Steps to reproduce the problem

The following settings must be included in .rubocop.yml:

Style/EmptyElse:
  AllowComments: true

RuboCop version

❯ bundle exec rubocop -V                                     
1.65.0 (using Parser 3.3.4.0, rubocop-ast 1.31.3, running on ruby 3.3.0) [arm64-darwin23]
  - rubocop-performance 1.21.1
  - rubocop-rake 0.6.0
  - rubocop-rspec 3.0.3

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