Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extra rubocop offenses when running rubocop on ruby/spec #2539

Open
eregon opened this issue Mar 2, 2024 · 4 comments
Open

Extra rubocop offenses when running rubocop on ruby/spec #2539

eregon opened this issue Mar 2, 2024 · 4 comments
Labels
bug Something isn't working rubocop Errors that affect Rubocop use of Prism

Comments

@eregon
Copy link
Member

eregon commented Mar 2, 2024

From rubocop/rubocop#12724 (comment)
I noticed there are 3 more offenses when running with ParserEngine: parser_prism:

core/objectspace/define_finalizer_spec.rb:166:1: W: Lint/ImplicitStringConcatenation: Combine  and  into a single string literal, rather than using implicit string concatenation.
    RUBY

language/fixtures/bytes_magic_comment.rb:2:26: F: Lint/Syntax: invalid multibyte character 0xA0
(Using Ruby 3.3 parser; configure using TargetRubyVersion parameter, under AllCops)
$magic_comment_result = '你好'.bytes.inspect
                         ^^
language/fixtures/bytes_magic_comment.rb:2:27: F: Lint/Syntax: invalid multibyte character 0xBD
(Using Ruby 3.3 parser; configure using TargetRubyVersion parameter, under AllCops)
$magic_comment_result = '你好'.bytes.inspect
                           ^^

I guess there are due to some differences between parser gem and Prism::Translation::Parser.

@kddnewton kddnewton added bug Something isn't working rubocop Errors that affect Rubocop use of Prism labels Mar 4, 2024
@kddnewton kddnewton added this to the RuboCop unblocked milestone Mar 4, 2024
@kddnewton
Copy link
Collaborator

Something very odd is happening with Parser::Source::Buffer. We're passing in a big5-encoded string, and it looks like it's transcoding it to utf-8. So then when it hits the multi-byte characters in the source, it has reencoded them as utf-8 which is invalid in big5. I think we need to tell it to please stop doing that.

@CKolkey
Copy link

CKolkey commented Mar 6, 2024

I'm not sure if this is the right place to be tracking these, so apologies if that's the case, but I also found that the following cops were being triggered incorrectly when using implicit keyword values:

# Lint/UnusedMethodArgument

def foo(bar)
  Baz.new(bar:)
end
# Lint/UnusedBlockArgument

[1, 2, 3].each do |n|
  Foo.new(n:)
end

That said, it found these (incorrect) issues very quickly, so, nice work :D

@kddnewton
Copy link
Collaborator

Thanks @CKolkey I've opened #2563 to fix this. If you find more, feel free to open new tickets.

@andyw8
Copy link
Contributor

andyw8 commented Apr 12, 2024

Here's a minimal example that results in a false positive for Layout/ExtraSpacing due to the emoji:

# 👎
<<-RUBY.squish
  a
  b
RUBY

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working rubocop Errors that affect Rubocop use of Prism
Projects
None yet
Development

No branches or pull requests

4 participants