Autocorrect for `Layout/FirstHashElementIndentation` breaks indentation consistency · Issue #10689 · rubocop/rubocop · GitHub
Skip to content

Autocorrect for Layout/FirstHashElementIndentation breaks indentation consistency #10689

Closed
@j-miyake

Description

The autocorrect for Layout/FirstHashElementIndentation breaks indentation consistency when inspecting this code.

(Code borrowed from grape's README)

desc 'Returns your public timeline.' do
  headers XAuthToken: {
            description: 'Validates your identity',
            required: true
          },
          XOptionalHeader: {
            description: 'Not really needed',
            required: false
          }
end

Expected behavior

No offenses, or correct the code with keeping indentation consistency for the second hash element.

Actual behavior

C: [Correctable] Layout/FirstHashElementIndentation: Indent the right brace the same as the start of the line where the left brace is.
              },
              ^

The code is autocorrected like,

 desc 'Returns your public timeline.' do
   headers XAuthToken: {
-            description: 'Validates your identity',
-            required: true
-          },
+    description: 'Validates your identity',
+    required: true
+  },
           XOptionalHeader: {
             description: 'Not really needed',
             required: false
           }

Steps to reproduce the problem

Run rubocop against the above code with the default configuration.

RuboCop version

$ exe/rubocop -V
1.30.0 (using Parser 3.1.2.0, rubocop-ast 1.18.0, running on ruby 2.7.5 x86_64-darwin20)
  - rubocop-performance 1.14.0
  - rubocop-rake 0.6.0
  - rubocop-rspec 2.11.1

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions