-
Notifications
You must be signed in to change notification settings - Fork 12
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
check_cassette_names fails when function argument name included #168
Comments
thanks for the issue @alex-gable and for the thorough dive into the problem. I admit the solution in I'll have a look and see if there's a solution that will be more general |
it gets more complex too: name <- "foo_bar"
use_cassette(name, {
...
}) |
I started working on this, but its complicated. we need to account for:
tried breaking up each test file by my local branch |
it occurred to me that this functionality might be implemented in a package like r-lib/styler apologize for not giving a more thorough inspection of how exactly that package could help. but something like a syntax highlighter or language server that returns a more rich syntax tokenization of R code. |
Good idea to look at styler. I should look to see if there's anything in there that may help |
Sorry for delay on this, getting a new version out soon, then can look at this again |
I've created a repo to reproduce the below scenario.
Session Info
check_cassette_names
fails when thename = {cassette name}
form is used to call the function. debugging shows that the issue is in thecassette_names
function.Debugging the internals led me to discover that the "magic number"
"2"
being added to the"use_cassette"
row number is dependent on allowing strictly a"("
between the function call and the name of the cassette. Looking atdf
as it gets subsetted and assigned toz
, you'd need to add"4"
in the named-argument instance. This situation becomes even more dire if the function arguments are out of order in addition to being named.Inspecting the
df
created by callinggetParseData
on my erroring file, I found that theSYMBOL_FUNCTION_CALL
foruse_cassettes
gives us a scope ofline1 == 5
orline1 == 18
to find our"name"
argument. I believe you'll find promising results by selecting thetoken == "STR_CONST
in those subsets.Looking at the
lobstr::ast()
for various ways to tell vcr which cassette to use, it's hard to see how all cases can be accommodated and parsed easily.Example Abstract Syntax Trees
The text was updated successfully, but these errors were encountered: