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

False positive for Layout/SpaceAroundKeyword when using ParserEngine: parser_prism #12829

Closed
andyw8 opened this issue Apr 10, 2024 · 9 comments
Closed
Labels

Comments

@andyw8
Copy link
Contributor

andyw8 commented Apr 10, 2024

Steps to reproduce the problem

Create a file containing:

while true
  # random
end

RuboCop fails with Layout/SpaceAroundKeyword: Space before keyword do is missing.

This might relate to some underlying issue in prism, I haven't investigated yet.

RuboCop version

% bin/rubocop -V                                                                                                                  
1.62.1 (using Prism 0.24.0, rubocop-ast 1.31.2, running on ruby 3.3.0) [x86_64-linux]
  - rubocop-graphql 1.5.1
  - rubocop-minitest 0.35.0
  - rubocop-performance 1.21.0
  - rubocop-rails 2.24.1
  - rubocop-sorbet 0.8.0
@andyw8
Copy link
Contributor Author

andyw8 commented Apr 10, 2024

(I also get Style/WhileUntilDo: Do not use do with multi-line while.).

@koic koic added the prism label Apr 10, 2024
@andyw8
Copy link
Contributor Author

andyw8 commented Apr 10, 2024

Another one, which is probably the same underlying cause:

if true
  # ;
end

Fails with Style/IfWithSemicolon: Do not use if true; - use a ternary operator instead.

@andyw8
Copy link
Contributor Author

andyw8 commented Apr 10, 2024

(this is is Prism 0.24.0, I'll check if it still happens on 0.25.0).

@andyw8
Copy link
Contributor Author

andyw8 commented Apr 10, 2024

Yes, still happens with 0.25.0.

@kddnewton
Copy link
Contributor

Both of these are problems with srange_find in the translation layer. They should not be searching comments.

@andyw8
Copy link
Contributor Author

andyw8 commented Apr 11, 2024

Thanks @kddnewton, I'll look into fixing that in Prism.

@koic I'm not sure if you want to keep this open for tracking, feel free to close it.

@andyw8
Copy link
Contributor Author

andyw8 commented Apr 11, 2024

Working on a fix in ruby/prism#2694

@kddnewton
Copy link
Contributor

@andyw8 this may have been fixed in the latest version of prism, can you check?

@andyw8
Copy link
Contributor Author

andyw8 commented Apr 24, 2024

Indeed it is, I updated the core branch earlier.

@andyw8 andyw8 closed this as completed Apr 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants