Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Layout/FirstHashElementIndentation consistent does not work correctly #265

Open
roman-dubrovsky opened this issue Nov 29, 2022 · 0 comments
Labels
bug Something isn't working hacktoberfest For Hacktoberfest contributors

Comments

@roman-dubrovsky
Copy link
Contributor

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
@roman-dubrovsky roman-dubrovsky added the bug Something isn't working label Nov 29, 2022
@atatarenko atatarenko added the hacktoberfest For Hacktoberfest contributors label Sep 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working hacktoberfest For Hacktoberfest contributors
Projects
None yet
Development

No branches or pull requests

2 participants