Skip to content

New paste_sep_linter - #997

Merged
AshesITR merged 3 commits into
masterfrom
paste_sep
Mar 25, 2022
Merged

AshesITR merged 3 commits into
masterfrom
paste_sep

Conversation

@MichaelChirico

Copy link
Copy Markdown
Collaborator

Part of #962

Comment thread R/paste_sep_linter.R Outdated
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
Copy Markdown
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.

@MichaelChirico MichaelChirico Mar 25, 2022 •

Copy link
Copy Markdown
Collaborator Author

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
Copy Markdown
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
Copy Markdown
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 😃

Comment thread NEWS.md Resolved
Comment thread R/paste_sep_linter.R 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