Skip to content

Commit

Permalink
Rename IndentArray and IndentHash to IndentFirst*Element
Browse files Browse the repository at this point in the history
  • Loading branch information
Buildkite authored and bbatsov committed Apr 28, 2019
1 parent 326da99 commit 184c2a1
Show file tree
Hide file tree
Showing 14 changed files with 218 additions and 200 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
* [#6885](https://github.com/rubocop-hq/rubocop/pull/6885): Revert adding psych >= 3.1 as runtime dependency. ([@andreaseger][])
* Rename `Layout/FirstParameterIndentation` to `Layout/IndentFirstArgument`. ([@maxh][])
* Extract method call argument alignment behavior from `Layout/AlignParameters` into `Layout/AlignArguments`. ([@maxh][])
* Rename `IndentArray` and `IndentHash` to `IndentFirstArrayElement` and `IndentFirstHashElement`. ([@maxh][])

## 0.67.2 (2019-04-05)

Expand Down
70 changes: 35 additions & 35 deletions config/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -652,32 +652,6 @@ Layout/HeredocArgumentClosingParenthesis:
Enabled: false
VersionAdded: '0.68'

Layout/IndentArray:
Description: >-
Checks the indentation of the first element in an array
literal.
Enabled: true
VersionAdded: '0.49'
# The value `special_inside_parentheses` means that array literals with
# brackets that have their opening bracket on the same line as a surrounding
# opening round parenthesis, shall have their first element indented relative
# to the first position inside the parenthesis.
#
# The value `consistent` means that the indentation of the first element shall
# always be relative to the first position of the line where the opening
# bracket is.
#
# The value `align_brackets` means that the indentation of the first element
# shall always be relative to the position of the opening bracket.
EnforcedStyle: special_inside_parentheses
SupportedStyles:
- special_inside_parentheses
- consistent
- align_brackets
# By default, the indentation width from `Layout/IndentationWidth` is used
# But it can be overridden by setting this parameter
IndentationWidth: ~

Layout/IndentAssignment:
Description: >-
Checks the indentation of the first line of the
Expand Down Expand Up @@ -712,25 +686,36 @@ Layout/IndentFirstArgument:
# But it can be overridden by setting this parameter
IndentationWidth: ~

Layout/IndentFirstParameter:
Layout/IndentFirstArrayElement:
Description: >-
Checks the indentation of the first parameter in a
method defintion.
Checks the indentation of the first element in an array
literal.
Enabled: true
VersionAdded: '0.49'
VersionChanged: '0.68'
EnforcedStyle: special_for_inner_method_call_in_parentheses
VersionAdded: '0.68'
# The value `special_inside_parentheses` means that array literals with
# brackets that have their opening bracket on the same line as a surrounding
# opening round parenthesis, shall have their first element indented relative
# to the first position inside the parenthesis.
#
# The value `consistent` means that the indentation of the first element shall
# always be relative to the first position of the line where the opening
# bracket is.
#
# The value `align_brackets` means that the indentation of the first element
# shall always be relative to the position of the opening bracket.
EnforcedStyle: special_inside_parentheses
SupportedStyles:
- special_inside_parentheses
- consistent
- align_parentheses
- align_brackets
# By default, the indentation width from `Layout/IndentationWidth` is used
# But it can be overridden by setting this parameter
IndentationWidth: ~

Layout/IndentHash:
Layout/IndentFirstHashElement:
Description: 'Checks the indentation of the first key in a hash literal.'
Enabled: true
VersionAdded: '0.49'
VersionAdded: '0.68'
# The value `special_inside_parentheses` means that hash literals with braces
# that have their opening brace on the same line as a surrounding opening
# round parenthesis, shall have their first key indented relative to the
Expand All @@ -751,6 +736,21 @@ Layout/IndentHash:
# But it can be overridden by setting this parameter
IndentationWidth: ~

Layout/IndentFirstParameter:
Description: >-
Checks the indentation of the first parameter in a
method defintion.
Enabled: true
VersionAdded: '0.49'
VersionChanged: '0.68'
EnforcedStyle: special_for_inner_method_call_in_parentheses
SupportedStyles:
- consistent
- align_parentheses
# By default, the indentation width from `Layout/IndentationWidth` is used
# But it can be overridden by setting this parameter
IndentationWidth: ~

Layout/IndentHeredoc:
Description: 'This cop checks the indentation of the here document bodies.'
StyleGuide: '#squiggly-heredocs'
Expand Down
4 changes: 2 additions & 2 deletions lib/rubocop.rb
Original file line number Diff line number Diff line change
Expand Up @@ -216,13 +216,13 @@
require_relative 'rubocop/cop/layout/first_method_argument_line_break'
require_relative 'rubocop/cop/layout/first_method_parameter_line_break'
require_relative 'rubocop/cop/layout/heredoc_argument_closing_parenthesis'
require_relative 'rubocop/cop/layout/indent_array'
require_relative 'rubocop/cop/layout/indent_assignment'
require_relative 'rubocop/cop/layout/indentation_consistency'
require_relative 'rubocop/cop/layout/indentation_width'
require_relative 'rubocop/cop/layout/indent_first_argument'
require_relative 'rubocop/cop/layout/indent_first_array_element'
require_relative 'rubocop/cop/layout/indent_first_hash_element'
require_relative 'rubocop/cop/layout/indent_first_parameter'
require_relative 'rubocop/cop/layout/indent_hash'
require_relative 'rubocop/cop/layout/indent_heredoc'
require_relative 'rubocop/cop/layout/initial_indentation'
require_relative 'rubocop/cop/layout/leading_blank_lines'
Expand Down
6 changes: 6 additions & 0 deletions lib/rubocop/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ class Config
'Layout/FirstParameterIndentation' =>
'The `Layout/FirstParameterIndentation` cop has been renamed to ' \
'`Layout/IndentFirstArgument`.',
'Layout/IndentArray' =>
'The `Layout/IndentArray` cop has been renamed to ' \
'`Layout/IndentFirstArrayElement`.',
'Layout/IndentHash' =>
'The `Layout/IndentHash` cop has been renamed to ' \
'`Layout/IndentFirstHashElement`.',
'Layout/SpaceAfterControlKeyword' =>
'The `Layout/SpaceAfterControlKeyword` cop has been removed. Please ' \
'use `Layout/SpaceAroundKeyword` instead.',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ module Layout
# and_now_for_something = [
# :completely_different
# ]
class IndentArray < Cop
class IndentFirstArrayElement < Cop
include Alignment
include ConfigurableEnforcedStyle
include MultilineElementIndentation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ module Layout
# and_now_for_something = {
# completely: :different
# }
class IndentHash < Cop
class IndentFirstHashElement < Cop
include Alignment
include ConfigurableEnforcedStyle
include MultilineElementIndentation
Expand Down
7 changes: 4 additions & 3 deletions lib/rubocop/cop/metrics/line_length.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ module Metrics
# - AlignHash
# - AlignParameters
# - ClosingParenthesisIndentation
# - FirstParameterIndentation
# - IndentArray
# - IndentHash
# - IndentFirstArgument
# - IndentFirstArrayElement
# - IndentFirstHashElement
# - IndentFirstParameter
# - MultilineArrayLineBreaks
# - MultilineHashBraceLayout
# - MultilineHashKeyLineBreaks
Expand Down
6 changes: 3 additions & 3 deletions lib/rubocop/cop/registry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,17 @@ def contains_cop_matching?(names)
#
# cops = RuboCop::Cop::Cop.all
# cops.
# qualified_cop_name('Layout/IndentArray') # => 'Layout/IndentArray'
# qualified_cop_name('Layout/EndOfLine') # => 'Layout/EndOfLine'
#
# @example fixes incorrect namespaces
#
# cops = RuboCop::Cop::Cop.all
# cops.qualified_cop_name('Lint/IndentArray') # => 'Layout/IndentArray'
# cops.qualified_cop_name('Lint/EndOfLine') # => 'Layout/EndOfLine'
#
# @example namespaces bare cop identifiers
#
# cops = RuboCop::Cop::Cop.all
# cops.qualified_cop_name('IndentArray') # => 'Layout/IndentArray'
# cops.qualified_cop_name('EndOfLine') # => 'Layout/EndOfLine'
#
# @example passes back unrecognized cop names
#
Expand Down
4 changes: 2 additions & 2 deletions manual/cops.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,11 @@ In the following section you find all available cops:
* [Layout/FirstMethodArgumentLineBreak](cops_layout.md#layoutfirstmethodargumentlinebreak)
* [Layout/FirstMethodParameterLineBreak](cops_layout.md#layoutfirstmethodparameterlinebreak)
* [Layout/HeredocArgumentClosingParenthesis](cops_layout.md#layoutheredocargumentclosingparenthesis)
* [Layout/IndentArray](cops_layout.md#layoutindentarray)
* [Layout/IndentAssignment](cops_layout.md#layoutindentassignment)
* [Layout/IndentFirstArgument](cops_layout.md#layoutindentfirstargument)
* [Layout/IndentFirstArrayElement](cops_layout.md#layoutindentfirstarrayelement)
* [Layout/IndentFirstHashElement](cops_layout.md#layoutindentfirsthashelement)
* [Layout/IndentFirstParameter](cops_layout.md#layoutindentfirstparameter)
* [Layout/IndentHash](cops_layout.md#layoutindenthash)
* [Layout/IndentHeredoc](cops_layout.md#layoutindentheredoc)
* [Layout/IndentationConsistency](cops_layout.md#layoutindentationconsistency)
* [Layout/IndentationWidth](cops_layout.md#layoutindentationwidth)
Expand Down

0 comments on commit 184c2a1

Please sign in to comment.