Skip to content

Investigate preceding-sibling::* misuse more broadly #2405

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

Closed
MichaelChirico opened this issue Dec 8, 2023 · 2 comments
Closed

Investigate preceding-sibling::* misuse more broadly #2405

MichaelChirico opened this issue Dec 8, 2023 · 2 comments
Labels
consistency 🍎 🍏 internals Issues related to inner workings of lintr, i.e., not user-visible

Comments

@MichaelChirico
Copy link
Collaborator

#2402 exposed an issue about preceding-sibling::*[1] including COMMENT by mistake. Took a quick look for similar such bugs and immediately found one in keyword_quote_linter():

lint("a$ # comment\n'b'", keyword_quote_linter())
# <text>:2:1: warning: [keyword_quote_linter] Only quote targets of extraction with # comment if necessary, i.e., if the name is not a valid R symbol (see ?make.names). Use backticks to create non-syntactic names, or use slot() to extract by string.
# 'b'
# ^~~

# comment in the lint message is supposed to be $.

Filing this issue to fix this and other such instances throughout the codebase. Since they've gone unnoticed thus far, they're mainly about cases where comments go in "unusual" places, but it can't hurt to be more robust.

@MichaelChirico
Copy link
Collaborator Author

Same for preceding-sibling::expr/following-sibling::expr which might unintentionally skip equal_assign or expr_or_assign_or_help expr-ish nodes, a la #2444.

@MichaelChirico MichaelChirico added internals Issues related to inner workings of lintr, i.e., not user-visible consistency 🍎 🍏 labels Dec 21, 2023
@MichaelChirico
Copy link
Collaborator Author

I think the way forward here is #2191 -- once we get some infrastructure set up for "jiggling" tests, we can do a "fuzz" where we insert COMMENT nodes at random places in the AST.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
consistency 🍎 🍏 internals Issues related to inner workings of lintr, i.e., not user-visible
Projects
None yet
Development

No branches or pull requests

1 participant