golem
golem copied to clipboard
Check for missing ns()
When running document_and_reload(), we could check if any ns() is missing from the code base.
Check for any ns :
"ns" %in% (getParseData(parse(text = readLines("R/mod_name.R"))) |> dplyr::filter(token == "SYMBOL_FUNCTION_CALL") |> getElement("text") )
Next step
- Detect that a function is input or output and that they are not update
- check that the next function call is ns
Some raw code (not working but left here as a draft)
getParseData(
parse(
text = readLines("R/mod_selecteur_territoire.R")
)
) |>
dplyr::filter(token == "SYMBOL_FUNCTION_CALL") |>
dplyr::mutate(is_input_output = grepl("Input|Output", text)) |>
dplyr::mutate(
is_input_output_next_to_input_output = dplyr::lag(is_input_output)
) |>
dplyr::select(text, is_input_output_next_to_input_output) |>
dplyr::mutate(is_correct = (text == "ns") & is_input_output_next_to_input_output) |>
dplyr::filter(is_input_output_next_to_input_output)
What we want to verify:
After each xyzInput or xyzOutput, there is a ns