-
-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix
Performance/CaseWhenSplat
cop error on when
node without body
Previously if `when` node has an empty body this cop raises: ```ruby case 1 when 1 # no body # 1 == 1 else nil end ``` ``` undefined method `loc' for nil # ./lib/rubocop/cop/performance/case_when_splat.rb:154:in `indent_for' # ./lib/rubocop/cop/performance/case_when_splat.rb:144:in `new_branch_without_then' # ./lib/rubocop/cop/performance/case_when_splat.rb:123:in `reordering_correction' # ./lib/rubocop/cop/performance/case_when_splat.rb:114:in `reorder_condition' # ./lib/rubocop/cop/performance/case_when_splat.rb:86:in `autocorrect' ``` It also did not preserve comments.
- Loading branch information
1 parent
4e147b0
commit a1a7c35
Showing
4 changed files
with
46 additions
and
6 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
changelog/fix_performance_case_when_splat_cop_error_on_when_without_body.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* [#484](https://github.com/rubocop/rubocop-performance/pull/484): Fix `Performance/CaseWhenSplat` cop error on `when` node without body. ([@viralpraxis][]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters