You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Spurious snake_case error when using $ in assignment #582
get_deseq_dataset.R:60:17: style: Variable and function name style should be snake_case.
tx2gene$TXNAME <- sub("^transcript:", "", tx2gene$TXNAME)
^~~~~~
@russHydeTXNAME is not the variable name though, tx2gene is. TXNAME is used with the $ operator to subset a data.frame column by name, it is equivalent to tx2gene[["TXNAME"]] , which lints fine.
Column names are often coming from third-party libraries, so I'd suggest to lint only the variable name (i.e. stop at the $).
Sorry, I hope it didn't sound glib. It's a difficult call whether subelements of a list/data.frame are variables, since they define variables that are nested in an environment defined by the top-level variable.
It might need quite a bit of thought to make lintr distinguish linting when i) assigning to top-level variables from ii) assigning to their subelements.
If it were possible, and accepting that there are some people who would want the subelement names to be linted by object_name_linter how should the linter API work?
# ? something like this ?
my_linter <- object_name_linter(case = "snake_case", lint_subelements = FALSE)
lint(my_file, linters = list(snake_case_linter = my_linter))
Activity
russHyde commentedon Nov 24, 2020
Since TXNAME is all caps, rather than in snake_case, the linter seems to be functioning correctly here.
nsoranzo commentedon Nov 24, 2020
@russHyde
TXNAMEis not the variable name though,tx2geneis.TXNAMEis used with the$operator to subset a data.frame column by name, it is equivalent totx2gene[["TXNAME"]], which lints fine.Column names are often coming from third-party libraries, so I'd suggest to lint only the variable name (i.e. stop at the
$).russHyde commentedon Nov 24, 2020
Sorry, I hope it didn't sound glib. It's a difficult call whether subelements of a list/data.frame are variables, since they define variables that are nested in an environment defined by the top-level variable.
It might need quite a bit of thought to make lintr distinguish linting when i) assigning to top-level variables from ii) assigning to their subelements.
If it were possible, and accepting that there are some people who would want the subelement names to be linted by
object_name_linterhow should the linter API work?It's a bit verbose but could be thought about.
Skip lintr on some spurrious errors
AshesITR commentedon Feb 15, 2021
#759 contains the XPath necessary to disambiguate symbols used in OP-DOLLAR contexts vs. as variable names.
Ignore symbols used for subsetting in `object_name_linter`
Ignore symbols used for subsetting in `object_name_linter`
Ignore symbols used for subsetting in `object_name_linter` (#765)
Skip lintr on spurious error