Skip to content

att_from_* functions shouldn't identify packages within quotes and commentsΒ #120

@AlexisBrgn

Description

@AlexisBrgn

When using any att_from_* function on a script containing double colons, it identifies packages that aren't packages.
This subsequently breaks any combination with att_to_desc_from_is or similar utility function.

Examples with an xpath using xml2 library :

xml_find_all(ttt, "//tr/th[@id='r6']/following-sibling::td") #att_from_rmd will return `sibling` as a package...

Example with a comment :

filter(df, value > 5) #this is not base::Filter ! <- will return base as a package

I believe the cause of this unwanted behaviour is the regex in att_from_rscripts.R :
str_extract_all("[[:alnum:]\\.]+(?=::)") %>%

The regex doesn't seem check the context around supposed "package" as you can see this playground
It should be possible to either build a cryptic regex checking if you are within parentheses or comment, or remove comments and quotes with gsub beforehand.
In either cases this might lose support for libraries called within string interpolation such as glue("Value : {data.table::fifelse(myvar, 1,2)}

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