golem icon indicating copy to clipboard operation
golem copied to clipboard

Check for missing ns()

Open ColinFay opened this issue 5 years ago • 2 comments

When running document_and_reload(), we could check if any ns() is missing from the code base.

ColinFay avatar Nov 19 '19 20:11 ColinFay

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)

ColinFay avatar Dec 18 '23 08:12 ColinFay

What we want to verify:

After each xyzInput or xyzOutput, there is a ns

Screenshot 2023-12-18 at 09 23 48

ColinFay avatar Dec 18 '23 08:12 ColinFay