jwons / raas

MIT License
2 stars 0 forks source link

Checking if library has a variable parameter fails #75

Open blernermhc opened 1 year ago

blernermhc commented 1 year ago

The identify_packages function in static_analysis.R on the dev branch calls:

packages_used <- unique(c(packages_used, get.variable.loaded.libs(file, "library")))

This checks if the library function is called with a variable as its parameter. As it turns out, you cannot pass a variable to library. library's documentation says that the package argument should be either a name or a string. Here is some code demonstrating that a variable cannot be used.

> x <- devtools
Error: object 'devtools' not found
> x <- "devtools"
> library(x)
Error in library(x) : there is no package called ‘x’
> library("devtools")
> library(devtools)

When you do this check, something goes wrong that results in a "Failed on Library" error that stops the static analysis. I discovered this with doi:10.7910/DVN/383K6K - Descriptives.R, and confirmed that if I comment out the line shown above, static analysis completes. Descriptives.R contains the following, and I expect this will be very easy to reproduce:

library(texreg)
library(ggplot2)
library(cowplot)
library(rdrobust)
library(rddensity)
library(rdlocrand)
library(dplyr)
library(tables)
library(xtable)
library(openxlsx)