lintr
lintr copied to clipboard
sprintf_linter() for 1-argument calls?
Is there any reason not to lint this?
# known string
sprintf(paste0(x, y))
# assumed string
sprintf(foo())
We already lint the literal version:
lint(text = "sprintf('a')", linters = sprintf_linter())
# <text>:1:1: warning: [sprintf_linter] sprintf call can be removed when a constant string is provided.
# sprintf('a')
# ^~~~~~~~~~~~
Not that I can think off. The first I've definitely done by accident whilst refactoring so would be nice to catch.
Is there a way to inject NSE there? Something like:
df |> mutate(a = sprintf(!!!args))
Also, beware of bquote() for similar use cases.
Is there a way to inject NSE there?
I suppose that could work, though I don't see anyone doing it:
https://github.com/search?q=lang%3AR+%2Fsprintf%5B%28%5D%5B+%5Cn%5D*%5B%21%5D%5B%21%5D%5B%21%5D%2F&type=code