Skip to content

Commit

Permalink
Disable Style/YodaExpression by default
Browse files Browse the repository at this point in the history
Follow rubocop#11333 (comment)

This PR disables `Style/YodaExpression` by default to respect user intentions such as:

```ruby
config.server_port = 9000 + ENV["TEST_ENV_NUMBER"].to_i
```
  • Loading branch information
koic authored and bbatsov committed Jan 3, 2023
1 parent ebb2f0a commit aa19ccd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* [#11380](https://github.com/rubocop/rubocop/pull/11380): Disable `Style/YodaExpression` by default. ([@koic][])
3 changes: 2 additions & 1 deletion config/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5440,9 +5440,10 @@ Style/YodaCondition:

Style/YodaExpression:
Description: 'Forbid the use of yoda expressions.'
Enabled: pending
Enabled: false
Safe: false
VersionAdded: '1.42'
VersionChanged: '<<next>>'
SupportedOperators:
- '*'
- '+'
Expand Down
7 changes: 7 additions & 0 deletions lib/rubocop/cop/style/yoda_expression.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ module Style
# and `^` operators) where the order of expression is reversed, eg. `1 + x`.
# This cop complements `Style/YodaCondition` cop, which has a similar purpose.
#
# This cop is disabled by default to respect user intentions such as:
#
# [source,ruby]
# ----
# config.server_port = 9000 + ENV["TEST_ENV_NUMBER"].to_i
# ----
#
# @safety
# This cop is unsafe because binary operators can be defined
# differently on different classes, and are not guaranteed to
Expand Down

0 comments on commit aa19ccd

Please sign in to comment.