* using log directory 'd:/Rcompile/CRANpkg/local/4.1/roger.Rcheck' * using R version 4.1.3 (2022-03-10) * using platform: x86_64-w64-mingw32 (64-bit) * using session charset: ISO8859-1 * checking for file 'roger/DESCRIPTION' ... OK * checking extension type ... Package * this is package 'roger' version '1.4-0' * package encoding: UTF-8 * checking package namespace information ... OK * checking package dependencies ... OK * checking if this is a source package ... OK * checking if there is a namespace ... OK * checking for hidden files and directories ... OK * checking for portable file names ... OK * checking whether package 'roger' can be installed ... OK * checking installed package size ... OK * checking package directory ... OK * checking DESCRIPTION meta-information ... OK * checking top-level files ... OK * checking for left-over files ... OK * checking index information ... OK * checking package subdirectories ... OK * checking R files for non-ASCII characters ... OK * checking R files for syntax errors ... OK * checking whether the package can be loaded ... OK * checking whether the package can be loaded with stated dependencies ... OK * checking whether the package can be unloaded cleanly ... OK * checking whether the namespace can be loaded with stated dependencies ... OK * checking whether the namespace can be unloaded cleanly ... OK * checking loading without being on the library search path ... OK * checking use of S3 registration ... OK * checking dependencies in R code ... OK * checking S3 generic/method consistency ... OK * checking replacement functions ... OK * checking foreign function calls ... OK * checking R code for possible problems ... [5s] OK * checking Rd files ... [1s] OK * checking Rd metadata ... OK * checking Rd cross-references ... OK * checking for missing documentation entries ... OK * checking for code/documentation mismatches ... OK * checking Rd \usage sections ... OK * checking Rd contents ... OK * checking for unstated dependencies in examples ... OK * checking examples ... [1s] OK * checking for unstated dependencies in 'tests' ... OK * checking tests ... [2s] ERROR Running 'documentation-tests.R' [0s] Running 'getParseFun-tests.R' [0s] Running 'getParseParent-tests.R' [0s] Running 'interface-tests.R' [0s] Running 'style-tests.R' [0s] Running the tests in 'tests/style-tests.R' failed. Complete output: > ### roger: Automated grading of R scripts > ### > ### Tests for the validity of the style linters. > ### > ### AUTHORS: Jean-Christophe Langlois, Vincent Goulet > ### LICENSE: GPL 2 or later. > > library(roger) > > ## Tests are run by R CMD check in a non interactive session where > ## parse data is thrown out by default. > if (!interactive()) + options(keep.source = TRUE) > > ### > ### Tests for code free of style errors > ### > > ## General expressions > VALID_STYLE_FILE <- tempfile(fileext = ".R") > cat( + "## Correct use of left assign token", + "x <- 2", + "y <- 3", + "z <- c(42, 43)", + "", + "## Correct use of spacing", + ## Operators + "x + y", + "x - y", + "x > y", + "x >= y", + "x < y", + "x <= y", + "x == y", + "x != y", + "x & y", + "x | y", + "x && y", + "x || y", + "c(42, 43) -> z", + "x %% y", + "x %*% y", + "x * y", + "x/y", # this one does not need surrounding spaces + "x^y", # this one does not need surrounding spaces + "x +", + "y", + "z[1", + "< 2]", + "x <- -2", + "2 + !TRUE", + "", + ## Parentheses + "sum(x)", + "1 + (x + y)", + "1 + ((x + y) * z)", + "1 + (z/(x + y))", + "1 + (z^(x + y))", + "1 + (sum(1:10))", + "1 + ((sum(1:10)))", + "if (x > 0) x + y", + "for (i in seq_along(z)) x[i] <- x[i] + 2", + "while (x < 2) x + 2", + "switch(2, 2 + 2, c(sum(x), diff(z)))", + "foo <- function(x) x^2", + "", + ## Square brackets + "z[1]", + "U <- matrix(1:4, ncol = 2)", + "U[2, ]", + "", + ## Commas + "paste('Hello',", + " ' World')", + "A <- array(24, 2:4)", + "A[1, , ]", + "A[, 1, ]", + "A[, , 1]", + "A[1, 1, ]", + "A[1, , 1]", + "A[, 1, 1]", + ## Trailing whitespace + "## There should be no whitespaces at the end of a line", + "", + ## Trailing blank lines + "## There should be no trailing blank lines in a file", + file = VALID_STYLE_FILE, sep = "\n") > VALID_STYLE <- getSourceData(VALID_STYLE_FILE) > > ## R bracing style > VALID_BRACE_R_FILE <- tempfile(fileext = ".R") > cat( + "## Correct use of R style for braces", + "foo <- function(x, y)", + "{", + " if (x > 2)", + " {", + " x^2 + y^3", + " }", + " else", + " {", + " z <- 3", + " x^2 + y^3 + z^4", + " }", + "", + " {", + " 2 + 3", + " }", + "}", + "", + "function(x, y)", + "{", + " 2 + 3", + "}", + "", + "{", + " 2 + 3", + "}", + file = VALID_BRACE_R_FILE, sep = "\n") > VALID_BRACE_R <- getSourceData(VALID_BRACE_R_FILE) > > ## 1TBS bracing style > VALID_BRACE_1TBS_FILE <- tempfile(fileext = ".R") > cat( + "## Correct use of 1TBS style for braces", + "bar <- function(x, y = 42) {", + " if (x < y) {", + " x + y", + " } else {", + " x - y", + " }", + "}", + "", + "function(x, y) {", + " 2 + 3", + "}", + file = VALID_BRACE_1TBS_FILE, sep = "\n") > VALID_BRACE_1TBS <- getSourceData(VALID_BRACE_1TBS_FILE) > > ## Comments > VALID_COMMENTS_FILE <- tempfile(fileext = ".R") > cat(file = VALID_COMMENTS_FILE, ' + ### comment + 2 + 3 # comment + 42 ## 42 + a ### a + ## + ## a + #! + #! a + #" + #" a + #$ + #$ a + #% + #% a + #& + #& a + #( + #( a + #) + #) a + #* + #* a + #+ + #+ a + #, + #, a + #- + #- a + #. + #. a + #/ + #/ a + #: + #: a + #; + #; a + #< + #< a + #= + #= a + #> + #> a + #? + #? a + #@ + #@ a + #[ + #[ a + #\ + #\ a + #] + #] a + #^ + #^ a + #_ + #_ a + #` + #` a + #{ + #{ a + #| + #| a + #} + #} a + #~ + #~ a + ') > VALID_COMMENTS <- getSourceData(VALID_COMMENTS_FILE) > > ## Magic numbers > VALID_NOMAGIC_FILE <- tempfile(fileext = ".R") > cat( + "SIZE <- 42", + "BAR <- 2^32", + "BAZ <- 2^32 - 1", + "FOOBAR0 <- 1234", + "FOO_BAR42 <- 32 - 1", + "FOO.BAR.1 <- 32 - 1", + "BÉBÉ <- 42", + "ÇA_1 <- 32 - 1", + "ÌÀÙ.2 <- 2^32 - 1", + "42 -> SIZE", + "32 - 1 -> ÇA_1", + "2^32 - 1 -> ÌÀÙ.2", + "", + "x <- rnorm(SIZE)", + "x[1]", + "x[1] * 2", + "x[33]", + "x[-1] - x[-SIZE] == -1L", + "x * 100", + "for (i in 1:SIZE) x[1]", + "x <- numeric(0)", + "", + "x <- Inf", + "x <- NA", + "x <- NaN", + file = VALID_NOMAGIC_FILE, sep = "\n") > VALID_NOMAGIC <- getSourceData(VALID_NOMAGIC_FILE) Error in parse(file, encoding = encoding, keep.source = keep.source) : D:\temp\RtmpQz0kqK\filea43877a0715a.R:7:2: unexpected input 6: FOO.BAR.1 <- 32 - 1 7: BÉ ^ Calls: getSourceData -> getParseData -> parse Execution halted * checking PDF version of manual ... OK * DONE Status: 1 ERROR