Closed caldwellst closed 4 months ago
This is interesting.
Just adding on here that I get similar, but slightly different issues, when testing against modules. Here, just have a.R
importing from src/z.R
and src/y.R
.
a.R
box::use(src/x)
box::use(src/y)
x$x()
y$y()
And running:
lintr::lint("x.R", linters = box.linters::box_default_linters)
Gives:
Line 1 [box_unused_attached_mod_linter] Attached module unused.
Line 4 [box_usage_linter] <package/module>$function does not exist.
Interesting because one of the attachments succeeds.
a.R
box::use(src/x)
box::use(src/y)
box::use(src/z)
x$x()
y$y()
z$z()
And this generates errors for the first two attachments src/x
and src/y
, but again, the final attachment passes linting, in this case src/z
.
Using the box::use(src/x, )
style ensures that all linting passes, just like when attaching packages.
While linting box::use(packages)
use a different set of functions from linting box::use(path/modules)
, they both follow the same algorithm.
We, at Appsilon, as standard practice use one box::use()
call for packages, and a separate box::use()
call for modules. We did not take into consideration having multiple box::use()
calls. We will include this feature request in future releases.
Thanks.
@caldwellst We just released 0.10.0
on CRAN. It comes with a fix for this issue.
box.linters version
0.9.1
Sample source code to lint
Lint command used
Lint result
Expected result
This should succeed. Linting is successful if we only import a single package.
It is also successful with multiple imports if we follow the
box.linters::rhino_default_linters
style of adding,
after all imports.And if we only add
,
without the space, it is also successful, which leads me to suspect it has something to do with expecting comma separation that allows the linter to successfully find multiple imports.