Skip to content

Commit

Permalink
[Fix rubocop#8132] Fix the problem with Naming/MethodName: EnforcedSt…
Browse files Browse the repository at this point in the history
…yle: camelCase and _ or i variables.
  • Loading branch information
Антон Валентинович Русанов committed Jun 12, 2020
1 parent 3b0552b commit 4f87275
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

### Bug fixes

* [#8132](https://github.com/rubocop-hq/rubocop/issues/8132): Fix the problem with `Naming/MethodName: EnforcedStyle: camelCase` and `_` or `i` variables. ([@avrusanov][])
* [#8115](https://github.com/rubocop-hq/rubocop/issues/8115): Fix false negative for `Lint::FormatParameterMismatch` when argument contains formatting. ([@andrykonchin][])
* [#8124](https://github.com/rubocop-hq/rubocop/issues/8124): Fix a false positive for `Lint/FormatParameterMismatch` when using named parameters with escaped `%`. ([@koic][])

Expand Down Expand Up @@ -4585,3 +4586,4 @@
[@ric2b]: https://github.com/ric2b
[@burnettk]: https://github.com/burnettk
[@andrykonchin]: https://github.com/andrykonchin
[@avrusanov]: https://github.com/avrusanov
2 changes: 1 addition & 1 deletion lib/rubocop/cop/mixin/configurable_naming.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module ConfigurableNaming

FORMATS = {
snake_case: /^@{0,2}[\da-z_]+[!?=]?$/,
camelCase: /^@{0,2}_?[a-z][\da-zA-Z]+[!?=]?$/
camelCase: /^@{0,2}(?:_|_?[a-z][\da-zA-Z]*)[!?=]?$/
}.freeze
end
end
Expand Down
8 changes: 8 additions & 0 deletions spec/rubocop/cop/naming/variable_name_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@
it 'accepts assignment with indexing of self' do
expect_no_offenses('self[:a] = b')
end

it 'accepts local variables marked as unused' do
expect_no_offenses('_ = 1')
end

it 'accepts one symbol size local variables' do
expect_no_offenses('i = 1')
end
end

context 'when configured for snake_case' do
Expand Down

0 comments on commit 4f87275

Please sign in to comment.