Repository navigation
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 usedlint(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
|
MichaelChirico
left a comment
There was a problem hiding this comment.
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 usedAlso 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