Skip to content

Enable Rubocop cop for multiline conditional assignment

What does this MR do and why?

Enable Rubocop cop for multiline conditional assignment

Feature: Maintenance

Screenshots or screen recordings

Code:

        message = if ready?
                    <<~MESSAGE
                      #{preface.chomp}

                      #{mentions}, please check the issue details are up to date
                      and ping @#{username} if there is any additional context which may help.

                      /assign @#{username}
                    MESSAGE
                  else
                    <<~MESSAGE
                      #{preface.chomp}

                      #{mentions}, this issue is not marked ~"workflow::ready for development",
                      please help @#{username} understand if they can move it forward, and how best to proceed.

                      /assign @#{username}
                    MESSAGE
                  end

Rubocop:

root@a2b8ffd7946d:/repo/contributors# bundle exec rubocop
Inspecting 258 files
..........C.......................................................................................................................................................................................................................................................

Offenses:

app/controllers/api/v1/manage_issue_controller.rb:96:9: C: [Correctable] Layout/MultilineAssignmentLayout: Right hand side of multi-line assignment is on the same line as the assignment operator =.
        close_action = if reason_message == 'a duplicate' ...
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

258 files inspected, 1 offense detected, 1 offense autocorrectable

Autofix:

        message =
          if ready?
            <<~MESSAGE
              #{preface.chomp}

              #{mentions}, please check the issue details are up to date
              and ping @#{username} if there is any additional context which may help.

              /assign @#{username}
            MESSAGE
          else
            <<~MESSAGE
              #{preface.chomp}

              #{mentions}, this issue is not marked ~"workflow::ready for development",
              please help @#{username} understand if they can move it forward, and how best to proceed.

              /assign @#{username}
            MESSAGE
          end

Validation steps

/cc @leetickett-gitlab

Edited by Lee Tickett

Merge request reports

Loading