lintr icon indicating copy to clipboard operation
lintr copied to clipboard

More glue fails and sneak case

Open latot opened this issue 1 year ago • 1 comments

Hi, I was running linting and found this:

test.R

df <- data.frame(list(
a = c(1, 2, 3)
))

v <- "a"

dplyr::mutate(df, !!paste0(tolower(v), "_l") := df$a * 2)

The output of the linting:

test.r:7:31: style: [object_name_linter] Variable and function name style should be snake_case or symbols.
dplyr::mutate(df, !!paste0(v, "_l") := df$a * 2)

Thx!

latot avatar Jul 22 '22 21:07 latot

Reprex:

library(lintr)

df <- dplyr::tibble(a = c(1))
v <- "a"

dplyr::mutate(df, !!paste0(tolower(v), "_l") := df$a * 2)
#> # A tibble: 1 × 2
#>       a   a_l
#>   <dbl> <dbl>
#> 1     1     2

lint(
  text = 'dplyr::mutate(df, !!paste0(v, "_l") := df$a * 2)',
  linter = object_name_linter()
)
#> <text>:1:31: style: [object_name_linter] Variable and function name style should be snake_case or symbols.
#> dplyr::mutate(df, !!paste0(v, "_l") := df$a * 2)
#>                               ^~~~

Created on 2022-07-24 by the reprex package (v2.0.1)

IndrajeetPatil avatar Jul 24 '22 13:07 IndrajeetPatil