Skip to content

wip: rethink the way attachment detect packages / functions #129

@ColinFay

Description

@ColinFay

Notes :

{attachment} will incorrectly parse the following file :

write(
  c(
    "# There will be some code like library(dplyr)", # <- ignored ✅
    "library(gglot2)", # <- detected ✅
    "sprintf('%s::plot()', 'ggplot2')", # <- incorrectly detecting s ❌
    "# And some comments with blabla::pif", # <- ignored ✅
    "library(thispackagedoesntexist)", # <- There should be an error here ❌
    "print(toTitleCase('hello'))", # <- incorrectly ignoring toTitleCase ❌
    "plot(iris)", # <- ✅
    "print('You can also use library(matplotlib)')", # <- incorrectly detecting matplotlib ❌
    "use('golem', 'run_dev')", # <- not detecting golem ❌
    "getFromNamespace('replace_na', 'tidyr')", # <- not detecting tidyr ❌
    "library(lib.loc = '/tmp', package = 'tidyverse')", # <- not detecting tidyverse ❌
    "requireNamespace('pak')", # <- detected ✅
    "requireNamespace(lib.loc = '/tmp', 'usethis')", # <- not detecting usethis  ❌
    "require(lib.loc = '/tmp', package = 'attachment')" # <- not detecting attachment ❌
  ),
  file = "test_file.R"
)
attachment::att_from_rscript(
  "test_file.R"
)
[1] "gglot2"                 "thispackagedoesntexist" "matplotlib"            
[4] "s" 

The expected values here would be:

  • first, an error for thispackagedoesntexist

Then :

  • gglot2
  • tools
  • golem
  • tidyr
  • tidyverse
  • attachment

I'll work on finding a different approach.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions