Skip to content

Commit f4342ae

Browse files
committed
correct and adjust coverage a little
1 parent f9468ae commit f4342ae

File tree

7 files changed

+45
-42
lines changed

7 files changed

+45
-42
lines changed

ChangeLog

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@
55

66
* .github/workflows/stale.yaml: Run weekly instead of daily
77

8+
* src/attributes.cpp: Additional #nocov tag(s)
9+
* R/Attributes.R: Idem
10+
* R/Module.R: Idem
11+
* R/Rcpp.package.skeleton.R: Idem
12+
* R/RcppClass.R: Idem
13+
* R/RcppLdpath.R: Idem
14+
815
2021-01-14 Dirk Eddelbuettel <[email protected]>
916

1017
* DESCRIPTION (Date, Version): Release 1.0.6

R/Attributes.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
# Copyright (C) 2012 - 2020 JJ Allaire, Dirk Eddelbuettel and Romain Francois
2+
# Copyright (C) 2012 - 2021 JJ Allaire, Dirk Eddelbuettel and Romain Francois
33
#
44
# This file is part of Rcpp.
55
#
@@ -437,7 +437,7 @@ compileAttributes <- function(pkgdir = ".", verbose = getOption("verbose")) {
437437
# create R directory if it doesn't already exist
438438
rDir <- file.path(pkgdir, "R")
439439
if (!file.exists(rDir))
440-
dir.create(rDir)
440+
dir.create(rDir) # #nocov
441441

442442
# remove the old RcppExports.R file
443443
unlink(file.path(rDir, "RcppExports.R"))

R/Module.R

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (C) 2010 - 2016 John Chambers, Dirk Eddelbuettel and Romain Francois
1+
# Copyright (C) 2010 - 2021 John Chambers, Dirk Eddelbuettel and Romain Francois
22
#
33
# This file is part of Rcpp.
44
#
@@ -160,11 +160,11 @@ cpp_object_maker <- function(typeid, pointer){
160160
}
161161

162162
Module <- function( module, PACKAGE = methods::getPackageName(where), where = topenv(parent.frame()), mustStart = FALSE ) {
163-
if(inherits(module, "DLLInfo") && missing(mustStart)) mustStart <- TRUE
164-
if(inherits(module, "Module")) {
163+
if (inherits(module, "DLLInfo") && missing(mustStart)) mustStart <- TRUE # #nocov
164+
if (inherits(module, "Module")) {
165165
xp <- .getModulePointer(module, FALSE)
166166
if(!missing(PACKAGE))
167-
warning("ignoring PACKAGE argument in favor of internal package from Module object")
167+
warning("ignoring PACKAGE argument in favor of internal package from Module object") # #nocov
168168
env <- as.environment(module) # not needed from R 2.12.0
169169
PACKAGE <- get("packageName", envir = env)
170170
moduleName <- get("moduleName", envir = env)
@@ -229,12 +229,12 @@ Module <- function( module, PACKAGE = methods::getPackageName(where), where = to
229229
# just to make codetools happy
230230
.self <- .refClassDef <- NULL
231231
generator$methods(initialize =
232-
if(cpp_hasDefaultConstructor(CLASS))
232+
if (cpp_hasDefaultConstructor(CLASS))
233233
function(...) Rcpp::cpp_object_initializer(.self,.refClassDef, ...)
234234
else
235235
function(...) {
236-
if(nargs()) Rcpp::cpp_object_initializer(.self,.refClassDef, ...)
237-
else Rcpp::cpp_object_dummy(.self, .refClassDef)
236+
if (nargs()) Rcpp::cpp_object_initializer(.self,.refClassDef, ...)
237+
else Rcpp::cpp_object_dummy(.self, .refClassDef) # #nocov
238238
}
239239
)
240240
rm( .self, .refClassDef )

R/Rcpp.package.skeleton.R

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (C) 2009 - 2020 Dirk Eddelbuettel and Romain Francois
1+
# Copyright (C) 2009 - 2021 Dirk Eddelbuettel and Romain Francois
22
#
33
# This file is part of Rcpp.
44
#
@@ -33,7 +33,7 @@ Rcpp.package.skeleton <- function(name = "anRpackage", list = character(),
3333
env <- parent.frame(1)
3434

3535
if (!is.character(cpp_files))
36-
stop("'cpp_files' must be a character vector")
36+
stop("'cpp_files' must be a character vector") # #nocov
3737

3838
if (!length(list)) {
3939
fake <- TRUE
@@ -46,12 +46,12 @@ Rcpp.package.skeleton <- function(name = "anRpackage", list = character(),
4646
}
4747
} else {
4848
if (example_code && !isTRUE(attributes)) {
49-
if (!"rcpp_hello_world" %in% list) {
49+
if (!"rcpp_hello_world" %in% list) { # #nocov start
5050
assign( "rcpp_hello_world", function() {}, envir = env)
5151
call[["list"]] <- as.call(c(as.name("c"),
5252
as.list(c("rcpp_hello_world", list))))
5353
}
54-
remove_hello_world <- TRUE
54+
remove_hello_world <- TRUE # #nocov end
5555
} else {
5656
remove_hello_world <- FALSE
5757
}
@@ -69,7 +69,7 @@ Rcpp.package.skeleton <- function(name = "anRpackage", list = character(),
6969
}
7070

7171
tryCatch(eval(call, envir = env), error = function(e){
72-
stop(sprintf("error while calling `package.skeleton` : %s", conditionMessage(e)))
72+
stop(sprintf("error while calling `package.skeleton` : %s", conditionMessage(e))) # #nocov
7373
})
7474

7575
message("\nAdding Rcpp settings")
@@ -103,7 +103,7 @@ Rcpp.package.skeleton <- function(name = "anRpackage", list = character(),
103103
if (getRversion() >= "3.4.0") {
104104
lines <- c(sprintf( "useDynLib(%s, .registration=TRUE)", name), lines)
105105
} else {
106-
lines <- c(sprintf( "useDynLib(%s)", name), lines)
106+
lines <- c(sprintf( "useDynLib(%s)", name), lines) # #nocov
107107
}
108108
writeLines(lines, con = ns)
109109
message(" >> added useDynLib directive to NAMESPACE" )
@@ -124,7 +124,7 @@ Rcpp.package.skeleton <- function(name = "anRpackage", list = character(),
124124
if (havePkgKitten) { # if pkgKitten is available, use it
125125
pkgKitten::playWithPerPackageHelpPage(name, path, maintainer, email)
126126
} else {
127-
.playWithPerPackageHelpPage(name, path, maintainer, email)
127+
.playWithPerPackageHelpPage(name, path, maintainer, email) # #nocov
128128
}
129129

130130
## lay things out in the src directory
@@ -135,9 +135,9 @@ Rcpp.package.skeleton <- function(name = "anRpackage", list = character(),
135135
skeleton <- system.file("skeleton", package = "Rcpp")
136136

137137
if (length(cpp_files) > 0L) {
138-
for (file in cpp_files) {
138+
for (file in cpp_files) { # #nocov start
139139
file.copy(file, src)
140-
message(" >> copied ", file, " to src directory" )
140+
message(" >> copied ", file, " to src directory" ) # #nocov end
141141
}
142142
}
143143

@@ -190,7 +190,7 @@ Rcpp.package.skeleton <- function(name = "anRpackage", list = character(),
190190
close(con)
191191
message(" >> created init.c for package registration")
192192
} else {
193-
message(" >> R version older than 3.4.0 detected, so NO file init.c created.")
193+
message(" >> R version older than 3.4.0 detected, so NO file init.c created.") # #nocov
194194
}
195195
}
196196

@@ -232,7 +232,7 @@ Rcpp.package.skeleton <- function(name = "anRpackage", list = character(),
232232
path = ".",
233233
maintainer = "Your Name",
234234
email = "[email protected]") {
235-
root <- file.path(path, name)
235+
root <- file.path(path, name) # #nocov start
236236
helptgt <- file.path(root, "man", sprintf( "%s-package.Rd", name))
237237
helpsrc <- system.file("skeleton", "manual-page-stub.Rd", package="Rcpp")
238238
## update the package description help page
@@ -244,5 +244,5 @@ Rcpp.package.skeleton <- function(name = "anRpackage", list = character(),
244244
lines, fixed = TRUE)
245245
writeLines(lines, helptgt)
246246
}
247-
invisible(NULL)
247+
invisible(NULL) # #nocov end
248248
}

R/RcppClass.R

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (C) 2010 - 2012 John Chambers, Dirk Eddelbuettel and Romain Francois
1+
# Copyright (C) 2010 - 2021 John Chambers, Dirk Eddelbuettel and Romain Francois
22
#
33
# This file is part of Rcpp.
44
#
@@ -26,8 +26,8 @@ setRcppClass <- function(Class, CppClass,
2626
...) {
2727
myCall <- match.call()
2828
myCall[[1]] <- quote(Rcpp::loadRcppClass)
29-
if(!missing(module) && moduleIsLoaded(module, where)) # eval now
30-
eval.parent(myCall)
29+
if (!missing(module) && moduleIsLoaded(module, where)) # eval now
30+
eval.parent(myCall) # #nocov
3131
else {
3232
f <- function(NS)NULL
3333
myCall$where = as.name("NS")
@@ -46,20 +46,20 @@ loadRcppClass <- function(Class, CppClass = Class,
4646
...) {
4747

4848
if(isBotchedSession()) {
49-
value <- setRefClass(Class, fields = fields, methods = methods, contains = contains, where = where, ...) # kludge -- see loadModule.R
49+
value <- setRefClass(Class, fields = fields, methods = methods, contains = contains, where = where, ...) # kludge -- see loadModule.R #nocov start
5050
if(is.character(saveAs) && length(saveAs) == 1)
5151
assign(saveAs, value, envir = where)
52-
return(value)
52+
return(value) # #nocov end
5353
}
5454
mod <- loadModule(module, NULL, env = where, loadNow = TRUE)
5555
storage <- get("storage", envir = as.environment(mod))
5656
if(exists(Class, envir = storage, inherits = FALSE)) {
5757
cppclassinfo <- get(Class, envir = storage)
5858
if(!is(cppclassinfo, "C++Class"))
59-
stop(gettextf("Object \"%s\" in module \"%s\" is not a C++ class description", Class, module))
59+
stop(gettextf("Object \"%s\" in module \"%s\" is not a C++ class description", Class, module)) # #nocov
6060
}
6161
else
62-
stop(gettextf("No object \"%s\" in module \"%s\"", Class, module))
62+
stop(gettextf("No object \"%s\" in module \"%s\"", Class, module)) # #nocov
6363
allmethods <- .makeCppMethods(methods, cppclassinfo, where)
6464
allfields <- .makeCppFields(fields, cppclassinfo, where)
6565
value <- setRefClass(Class, fields = allfields,
@@ -124,7 +124,7 @@ loadRcppClass <- function(Class, CppClass = Class,
124124
cppArgs <- !nzchar(argNames)
125125
.CppObject <<- do.call(.CppGenerator$new, args[cppArgs])
126126
for(i in seq_along(args)[!cppArgs])
127-
field(argNames[[i]], args[[i]])
127+
field(argNames[[i]], args[[i]]) # #nocov
128128
}
129129
),
130130
fields = list(
@@ -135,7 +135,7 @@ loadRcppClass <- function(Class, CppClass = Class,
135135

136136
.RcppClass$methods(show = function ()
137137
{
138-
cat("Rcpp class object of class ", classLabel(class(.self)),
138+
cat("Rcpp class object of class ", classLabel(class(.self)), # #nocov start
139139
"\n", sep = "")
140140
fields <- names(.refClassDef@fieldClasses)
141141
if(".CppObject" %in% fields) {
@@ -150,8 +150,5 @@ loadRcppClass <- function(Class, CppClass = Class,
150150
}
151151
},
152152
objectPointer = function()
153-
.CppObject$.pointer
153+
.CppObject$.pointer # #nocov end
154154
)
155-
156-
157-

R/RcppLdpath.R

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (C) 2010 - 2018 Dirk Eddelbuettel and Romain Francois
1+
# Copyright (C) 2010 - 2021 Dirk Eddelbuettel and Romain Francois
22
#
33
# This file is part of Rcpp.
44
#
@@ -50,7 +50,7 @@ RcppCxxFlags <- function(cxx0x=FALSE) {
5050
# path <- RcppLdPath()
5151
path <- Rcpp.system.file( "include" )
5252
if (.Platform$OS.type=="windows") {
53-
path <- asBuildPath(path)
53+
path <- asBuildPath(path) # #nocov
5454
}
5555
paste("-I", path, if (cxx0x && canUseCXX0X()) " -std=c++0x" else "", sep="")
5656
}
@@ -60,7 +60,7 @@ RcppCxxFlags <- function(cxx0x=FALSE) {
6060
CxxFlags <- function(cxx0x=FALSE) {
6161
#.Deprecated(msg=paste("This function is now deprecated as R uses minimally",
6262
# "viable compilers om all platforme."))
63-
cat(RcppCxxFlags(cxx0x=cxx0x))
63+
cat(RcppCxxFlags(cxx0x=cxx0x)) # #nocov
6464
}
6565

6666
## LdFlags defaults to static linking on the non-Linux platforms Windows and OS X
@@ -76,11 +76,11 @@ RcppCapabilities <- capabilities <- function() .Call( rcpp_capabilities )
7676
RcppCxx0xFlags <- function() {
7777
#.Deprecated(msg=paste("This function is now deprecated as R uses minimally",
7878
# "viable compilers om all platforme."))
79-
script <- Rcpp.system.file( "discovery", "cxx0x.R" )
79+
script <- Rcpp.system.file( "discovery", "cxx0x.R" ) # #nocov start
8080
flag <- capture.output( source( script ) )
8181
flag
8282
}
8383

8484
Cxx0xFlags <- function() {
85-
cat( RcppCxx0xFlags() )
85+
cat( RcppCxx0xFlags() ) # #nocov end
8686
}

src/attributes.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; indent-tabs-mode: nil; -*-
21
//
32
// attributes.cpp: Rcpp R/C++ interface class library -- Rcpp attributes
43
//
5-
// Copyright (C) 2012 - 2017 JJ Allaire, Dirk Eddelbuettel and Romain Francois
4+
// Copyright (C) 2012 - 2021 JJ Allaire, Dirk Eddelbuettel and Romain Francois
65
//
76
// This file is part of Rcpp.
87
//
@@ -919,7 +918,7 @@ namespace attributes {
919918
for (size_t i = 0; i<exts.size(); ++i) {
920919

921920
// look for corresponding cpp file and add it
922-
std::string file = Rcpp::as<std::string>(
921+
std::string file = Rcpp::as<std::string>( // #nocov
923922
filePathSansExt(include)) + exts[i];
924923

925924
exists = fileExists(file);

0 commit comments

Comments
 (0)