Skip to content

Commit

Permalink
[Fix rubocop#3095] Add IndentationWidth parameter to Style/AlignParam…
Browse files Browse the repository at this point in the history
…eters

It was supported anyways, through the AutocorrectAlign mixin, but not
explicitly allowed as a parameter.
  • Loading branch information
alexdowad authored and Neodelf committed Oct 15, 2016
1 parent 8009880 commit 69e35de
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

### New features

* [#3095](https://github.com/bbatsov/rubocop/issues/3095): Add `IndentationWidth` configuration parameter for `Style/AlignParameters` cop. ([@alexdowad][])
* [#3066](https://github.com/bbatsov/rubocop/issues/3066): Add new `Style/ImplicitRuntimeError` cop which advises the use of an explicit exception class when raising an error. ([@alexdowad][])
* [#3018](https://github.com/bbatsov/rubocop/issues/3018): Add new `Style/EachForSimpleLoop` cop which advises the use of `Integer#times` for simple loops which iterate a fixed number of times. ([@alexdowad][])
* [#2595](https://github.com/bbatsov/rubocop/issues/2595): New `compact` style for `Style/SpaceInsideLiteralHashBraces`. ([@alexdowad][])
Expand Down
3 changes: 3 additions & 0 deletions config/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,9 @@ Style/AlignParameters:
SupportedStyles:
- with_first_parameter
- with_fixed_indentation
# By default, the indentation width from Style/IndentationWidth is used
# But it can be overridden by setting this parameter
IndentationWidth: ~

Style/AndOr:
# Whether `and` and `or` are banned only in conditionals (conditionals)
Expand Down
24 changes: 24 additions & 0 deletions spec/rubocop/cop/style/align_parameters_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,30 @@
.to eq(correct_source.join("\n"))
end
end

context 'with AlignParameters:IndentationWidth set to 4' do
let(:config) do
RuboCop::Config.new('Style/AlignParameters' =>
cop_config.merge('IndentationWidth' => 4))
end

it 'accepts the first parameter being on a new row' do
inspect_source(cop, [' assigned_value = match(',
' a,',
' b,',
' c',
' )'])
expect(cop.offenses).to be_empty
end

it 'accepts the first parameter being on method row' do
inspect_source(cop, [' assigned_value = match(a,',
' b,',
' c',
' )'])
expect(cop.offenses).to be_empty
end
end
end
end
end

0 comments on commit 69e35de

Please sign in to comment.