提交 5ac6ec54 编写于 作者: K Koichi ITO

Enable autocorrect for `Lint/EndAlignment` cop

### Summary

This PR changes .rubocop.yml.

Regarding the code using `if ... else ... end`, I think the coding style
that Rails expects is as follows.

```ruby
var = if cond
  a
else
  b
end
```

However, the current .rubocop.yml setting does not offense for the
following code.

```ruby
var = if cond
        a
      else
        b
      end
```

I think that the above code expects offense to be warned.
Moreover, the layout by autocorrect is unnatural.

```ruby
var = if cond
  a
      else
        b
      end
```

This PR adds a setting to .rubocop.yml to make an offense warning and
autocorrect as expected by the coding style.
And this change also fixes `case ... when ... end` together.

Also this PR itself is an example that arranges the layout using
`rubocop -a`.

### Other Information

Autocorrect of `Lint/EndAlignment` cop is `false` by default.
https://github.com/bbatsov/rubocop/blob/v0.51.0/config/default.yml#L1443

This PR changes this value to `true`.

Also this PR has changed it together as it is necessary to enable
`Layout/ElseAlignment` cop to make this behavior.
上级 ffd9902b
...@@ -26,6 +26,9 @@ Layout/CaseIndentation: ...@@ -26,6 +26,9 @@ Layout/CaseIndentation:
Layout/CommentIndentation: Layout/CommentIndentation:
Enabled: true Enabled: true
Layout/ElseAlignment:
Enabled: true
Layout/EmptyLineAfterMagicComment: Layout/EmptyLineAfterMagicComment:
Enabled: true Enabled: true
...@@ -140,6 +143,7 @@ Style/UnneededPercentQ: ...@@ -140,6 +143,7 @@ Style/UnneededPercentQ:
Lint/EndAlignment: Lint/EndAlignment:
Enabled: true Enabled: true
EnforcedStyleAlignWith: variable EnforcedStyleAlignWith: variable
AutoCorrect: true
# Use my_method(my_arg) not my_method( my_arg ) or my_method my_arg. # Use my_method(my_arg) not my_method( my_arg ) or my_method my_arg.
Lint/RequireParentheses: Lint/RequireParentheses:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册