You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix false positive in Naming/ConstantName when using conditional assignment. (@Drenmi)
Actual behavior
That code triggered the Naming/ConstantName cop.
Steps to reproduce the problem
~ ➜ cat foo.rb
class Foo; end
class Bar; end
Lol = if true then Foo else Bar end
~ ➜ rubocop --only Naming/ConstantName foo.rb
Inspecting 1 file
C
Offenses:
foo.rb:4:1: C: Naming/ConstantName: Use SCREAMING_SNAKE_CASE for constants.
Lol = if true then Foo else Bar end
^^^
1 file inspected, 1 offense detected
This isn't a problem without the conditional:
~ ➜ cat bar.rb
class Foo; end
Bar = Foo
~ ➜ rubocop --only Naming/ConstantName bar.rb
Inspecting 1 file
.
1 file inspected, no offenses detected
This cop would register an offense when rhs is a conditional expression
like the following code:
```
Lol = if true then Foo else Bar end
```
This change fixes that.
This cop would register an offense when rhs is a conditional expression
like the following code:
```
Lol = if true then Foo else Bar end
```
This change fixes that.
Expected behavior
I expected this not to trigger the
Naming/ConstantName
cop:The docs say
The changelog says
Actual behavior
That code triggered the
Naming/ConstantName
cop.Steps to reproduce the problem
This isn't a problem without the conditional:
RuboCop version
The text was updated successfully, but these errors were encountered: