Skip to content

Layout/FirstHashElementIndentation consistent does not work correctly #265

@roman-dubrovsky

Description

@roman-dubrovsky

Have issue with this cop on the project: https://docs.rubocop.org/rubocop/cops_layout.html#layoutfirsthashelementindentation

We have this configuration

Layout/FirstHashElementIndentation:
  EnforcedStyle: consistent

But for that code (which looks correct)

      respond_to do |format|
        format.json {
          render json: {
            data: {
              employee: @employee,
              message: "Associate was successfully created.",
            },
          },
          status: :created
        }
      end

we have this notifications

app/controllers/***_controller.rb:27:13: C: [Correctable] Layout/FirstHashElementIndentation: Use 2 spaces for indentation in a hash, relative to the parent hash key.
            data: { ...
            ^^^^^^^
app/controllers/***_controller.rb:31:11: C: [Correctable] Layout/FirstHashElementIndentation: Indent the right brace the same as the parent hash key.
          },
          ^
app/controllers/***_controller.rb:32:11: C: [Correctable] Layout/ArgumentAlignment: Use one level of indentation for arguments following the first line of a multi-line method call.
          status: :created
          ^^^^^^^^^^^^^^^^
app/controllers/***_controller.rb:60:11: C: [Correctable] Layout/FirstHashElementIndentation: Use 2 spaces for indentation in a hash, relative to the parent hash key.
          data: { ...
          ^^^^^^^
app/controllers/***_controller.rb:63:9: C: [Correctable] Layout/FirstHashElementIndentation: Indent the right brace the same as the parent hash key.
        },
        ^
app/controllers/***_controller.rb:64:9: C: [Correctable] Layout/ArgumentAlignment: Use one level of indentation for arguments following the first line of a multi-line method call.
        status: :ok
        ^^^^^^^^^^^

and rubocop corrects it to the next variant:

      respond_to do |format|
        format.json {
          render json: {
                   data: {
                     employee: @employee,
                     message: "Associate was successfully created.",
                   },
                 },
            status: :created
        }
      end

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghacktoberfestFor Hacktoberfest contributors

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions