-
Notifications
You must be signed in to change notification settings - Fork 186
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into which_grepl
- Loading branch information
Showing
28 changed files
with
447 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#' Block usage of print() for logging | ||
#' | ||
#' The default print method for character vectors is appropriate for interactively inspecting objects, | ||
#' not for logging messages. Thus checked-in usage like `print(paste('Data has', nrow(DF), 'rows.'))` | ||
#' is better served by using [cat()], e.g. `cat(sprintf('Data has %d rows.\n', nrow(DF)))` (noting that | ||
#' using `cat()` entails supplying your own line returns, and that [glue::glue()] might be preferable | ||
#' to [sprintf()] for constructing templated strings). Lastly, note that [message()] differs slightly | ||
#' from `cat()` in that it prints to `stderr` by default, not `stdout`, but is still a good option | ||
#' to consider for logging purposes. | ||
#' | ||
#' @examples | ||
#' # will produce lints | ||
#' lint( | ||
#' text = "print('a')", | ||
#' linters = print_linter() | ||
#' ) | ||
#' | ||
#' lint( | ||
#' text = "print(paste(x, 'y'))", | ||
#' linters = print_linter() | ||
#' ) | ||
#' | ||
#' # okay | ||
#' lint( | ||
#' text = "print(x)", | ||
#' linters = print_linter() | ||
#' ) | ||
#' | ||
#' @evalRd rd_tags("print_linter") | ||
#' @seealso [linters] for a complete list of linters available in lintr. | ||
#' @export | ||
print_linter <- make_linter_from_xpath( | ||
xpath = " | ||
//SYMBOL_FUNCTION_CALL[text() = 'print'] | ||
/parent::expr | ||
/parent::expr[expr[2][ | ||
STR_CONST | ||
or expr/SYMBOL_FUNCTION_CALL[ | ||
text() = 'paste' or text() = 'paste0' or text() = 'sprintf' | ||
] | ||
]] | ||
", | ||
lint_message = | ||
"Use cat() instead of print() logging messages. Use message() in cases calling for a signalled condition." | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.