Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix an error for
Lint/MixedRegexpCaptureTypes
cop
This commit fixes the following error. ```console % cd repo/to/rubocop-hq/rubocop % bundle exec rubocop -d --only Lint/MixedRegexpCaptureTypes lib/rubocop/cop/utils/format_string.rb For /Users/koic/src/github.com/rubocop-hq/rubocop: configuration from /Users/koic/src/github.com/rubocop-hq/rubocop/.rubocop.yml configuration from /Users/koic/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rubocop-performance-1.6.0/config/default.yml configuration from /Users/koic/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rubocop-performance-1.6.0/config/default.yml Default configuration from /Users/koic/src/github.com/rubocop-hq/rubocop/config/default.yml configuration from /Users/koic/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rubocop-rspec-1.39.0/config/default.yml configuration from /Users/koic/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rubocop-rspec-1.39.0/config/default.yml Inheriting configuration from /Users/koic/src/github.com/rubocop-hq/rubocop/.rubocop_todo.yml Inspecting 1 file Scanning /Users/koic/src/github.com/rubocop-hq/rubocop/lib/rubocop/cop/utils/format_string.rb An error occurred while Lint/MixedRegexpCaptureTypes cop was inspecting /Users/koic/src/github.com/rubocop-hq/rubocop/lib/rubocop/cop/utils/format_string.rb:18:19. No valid target found for '*' /Users/koic/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/regexp_parser-1.7.0/lib/regexp_parser/parser.rb:432:in `quantifier' /Users/koic/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/regexp_parser-1.7.0/lib/regexp_parser/parser.rb:102:in `parse_token' /Users/koic/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/regexp_parser-1.7.0/lib/regexp_parser/parser.rb:39:in `block in parse' /Users/koic/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/regexp_parser-1.7.0/lib/regexp_parser/lexer.rb:55:in `block in lex' /Users/koic/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/regexp_parser-1.7.0/lib/regexp_parser/lexer.rb:55:in `map' /Users/koic/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/regexp_parser-1.7.0/lib/regexp_parser/lexer.rb:55:in `lex' /Users/koic/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/regexp_parser-1.7.0/lib/regexp_parser/lexer.rb:15:in `lex' /Users/koic/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/regexp_parser-1.7.0/lib/regexp_parser/parser.rb:38:in `parse' /Users/koic/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/regexp_parser-1.7.0/lib/regexp_parser/parser.rb:22:in `parse' /Users/koic/src/github.com/rubocop-hq/rubocop/lib/rubocop/cop/lint/mixed_regexp_capture_types.rb:28:in `on_regexp' /Users/koic/src/github.com/rubocop-hq/rubocop/lib/rubocop/cop/commissioner.rb:56:in `block (2 levels) in trigger_responding_cops' /Users/koic/src/github.com/rubocop-hq/rubocop/lib/rubocop/cop/commissioner.rb:115:in `with_cop_error_handling' /Users/koic/src/github.com/rubocop-hq/rubocop/lib/rubocop/cop/commissioner.rb:55:in `block in trigger_responding_cops' /Users/koic/src/github.com/rubocop-hq/rubocop/lib/rubocop/cop/commissioner.rb:54:in `each' /Users/koic/src/github.com/rubocop-hq/rubocop/lib/rubocop/cop/commissioner.rb:54:in `trigger_responding_cops' /Users/koic/src/github.com/rubocop-hq/rubocop/lib/rubocop/cop/commissioner.rb:32:in `block (2 levels) in <class:Commissioner>' ``` RuboCop does not know a value of variables that it will contain in the regexp literal. For example, `/(?<foo>#{var}*)` is interpreted as `/(?<foo>*)`. So it does not offense when variables are used in regexp literals. Also this PR fixes regexps that is causing an error in `regexp_parser` gem.
- Loading branch information