Appsilon / box.linters

lintr-compatible linters for box modules in R
https://appsilon.github.io/box.linters/
10 stars 0 forks source link

[LINT_BUG]: Module linter not properly reading short path/module #87

Closed radbasa closed 4 months ago

radbasa commented 4 months ago

box.linters version

0.9.0

Sample source code to lint

box::use(
  shiny[testServer],
  testthat[expect_true, test_that],
)
box::use(
  app/main[server],
)

test_that("main server works", {
  testServer(server, {
    expect_true(grepl(x = output$message$html, pattern = "Check out Rhino docs!"))
  })
})

Lint command used

lintr::lint("tests/testthat/test-main.R", linters = box.linters::box_unused_attached_mod_linter())

Lint result

Error: Linter 'box.linters::box_unused_attached_mod_linter' failed in /Users/radbasa/_dev/appsilon/rhino/tests/e2e/Rhinoapp/tests/testthat/test-main.R: invalid subscript type 'list'

Expected result

This should not lint

radbasa commented 4 months ago

This is a bug in get_attached_modules(). The function to get modules imported whole. It works as expected if the module path is two/folders/module[server]. It has problems with folder/module[server].

radbasa commented 4 months ago

attached_modules in get_attached_modules() was returning

app/main[server]$ui app/main[server]$server

app/main[server] should not be seen by get_attached_modules() in the first place because it should only see modules attached in whole.