-
Notifications
You must be signed in to change notification settings - Fork 187
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
Fix parsing usage warnings from codetools without location info #1993
Conversation
There is still one ugly edge case, but I fear it will be very hard to properly fix: codetools::checkUsage({
foo <- function() a <-
bar()
})
# This one will fail to find col1 because the symbol is on line 2:
# <anonymous>: no visible global function definition for ‘bar’
# This one is fixed by the PR:
# <anonymous>: local variable ‘a’ assigned but may not be used lint(text = "foo <- function() a <-\n bar()", linters = object_usage_linter())
#> <text>:1:19: warning: [object_usage_linter] no visible global function definition for 'bar'
#> foo <- function() a <-
#> ^
#> <text>:1:19: warning: [object_usage_linter] local variable 'a' assigned but may not be used
#> foo <- function() a <-
#> ^ |
Codecov Report
@@ Coverage Diff @@
## main #1993 +/- ##
=======================================
Coverage 98.55% 98.55%
=======================================
Files 113 113
Lines 4993 4999 +6
=======================================
+ Hits 4921 4927 +6
Misses 72 72
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice! lazy matching... my Achilles heel!
it looks like this may have popped new lints in quotes_linter()?
Interesting. On current main, we see a warning as expected: lintr::lint("R/quotes_linter.R", linters = object_usage_linter())
#> Warning in parse_check_usage(fun, known_used_symbols = known_used_symbols, :
#> Possible bug in lintr: Couldn't parse usage message ‘<anonymous> : <anonymous> : <anonymous>: local variable 'col2' assigned but may not be used Also seeing a warning in lint-changed-files: Linter consecutive_stopifnot_linter was deprecated in lintr version 3.1.0. Use consecutive_assertion_linter instead. |
Thinking about the lint in R/quotes_linter.R actually helped me find a solution for the multi-line edge case I presented above 🥳 |
also fixes #1917 |
Fixes #1986, Fixes #1917