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

Add IndentFirstArgument and IndentFirstParameter #6982

Merged
merged 2 commits into from Apr 27, 2019

Conversation

maxh
Copy link
Contributor

@maxh maxh commented Apr 27, 2019

As proposed in #6929, this PR (1) renames Layout/FirstParameterIndentation to Layout/IndentFirstArgument because it operates on arguments in method calls and (2) adds a new cop with the name Layout/IndentFirstParameter that operates on parameters in method definitions.

The reason to change the naming scheme from FirstFooIndentation to IndentFirstFoo is for consistency and ease of use in the docs. See also #6983.

Because indenting the first element of method definition shares logic with array/hash literal alignment, this PR renames ArrayHashIndentation mixin and uses it in the cop added in (2). This PR also cleans up the use of argument and parameter throughout the relevant docs.

This PR will be a minor breaking change due to the rename. Both cops are enabled by default.

I suggest releasing this in the same version as #6983 and #6981 so that folks only have to go through one set of breaking changes.


Before submitting the PR make sure the following are checked:

  • Wrote good commit messages.
  • Commit message starts with [Fix #issue-number] (if the related issue exists).
  • Feature branch is up-to-date with master (if not - rebase it).
  • Squashed related commits together.
  • Added tests.
  • Added an entry to the Changelog if the new code introduces user-observable changes. See changelog entry format.
  • The PR relates to only one subject with a clear title
    and description in grammatically correct, complete sentences.
  • Run bundle exec rake default. It executes all tests and RuboCop for itself, and generates the documentation.

@maxh maxh force-pushed the maxh/add-first-argument-indent branch from 970e31a to 8f03bcb Compare April 27, 2019 14:04
@maxh maxh changed the title Clean up FirstParameterIndentation and add FirstArgumentIndentation Add FirstArgumentIndentation and FirstParameterIndentation Apr 27, 2019
@maxh maxh force-pushed the maxh/add-first-argument-indent branch from 8f03bcb to 268d1e6 Compare April 27, 2019 14:05
@maxh maxh changed the title Add FirstArgumentIndentation and FirstParameterIndentation Add IndentFirstArgument and IndentFirstParameter Apr 27, 2019
@bbatsov bbatsov merged commit c3a0f96 into rubocop:master Apr 27, 2019
@bbatsov
Copy link
Collaborator

bbatsov commented Apr 27, 2019

Thanks!

koic added a commit to koic/rubocop that referenced this pull request Apr 28, 2019
Follow up rubocop#6982.

This PR adds obsolete message for renaming `Layout/FirstParameterIndentation`.

The following is when `Layout/FirstParameterIndentation` is specified in
.rubocop.yml.

## Before

```console
% rubocop
Warning: unrecognized cop Layout/FirstParameterIndentation found in
.rubocop.yml
```

## After

```console
% rubocop
Error: The `Layout/FirstParameterIndentation` cop has been renamed to
`Layout/IndentFirstArgument`.
(obsolete configuration found in .rubocop.yml, please update it)
```
bbatsov pushed a commit that referenced this pull request Apr 28, 2019
Follow up #6982.

This PR adds obsolete message for renaming `Layout/FirstParameterIndentation`.

The following is when `Layout/FirstParameterIndentation` is specified in
.rubocop.yml.

## Before

```console
% rubocop
Warning: unrecognized cop Layout/FirstParameterIndentation found in
.rubocop.yml
```

## After

```console
% rubocop
Error: The `Layout/FirstParameterIndentation` cop has been renamed to
`Layout/IndentFirstArgument`.
(obsolete configuration found in .rubocop.yml, please update it)
```
koic added a commit to koic/rubocop that referenced this pull request May 1, 2019
Follow up rubocop#6982 and rubocop#7002.

This PR marks the default `EnforcedStyle` for `Layout/IndentFirstParameter`
natesholland added a commit to natesholland/rails that referenced this pull request May 4, 2019
Performance cops were extracted in rubocop/rubocop#5977 and @koic
updated to 0.67.2 and added the rubocop-performance gem in rails#35989.

This bumps rubocop to 0.68.1 to be on the latest version. Two changes
were made in regards to the bump of the version:
* The first was that Layout/FirstParameterIndentation was renamed to
Layout/IndentFirstArgument. These changes can be seen in
rubocop/rubocop#6982 and rubocop/rubocop#6987
* The second was that a new instance of the Style/HashSyntax cop was
found. I updated that instance to follow the new Ruby >= 1.9 syntax.
natesholland added a commit to natesholland/codeclimate-rubocop that referenced this pull request May 4, 2019
natesholland added a commit to natesholland/codeclimate-rubocop that referenced this pull request May 4, 2019
This is a new cop that was added in rubocop/rubocop#6982
natesholland added a commit to natesholland/codeclimate-rubocop that referenced this pull request May 4, 2019
@maxh maxh deleted the maxh/add-first-argument-indent branch May 22, 2019 02:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants