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

New paste_sep_linter #997

Merged
merged 3 commits into from
Mar 25, 2022
Merged

New paste_sep_linter #997

merged 3 commits into from
Mar 25, 2022

Conversation

MichaelChirico
Copy link
Collaborator

Part of #962

sep_cond <- file.path(
"SYMBOL_SUB[text() = 'sep']",
# NB: length-2 means '' or "" (*not* 'ab' or 'cd' which have length 4)
"following-sibling::expr[1][STR_CONST[string-length(text()) = 2]]"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Edge case: What about r"()"?
Probably easier to understand with explicit comparisons.

Copy link
Collaborator Author

@MichaelChirico MichaelChirico Mar 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea... this is gonna come up a few times. we're still on R 3.6.3 so haven't had to lint for any raw strings stuff yet.

in the case of this linter, I think it's fine as is... paste(sep = R'()') seems unlikely.

this linter has mainly been useful for tidying up very old code written before paste0 existed, FWIW

PS we may have to do a thing where we merge first and tidy up later, for any case where there's something unique to do for R>4.0. it'll be tough to do such changes in my work environment.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can chip in with 4.x stuff.
It should also be safe and future proof to instead check identical(eval(xml_text(sep_str_const)), ""). WDYT?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right, but i always hate pulling stuff out of the XPath if we can avoid it 😃

NEWS.md Show resolved Hide resolved
R/paste_sep_linter.R Outdated Show resolved Hide resolved
@AshesITR AshesITR merged commit 5da20e0 into master Mar 25, 2022
@MichaelChirico MichaelChirico deleted the paste_sep branch March 30, 2022 16:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants