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]: unused object in data.table scope #140

Open Gotfrid opened 2 months ago

Gotfrid commented 2 months ago

box.linters version

0.10.2

Sample source code to lint

threshold <- 0.5
data <- data.table::data.table(value = c(0.3, 0.6))
data[, color_level := ifelse(value <= threshold, 1, 0)]

Lint command used

rhino::lint_r()

Lint result

app/logic/utils.R:39:10: warning: [unused_declared_object_linter] Declared function/object unused.
  data[, color_level := ifelse(value <= threshold, 1, 0)]
         ^~~~~~~~~~~

Expected result

No linter issues.

shahreyar-abeer commented 2 months ago

Hi,

I'd like to report a similar issue with the dot(.) operator in {data.table}

box.linters version

0.10.0

sample source code to lint

box::use(
  data.table[data.table, ],
)

d1 <- data.table(v = 1:9)
d1[, .(sum(v))]

lint result

Line 6 [box_usage_linter] Function not imported nor defined.

expected result

No linter issues
radbasa commented 2 months ago

This looks like custom special handlers for {data.table} are needed.