trailing_whitespace_style {roger} | R Documentation |
Validation of Trailing Whitespace
Description
Check that a script file does not contain unnecessary whitespace at the end of lines.
Usage
trailing_whitespace_style(srcData)
Arguments
srcData |
a list as returned by |
Details
Good coding practices dictate that a script file should contain unnecessary whitespace (space or tabulation) at the end of lines.
Value
Boolean. When FALSE
, a message indicates the nature of
the error and the faulty lines, and the returned value has the
following attributes:
lines |
faulty line numbers; |
message |
text of the error message. |
Examples
## Keep parse data in non interactive sessions.
if (!interactive())
op <- options(keep.source = TRUE)
## Correct script without trailing whitespace
fil <- tempfile(fileext = ".R")
cat("## A simple function",
"foo <- function(x, y)",
"{",
" x + y",
"}",
file = fil, sep = "\n")
trailing_whitespace_style(getSourceData(fil))
## Incorrect script with trailing whitespace
fil <- tempfile(fileext = ".R")
cat("## A simple function",
"foo <- function(x, y)",
"{ ",
" x + y",
"}\t",
file = fil, sep = "\n")
trailing_whitespace_style(getSourceData(fil))
[Package roger version 1.5-1 Index]