Layout/ClosingHeredocIndentation
& Style/RedundantHeredocDelimiterQuotes
- undefined method `captures' for nil:NilClass
#11998
Labels
Hello 馃憢 I open an issue for both cops, because it failed on the same method
heredoc_type
do not hesitate to tell me if you prefer two distinct issues.Given a file
foo.rb
:<<""
Which is a valid syntax:
Expected behavior
Should not trigger an error. I think this is a valid
heredoc
syntax, as it start with<<
maybe some related offenses can be displayed. I'm very terrible with regex, so I can't dig more on group expectation etc. 馃槥Actual behavior
bin/rubocop -d --only Style/RedundantHeredocDelimiterQuotes foo.rb
bin/rubocop -d --only Style/ClosingHeredocIndentation foo.rb
Steps to reproduce the problem
Both
Layout/ClosingHeredocIndentation
&Style/RedundantHeredocDelimiterQuotes
are using theheredoc_type
method from the moduleRuboCop::Cop::Heredoc
Which receive a node:
Nothing match with the pattern:
OPENING_DELIMITER = /(<<[~-]?)['"`]?([^'"`]+)['"`]?/.freeze
So the capture group
node.source.match(OPENING_DELIMITER).captures[0]
trigger an error.rubocop/lib/rubocop/cop/layout/closing_heredoc_indentation.rb
Lines 57 to 66 in aaf1c3f
rubocop/lib/rubocop/cop/style/redundant_heredoc_delimiter_quotes.rb
Lines 48 to 54 in aaf1c3f
rubocop/lib/rubocop/cop/mixin/heredoc.rb
Lines 32 to 34 in aaf1c3f
RuboCop version
The text was updated successfully, but these errors were encountered: