-
Notifications
You must be signed in to change notification settings - Fork 186
New inner_combine_linter #1012
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 inner_combine_linter #1012
Conversation
R/inner_combine_linter.R
Outdated
date_args_cond <- xp_or( | ||
sprintf("not(expr[SYMBOL_FUNCTION_CALL[%s]])", xp_text_in_table(date_funs)), | ||
"not(SYMBOL_SUB) and not(following-sibling::expr/SYMBOL_SUB)", | ||
do.call(xp_and, as.list(vapply(date_args, arg_match_cond, character(1L)))) | ||
) | ||
|
||
log_args_cond <- xp_or( | ||
sprintf("not(expr[SYMBOL_FUNCTION_CALL[%s]])", xp_text_in_table(log_funs)), | ||
"not(SYMBOL_SUB) and not(following-sibling::expr/SYMBOL_SUB)", | ||
arg_match_cond("base") | ||
) | ||
|
||
c_expr_cond <- xp_and( | ||
sprintf( | ||
"expr[SYMBOL_FUNCTION_CALL[%s]]", | ||
xp_text_in_table(c(no_arg_vectorized_funs, date_funs, log_funs)) | ||
), | ||
"not(following-sibling::expr[not(expr[SYMBOL_FUNCTION_CALL])])", | ||
sprintf( | ||
"not(%1$s != following-sibling::expr/%1$s)", | ||
"expr/SYMBOL_FUNCTION_CALL" | ||
), | ||
date_args_cond, | ||
log_args_cond | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
glue()
these as well?
Very hard to read with the nested sprintf()
calls.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactored a little bit, hopefully a bit better.
# still preferable to vectorize the call, while being sure to use a | ||
# consistent format for the inputs. In this case, the correct equivalent | ||
# call is as.POSIXct(c("2021-01-01 00:00:00", "2021-01-01 01:00:00")). | ||
# See http://google3/analysis/economics/r/izeitgeist/tests/testthat/test-izeitgeist.R;l=1058-1062;rcl=394984377. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
internal google link?
# Conflicts: # man/linters.Rd
Part of #962
This one is somewhat of a mess... easy enough to describe what it wants to do, and it did match a bunch of our internal code. But a bit of a mess to write the linter.