lintr
lintr copied to clipboard
New `return_linter` to enforce consistent return style
Tidyverse expects implicit returns, so those should be the default.
Basically check that the last expr in all function definitions is a) never a return() or b) always a return().
Signature could maybe be return_linter(use_implicit_returns = TRUE)
?
The google linters introduced a bunch of these (grep return\(lapply\( R/*.R
)
these are coming from Google having the opposite policy which is always to have explicit returns.
in fact ExplicitReturnLinter is part of the extended suite (explicitly tabled because of this conflicting issue), so we can work the new option into the implementation there.
This would be a great addition. Happy to help beta test.
Seconding the ask here, would definitely find this linter useful!
FYI @mjsteinbaugh and @givison there's a pending version in #2271
Thanks @MichaelChirico I'll check it out!