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

Ruby format treats interpolated strings as comments. #818

Closed
1 task done
reitermarkus opened this issue Apr 30, 2024 · 5 comments
Closed
1 task done

Ruby format treats interpolated strings as comments. #818

reitermarkus opened this issue Apr 30, 2024 · 5 comments

Comments

@reitermarkus
Copy link

Check for existing issues

  • Completed

Environment

Using the Ruby format, strings with interpolation are treated as comments.

macOS/Homebrew/3.4.1

Describe the bug / provide steps to reproduce it

Running vale with the style rule

---
extends: existence
message: "'%s' should have one space."
link: "https://github.com/Homebrew/brew/blob/HEAD/docs/Prose-Style-Guidelines.md#typographical-conventions"
level: error
nonword: true
tokens:
  - "[a-z][.?!][A-Z]"
  - "[.?!] {2,}[A-Z]"

on a Ruby file containing

"#{args.HEAD?}"

results in

 1:7  error  's.H' should have one space.  Homebrew.Spacing 
@reitermarkus
Copy link
Author

A similar issue occurs with multi-line strings containing #, e.g.

<<~EOS
# Not a Comment
EOS

@reitermarkus
Copy link
Author

reitermarkus commented Apr 30, 2024

And another issue, cause by the shebang line and a ruby: Ruby rule.

#!/usr/bin/env ruby

@reitermarkus
Copy link
Author

And yet another issue, also with the ruby: Ruby rule, caused by a regex being treated as a comment:

%r{https://example\.org/#compatibility-with-ruby-mri\.},

@jdkato
Copy link
Member

jdkato commented May 1, 2024

All of these issues are a product of trying to identify comments using only regex. This is (obviously) not the right way to do this.

I have two branches currently exploring other solutions, tree-sitter and chroma, so this will eventually be fixed.

@jdkato
Copy link
Member

jdkato commented May 31, 2024

These issues should be fixed now on the v3 branch, if you'd like to try it out.

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

No branches or pull requests

2 participants