Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add arg to skip with() in object_usage_linter() #1548

Merged
merged 10 commits into from
Sep 25, 2022
Merged

Conversation

IndrajeetPatil
Copy link
Collaborator

@IndrajeetPatil IndrajeetPatil commented Sep 22, 2022

Closes #1458

Example

library(lintr)

f <- tempfile()
writeLines(
  "test_fun <- function(df) {
      with(df, first_var + second_var)
     }",
  f
)

lint(f, object_usage_linter(skip_with = TRUE))

lint(f, object_usage_linter(skip_with = FALSE))
#> /private/var/folders/xr/v_vddzvs33q5wg7jv9mr__4h0000gn/T/Rtmp1OPl2d/file1557f756350e9:2:16: warning: [object_usage_linter] no visible binding for global variable 'first_var'
#>       with(df, first_var + second_var)
#>                ^~~~~~~~~
#> /private/var/folders/xr/v_vddzvs33q5wg7jv9mr__4h0000gn/T/Rtmp1OPl2d/file1557f756350e9:2:28: warning: [object_usage_linter] no visible binding for global variable 'second_var'
#>       with(df, first_var + second_var)
#>                            ^~~~~~~~~~

Created on 2022-09-22 with reprex v2.0.2

P.S. A few .Rd changes are remnants of #1539, I think.

@AshesITR
Copy link
Collaborator

Isn't R CMD checks default skipWith = TRUE? Are there valid usages of with() that don't produce false positives?

@IndrajeetPatil
Copy link
Collaborator Author

@AshesITR You are right; I have changed the default for skip_with to TRUE, since setting is to FALSE is rarely going to not produce a false positive.

I also made some changes to the docs to close #941. The rest of the todos in that issue already seem to have been handled.

IndrajeetPatil added a commit that referenced this pull request Sep 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

option to disable the object_usage_linter inside with expressions
3 participants