False Positive for `Lint/ImplicitStringConcatenation` with prism
pjsk-stripe opened this issue · comments
pjsk-stripe commented
Expected behavior
Lint/ImplicitStringConcatenation
behaves strangely with prism in the situation below. With prism turned off, it doesn't report an error.
I imagine this is some combination of the \n
and heredocs. But strangely the prefix Something:
is determining the output.
Actual behavior
$ rubocop --debug
For /Users/pjsk/Workspace/rubocop-test: configuration from /Users/pjsk/Workspace/rubocop-test/.rubocop.yml
Default configuration from /Users/pjsk/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/rubocop-1.63.4/config/default.yml
Use parallel by default.
Running parallel inspection
Loading cache from /Users/pjsk/.cache/rubocop_cache/534273b9ca3f55074640a50c5ca18229f9ff297e/6d7a3b621ca1730e04accd938619e4bdab66cfb1/63a887baec0f59303e2489405d3b0e5e5e5d0d31
Inspecting 2 files
Scanning /Users/pjsk/Workspace/rubocop-test/Gemfile
Loading cache from /Users/pjsk/.cache/rubocop_cache/534273b9ca3f55074640a50c5ca18229f9ff297e/6d7a3b621ca1730e04accd938619e4bdab66cfb1/b34fb59736dff2e5d1f73f75d34d9efc96a08880
.Scanning /Users/pjsk/Workspace/rubocop-test/test.rb
Loading cache from /Users/pjsk/.cache/rubocop_cache/534273b9ca3f55074640a50c5ca18229f9ff297e/6d7a3b621ca1730e04accd938619e4bdab66cfb1/63a887baec0f59303e2489405d3b0e5e5e5d0d31
W
Offenses:
test.rb:5:1: W: Lint/ImplicitStringConcatenation: Combine and Something: into a single string literal, rather than using implicit string concatenation.
Something: #{b}
^^^^^^^^^^^^^
2 files inspected, 1 offense detected
Finished in 0.2889069998636842 seconds
Steps to reproduce the problem
$ rubocop -V
1.63.4 (using Prism 0.27.0, rubocop-ast 1.31.3, running on ruby 2.7.2) [arm64-darwin22]
AllCops:
TargetRubyVersion: 3.3
ParserEngine: parser_prism
NewCops: enable
# frozen_string_literal: true
_note = <<~SOMEHEREDOC
Thing: #{a} \n
Something: #{b}
SOMEHEREDOC
RuboCop version
Include the output of rubocop -V
or bundle exec rubocop -V
if using Bundler.
If you see extension cop versions (e.g. rubocop-performance
, rubocop-rspec
, and others)
output by rubocop -V
, include them as well. Here's an example:
$ rubocop -V
1.63.4 (using Prism 0.27.0, rubocop-ast 1.31.3, running on ruby 3.3.0) [arm64-darwin23]