Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This PR fixes the following error for `Style/GuardClause` when using heredoc as an argument of raise in `then` branch and it does not have `else` branch: ```ruby def func if condition raise <<~MESSAGE oops MESSAGE end end ``` ```console % bundle exec rubocop --only Style/GuardClause -d (snip) An error occurred while Style/GuardClause cop was inspecting /Users/koic/src/github.com/koic/rubocop-issues/guard_clause/example.rb:1:0. undefined method `source_range' for nil:NilClass /Users/koic/src/github.com/rubocop/rubocop/lib/rubocop/cop/style/guard_clause.rb:209:in `autocorrect_heredoc_argument' /Users/koic/src/github.com/rubocop/rubocop/lib/rubocop/cop/style/guard_clause.rb:191:in `autocorrect' /Users/koic/src/github.com/rubocop/rubocop/lib/rubocop/cop/style/guard_clause.rb:179:in `block in register_offense' ```
- Loading branch information
Showing
3 changed files
with
37 additions
and
7 deletions.
There are no files selected for viewing
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 @@ | ||
* [#11344](https://github.com/rubocop/rubocop/pull/11344): Fix an error for `Style/GuardClause` when using heredoc as an argument of raise in `then` branch and it does not have `else` branch. ([@koic][]) |
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
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