Skip to content

Commit

Permalink
Initial handling of 'if (reset) x <- 0; x + 1' [#31]
Browse files Browse the repository at this point in the history
  • Loading branch information
HenrikBengtsson committed Dec 30, 2017
1 parent 46a8728 commit 49ec7c9
Showing 1 changed file with 115 additions and 8 deletions.
123 changes: 115 additions & 8 deletions R/findGlobals.R
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ find_globals_liberal <- function(expr, envir, ..., trace = FALSE) {


#' @importFrom codetools makeUsageCollector walkCode
find_globals_ordered <- function(expr, envir, ..., trace = FALSE) {
find_nnn_ordered <- function(expr, envir, unique = TRUE, ..., trace = FALSE) {
class <- name <- character()

enter_local <- function(type, v, e, w) {
Expand All @@ -85,9 +85,9 @@ find_globals_ordered <- function(expr, envir, ..., trace = FALSE) {
class <<- c(class, "global")
name <<- c(name, v)

## Also walk formulas to identify globals
if (type == "function") {
if (v == "~") {
## Also, walk formulas to identify globals
stopifnot(identical(e[[1]], as.symbol("~")))
expr <- e[-1]
for (kk in seq_along(expr)) {
Expand All @@ -97,10 +97,78 @@ find_globals_ordered <- function(expr, envir, ..., trace = FALSE) {
name <<- c(name, globals)
}
}
} else if (v == "if" && getOption("globals.ambiguous", TRUE)) {
## ... and if-else statements
stopifnot(identical(e[[1]], as.symbol("if")))

cond <- e[[2]]
if (is.atomic(cond)) {
cond <- as.logical(cond)
stopifnot(length(cond) == 1L)
} else {
cond <- NA
}

mdebug(" - cond: %d", cond)

if (is.na(cond)) {
## Locals identified in "ambiguous" if-else statements should be
## ignored if following statements contain a global with the same
## name. For example, below 'x' should be considered a global:
## if (NA) x <- 0
## y <- x + 1
expr <- e[-(1:2)]
envir <- w$env

## NB: Suppress any codetools warnings, particularly "... may be
## used in an incorrect context". Those will be detected after
## enter_global() returns, if they exist.
suppressWarnings({
for (kk in seq_along(expr)) {
locals <- find_locals_ordered(expr = expr[[kk]], envir = envir)
if (length(locals) > 0) {
class <<- c(class, rep("local-maybe-global",
times = length(locals)))
name <<- c(name, locals)
}
}
})
} else {
## Locals identified in "constant" if-else statements should be
## treated as is. For example, in:
## if (TRUE) x <- 0
## y <- x + 1
## 'x' should be considered a local variable, whereas in:
## if (FALSE) x <- 0
## y <- x + 1
## 'x' should be considered a global variable.
##
## NB: We suppress any codetools warnings, particularly "... may be
## used in an incorrect context". Those will be detected after
## enter_global() returns, if they exist.
if (cond) {
mdebug(" - expr: %s", paste(capture.output(print(e[[3]])), collapse = "\n"))
suppressWarnings(
globals <- find_globals_ordered(expr = e[[3]], envir = w$env)
)
} else if (length(e) >= 4) {
mdebug(" - expr: %s", paste(capture.output(print(e[[4]])), collapse = "\n"))
suppressWarnings(
globals <- find_globals_ordered(expr = e[[4]], envir = w$env)
)
} else {
globals <- character(0L)
}
mdebug(" - globals: %s", paste(sQuote(globals), collapse = ", "))
if (length(globals) > 0) {
class <<- c(class, rep("global", times = length(globals)))
name <<- c(name, globals)
}
}
}
}
}

## A function or an expression?
if (is.function(expr)) {
if (typeof(expr) != "closure") return(character(0L)) ## e.g. `<-`
Expand All @@ -120,14 +188,52 @@ find_globals_ordered <- function(expr, envir, ..., trace = FALSE) {
walkCode(expr, w)
}

mdebug("find_nnn_ordered():")
mdebug(" - names: [%d] %s", length(name), paste(sQuote(name), collapse = ", "))
mdebug(" - classes: [%d] %s", length(class), paste(sQuote(class), collapse = ", "))

## Drop duplicated names?
if (unique) {
dups <- duplicated(name)
class <- class[!dups]
name <- name[!dups]
}

list(name = name, class = class)
}

find_globals_ordered <- function(expr, ...) {
objs <- find_nnn_ordered(expr, ..., unique = FALSE)
name <- objs[["name"]]
class <- objs[["class"]]

maybes <- unique(name[class == "local-maybe-global"])
if (length(maybes) > 0) {
mdebug("find_globals_ordered():")
mdebug(" - maybes: [%d] %s", length(maybes), paste(sQuote(maybes), collapse = ", "))
mdebug(" - names: [%d] %s", length(name), paste(sQuote(name), collapse = ", "))
mdebug(" - classes: [%d] %s", length(class), paste(sQuote(class), collapse = ", "))

for (nn in maybes) {
midxs <- which(name == nn & class == "local-maybe-global")
gidx <- which(name == nn & class == "global")[1]
class[midxs] <- if (!is.na(gidx)) "global" else "local"
}
mdebug(" - classes: [%d] %s", length(class), paste(sQuote(class), collapse = ", "))
}

## Drop duplicated names
dups <- duplicated(name)
class <- class[!dups]
name <- name[!dups]

unique(name[class == "global"])
name[class == "global"]
}

find_locals_ordered <- function(expr, ...) {
objs <- find_nnn_ordered(expr, ..., unique = TRUE)
objs[["name"]][objs[["class"]] == "local"]
}

#' @export
findGlobals <- function(expr, envir = parent.frame(), ..., tweak = NULL,
Expand All @@ -150,7 +256,7 @@ findGlobals <- function(expr, envir = parent.frame(), ..., tweak = NULL,
substitute = FALSE, unlist = FALSE)

mdebug(" - preliminary globals found: [%d] %s",
length(globals), hpaste(sQuote(names(globals))))
length(globals), hpaste(sQuote(names(globals)), max_head = Inf))

if (unlist) {
needs_dotdotdot <- FALSE
Expand All @@ -169,7 +275,7 @@ findGlobals <- function(expr, envir = parent.frame(), ..., tweak = NULL,
}

mdebug(" - globals found: [%d] %s",
length(globals), hpaste(sQuote(globals)))
length(globals), hpaste(sQuote(globals), max_head = Inf))

mdebug("findGlobals(..., dotdotdot = '%s', method = '%s', unlist = %s) ... DONE", dotdotdot, method, unlist) #nolint
return(globals)
Expand Down Expand Up @@ -223,7 +329,8 @@ findGlobals <- function(expr, envir = parent.frame(), ..., tweak = NULL,

if (needs_dotdotdot) globals <- c(globals, "...")

mdebug(" - globals found: [%d] %s", length(globals), hpaste(sQuote(globals)))
mdebug(" - globals found: [%d] %s", length(globals),
hpaste(sQuote(globals), max_head = Inf))

mdebug("findGlobals(..., dotdotdot = '%s', method = '%s', unlist = %s) ... DONE", dotdotdot, method, unlist) #nolint

Expand Down

1 comment on commit 49ec7c9

@lintr-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

R/cleanup.R:12:1: style: Variable or function name should be snake_case.

cleanup.Globals <- function(globals, drop = c("missing", "base-packages"),
^~~~~~~~~~~~~~~

R/cleanup.R:30:11: warning: no visible global function definition for ‘is_base_pkg’

if (is_base_pkg(environmentName(where[[name]]))) keep[name] <- FALSE
          ^~~~~~~~~~~

R/cleanup.R:44:11: warning: no visible global function definition for ‘is_internal’

if (is_internal(globals[[name]])) keep[name] <- FALSE
          ^~~~~~~~~~~

R/findGlobals.R:17:10: warning: no visible global function definition for ‘makeUsageCollector’

w <- makeUsageCollector(fun, name = "<anonymous>", enterGlobal = enter)
         ^~~~~~~~~~~~~~~~~~

R/findGlobals.R:18:21: warning: no visible global function definition for ‘inject_tracer_to_walker’

if (trace) w <- inject_tracer_to_walker(w)
                    ^~~~~~~~~~~~~~~~~~~~~~~

R/findGlobals.R:19:5: warning: no visible global function definition for ‘collect_usage_function’

​    collect_usage_function(fun, name = "<anonymous>", w)
    ^~~~~~~~~~~~~~~~~~~~~~

R/findGlobals.R:22:12: warning: no visible global function definition for ‘as_function’, Did you mean 'as.function'?

fun <- as_function(expr, envir = envir, ...)
           ^~~~~~~~~~~

R/findGlobals.R:26:10: warning: no visible global function definition for ‘makeUsageCollector’

w <- makeUsageCollector(fun, name = "<anonymous>", enterGlobal = enter)
         ^~~~~~~~~~~~~~~~~~

R/findGlobals.R:28:21: warning: no visible global function definition for ‘inject_tracer_to_walker’

if (trace) w <- inject_tracer_to_walker(w)
                    ^~~~~~~~~~~~~~~~~~~~~~~

R/findGlobals.R:29:1: style: Trailing whitespace is superfluous.

^~~~

R/findGlobals.R:30:15: warning: no visible global function definition for ‘findLocalsList’

locals <- findLocalsList(list(expr))
              ^~~~~~~~~~~~~~

R/findGlobals.R:32:5: warning: no visible global function definition for ‘walkCode’

​    walkCode(expr, w)
    ^~~~~~~~

R/findGlobals.R:50:10: warning: no visible global function definition for ‘makeUsageCollector’

w <- makeUsageCollector(fun, name = "<anonymous>", enterGlobal = enter)
         ^~~~~~~~~~~~~~~~~~

R/findGlobals.R:51:21: warning: no visible global function definition for ‘inject_tracer_to_walker’

if (trace) w <- inject_tracer_to_walker(w)
                    ^~~~~~~~~~~~~~~~~~~~~~~

R/findGlobals.R:52:5: warning: no visible global function definition for ‘collect_usage_function’

​    collect_usage_function(fun, name = "<anonymous>", w)
    ^~~~~~~~~~~~~~~~~~~~~~

R/findGlobals.R:54:12: warning: no visible global function definition for ‘as_function’, Did you mean 'as.function'?

fun <- as_function(expr, envir = envir, ...)
           ^~~~~~~~~~~

R/findGlobals.R:55:10: warning: no visible global function definition for ‘makeUsageCollector’

w <- makeUsageCollector(fun, name = "<anonymous>", enterGlobal = enter)
         ^~~~~~~~~~~~~~~~~~

R/findGlobals.R:56:21: warning: no visible global function definition for ‘inject_tracer_to_walker’

if (trace) w <- inject_tracer_to_walker(w)
                    ^~~~~~~~~~~~~~~~~~~~~~~

R/findGlobals.R:57:5: warning: no visible global function definition for ‘walkCode’

​    walkCode(expr, w)
    ^~~~~~~~

R/findGlobals.R:67:1: style: Trailing whitespace is superfluous.

^~

R/findGlobals.R:87:1: style: Trailing whitespace is superfluous.

^~~~

R/findGlobals.R:94:22: warning: no visible global function definition for ‘find_globals_ordered’

globals <- find_globals_ordered(expr = expr[[kk]], envir = w$env)
                     ^~~~~~~~~~~~~~~~~~~~

R/findGlobals.R:103:1: style: Trailing whitespace is superfluous.

^~~~~~~~

R/findGlobals.R:112:9: warning: no visible global function definition for ‘mdebug’, Did you mean 'debug'?

​        mdebug(" - cond: %d", cond)
        ^~~~~~

R/findGlobals.R:113:1: style: Trailing whitespace is superfluous.

^~~~~~~~

R/findGlobals.R:120:22: style: Place a space before left parenthesis, except in a function call.

expr <- e[-(1:2)]
                     ^

R/findGlobals.R:122:1: style: Trailing whitespace is superfluous.

^~~~~~~~~~

R/findGlobals.R:128:25: warning: no visible global function definition for ‘find_locals_ordered’

locals <- find_locals_ordered(expr = expr[[kk]], envir = envir)
                        ^~~~~~~~~~~~~~~~~~~

R/findGlobals.R:150:1: style: Lines should not be more than 80 characters.

​            mdebug(" - expr: %s", paste(capture.output(print(e[[3]])), collapse = "\n"))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/findGlobals.R:150:13: warning: no visible global function definition for ‘mdebug’, Did you mean 'debug'?

​            mdebug(" - expr: %s", paste(capture.output(print(e[[3]])), collapse = "\n"))
            ^~~~~~

R/findGlobals.R:155:1: style: Lines should not be more than 80 characters.

​            mdebug(" - expr: %s", paste(capture.output(print(e[[4]])), collapse = "\n"))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/findGlobals.R:155:13: warning: no visible global function definition for ‘mdebug’, Did you mean 'debug'?

​            mdebug(" - expr: %s", paste(capture.output(print(e[[4]])), collapse = "\n"))
            ^~~~~~

R/findGlobals.R:162:11: warning: no visible global function definition for ‘mdebug’, Did you mean 'debug'?

​          mdebug(" - globals: %s", paste(sQuote(globals), collapse = ", "))
          ^~~~~~

R/findGlobals.R:171:1: style: Trailing whitespace is superfluous.

^~

R/findGlobals.R:180:21: warning: no visible global function definition for ‘inject_tracer_to_walker’

if (trace) w <- inject_tracer_to_walker(w)
                    ^~~~~~~~~~~~~~~~~~~~~~~

R/findGlobals.R:181:5: warning: no visible global function definition for ‘collect_usage_function’

​    collect_usage_function(fun, name = "<anonymous>", w)
    ^~~~~~~~~~~~~~~~~~~~~~

R/findGlobals.R:183:12: warning: no visible global function definition for ‘as_function’, Did you mean 'as.function'?

fun <- as_function(expr, envir = envir, ...)
           ^~~~~~~~~~~

R/findGlobals.R:187:21: warning: no visible global function definition for ‘inject_tracer_to_walker’

if (trace) w <- inject_tracer_to_walker(w)
                    ^~~~~~~~~~~~~~~~~~~~~~~

R/findGlobals.R:188:5: warning: no visible global function definition for ‘walkCode’

​    walkCode(expr, w)
    ^~~~~~~~

R/findGlobals.R:191:3: warning: no visible global function definition for ‘mdebug’, Did you mean 'debug'?

​  mdebug("find_nnn_ordered():")
  ^~~~~~

R/findGlobals.R:192:1: style: Lines should not be more than 80 characters.

​  mdebug(" - names: [%d] %s", length(name), paste(sQuote(name), collapse = ", "))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/findGlobals.R:192:3: warning: no visible global function definition for ‘mdebug’, Did you mean 'debug'?

​  mdebug(" - names: [%d] %s", length(name), paste(sQuote(name), collapse = ", "))
  ^~~~~~

R/findGlobals.R:193:1: style: Lines should not be more than 80 characters.

​  mdebug(" - classes: [%d] %s", length(class), paste(sQuote(class), collapse = ", "))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/findGlobals.R:193:3: warning: no visible global function definition for ‘mdebug’, Did you mean 'debug'?

​  mdebug(" - classes: [%d] %s", length(class), paste(sQuote(class), collapse = ", "))
  ^~~~~~

R/findGlobals.R:194:1: style: Trailing whitespace is superfluous.

^~

R/findGlobals.R:206:11: warning: no visible global function definition for ‘find_nnn_ordered’

objs <- find_nnn_ordered(expr, ..., unique = FALSE)
          ^~~~~~~~~~~~~~~~

R/findGlobals.R:212:5: warning: no visible global function definition for ‘mdebug’, Did you mean 'debug'?

​    mdebug("find_globals_ordered():")
    ^~~~~~

R/findGlobals.R:213:1: style: Lines should not be more than 80 characters.

​    mdebug(" - maybes: [%d] %s", length(maybes), paste(sQuote(maybes), collapse = ", "))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/findGlobals.R:213:5: warning: no visible global function definition for ‘mdebug’, Did you mean 'debug'?

​    mdebug(" - maybes: [%d] %s", length(maybes), paste(sQuote(maybes), collapse = ", "))
    ^~~~~~

R/findGlobals.R:214:1: style: Lines should not be more than 80 characters.

​    mdebug(" - names: [%d] %s", length(name), paste(sQuote(name), collapse = ", "))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/findGlobals.R:214:5: warning: no visible global function definition for ‘mdebug’, Did you mean 'debug'?

​    mdebug(" - names: [%d] %s", length(name), paste(sQuote(name), collapse = ", "))
    ^~~~~~

R/findGlobals.R:215:1: style: Lines should not be more than 80 characters.

​    mdebug(" - classes: [%d] %s", length(class), paste(sQuote(class), collapse = ", "))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/findGlobals.R:215:5: warning: no visible global function definition for ‘mdebug’, Did you mean 'debug'?

​    mdebug(" - classes: [%d] %s", length(class), paste(sQuote(class), collapse = ", "))
    ^~~~~~

R/findGlobals.R:216:1: style: Trailing whitespace is superfluous.

^~~~

R/findGlobals.R:222:1: style: Lines should not be more than 80 characters.

​    mdebug(" - classes: [%d] %s", length(class), paste(sQuote(class), collapse = ", "))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

R/findGlobals.R:222:5: warning: no visible global function definition for ‘mdebug’, Did you mean 'debug'?

​    mdebug(" - classes: [%d] %s", length(class), paste(sQuote(class), collapse = ", "))
    ^~~~~~

R/findGlobals.R:229:1: style: Trailing whitespace is superfluous.

^~

R/findGlobals.R:234:11: warning: no visible global function definition for ‘find_nnn_ordered’

objs <- find_nnn_ordered(expr, ..., unique = TRUE)
          ^~~~~~~~~~~~~~~~

R/findGlobals.R:252:5: warning: no visible global function definition for ‘mdebug’, Did you mean 'debug'?

​    mdebug(" - expr: <a list of length %d>", length(expr))
    ^~~~~~

R/findGlobals.R:285:5: warning: no visible global function definition for ‘mdebug’, Did you mean 'debug'?

​    mdebug(" - tweaking expression using function")
    ^~~~~~

R/findGlobals.R:290:23: warning: no visible binding for global variable ‘find_globals_ordered’

find_globals_t <- find_globals_ordered
                      ^~~~~~~~~~~~~~~~~~~~

R/findGlobals.R:292:23: warning: no visible binding for global variable ‘find_globals_conservative’

find_globals_t <- find_globals_conservative
                      ^~~~~~~~~~~~~~~~~~~~~~~~~

R/findGlobals.R:294:23: warning: no visible binding for global variable ‘find_globals_liberal’

find_globals_t <- find_globals_liberal
                      ^~~~~~~~~~~~~~~~~~~~

R/findGlobals.R:314:7: warning: no visible global function definition for ‘mdebug’, Did you mean 'debug'?

​      mdebug(" - detected: %s", dQuote(trim(w$message)))
      ^~~~~~

R/findGlobals.R:314:40: warning: no visible global function definition for ‘trim’, Did you mean 'arima'?

​      mdebug(" - detected: %s", dQuote(trim(w$message)))
                                       ^~~~

R/findGlobals.R:361:20: warning: no visible global function definition for ‘drop_missing_formals’

formals_clean <- drop_missing_formals(formals)
                   ^~~~~~~~~~~~~~~~~~~~

R/findGlobals.R:362:13: warning: no visible global function definition for ‘findLocalsList’

locals <- findLocalsList(c(list(body), formals_clean))
            ^~~~~~~~~~~~~~

R/findGlobals.R:366:28: warning: no visible global function definition for ‘walkCode’

for (a in formals_clean) walkCode(a, w)
                           ^~~~~~~~

R/findGlobals.R:368:3: warning: no visible global function definition for ‘walkCode’

​  walkCode(body, w)
  ^~~~~~~~

R/findGlobals.R:375:3: warning: local variable ‘args’ assigned but may not be used

args <- setdiff(names(f), c("w", "..."))
  ^~~~

R/findGlobals.R:376:3: warning: local variable ‘title’ assigned but may not be used

title <- sprintf("%s():", name)
  ^~~~~

R/findGlobals.R:391:7: style: Variable or function name should be snake_case.

w$startCollectLocals <- function(parnames, locals, ...) { NULL }
      ^~~~~~~~~~~~~~~~~~

R/findGlobals.R:394:7: style: Variable or function name should be snake_case.

w$finishCollectLocals <- function(w, ...) { NULL }
      ^~~~~~~~~~~~~~~~~~~

R/findGlobals.R:397:7: style: Variable or function name should be snake_case.

w$enterInternal <- function(type, v, e, ...) { NULL }
      ^~~~~~~~~~~~~

R/findGlobals.R:399:1: style: Trailing whitespace is superfluous.

^~

R/findGlobals.R:401:20: style: Trailing whitespace is superfluous.

fcn <- w[[key]] 
                   ^

R/findGlobals.R:403:12: warning: no visible global function definition for ‘inject_tracer_to_function’

fcn <- inject_tracer_to_function(fcn, key)
           ^~~~~~~~~~~~~~~~~~~~~~~~~

R/findGlobals.R:406:1: style: Trailing whitespace is superfluous.

^~

R/Globals-class.R:16:1: style: Variable or function name should be snake_case.

Globals <- function(object = list(), ...) {
^~~~~~~

R/Globals-class.R:66:3: warning: no visible global function definition for ‘Globals’

​  Globals(x, ...)
  ^~~~~~~

R/Globals-class.R:178:1: style: Variable or function name should be snake_case.

unique.Globals <- function(x, ...) {
^~~~~~~~~~~~~~

R/globalsOf.R:65:1: style: Variable or function name should be snake_case.

globalsOf <- function(expr, envir = parent.frame(), ...,
^~~~~~~~~

R/globalsOf.R:67:57: style: Variable or function name should be snake_case.

tweak = NULL, substitute = FALSE, mustExist = TRUE,
                                                        ^~~~~~~~~

R/globalsOf.R:73:1: style: Trailing whitespace is superfluous.

^~

R/globalsOf.R:84:5: warning: no visible global function definition for ‘globalsByName’

​    globalsByName(names, envir = envir, mustExist = mustExist)
    ^~~~~~~~~~~~~

R/globalsOf.R:99:5: warning: no visible global function definition for ‘mdebug’, Did you mean 'debug'?

​    mdebug(" - recursive scan of preliminary globals ...")
    ^~~~~~

R/globalsOf.R:104:34: warning: no visible binding for global variable ‘envname’, Did you mean 'unname'?

where <- sapply(where, FUN = envname)
                                 ^~~~~~~

R/globalsOf.R:121:1: style: Trailing whitespace is superfluous.

^~~~~~

R/globalsOf.R:123:9: warning: no visible global function definition for ‘mdebug’, Did you mean 'debug'?

​        mdebug("   + scanning global #%d (%s) ...", gg, sQuote(names_t[[gg]]))
        ^~~~~~

R/globalsOf.R:148:7: warning: no visible global function definition for ‘mdebug’, Did you mean 'debug'?

​      mdebug(" - subset of globals to be scanned: [0]")
      ^~~~~~

R/globalsOf.R:151:5: warning: no visible global function definition for ‘mdebug’, Did you mean 'debug'?

​    mdebug(" - recursive scan of preliminary globals ... DONE")
    ^~~~~~

R/globalsOf.R:177:1: style: Variable or function name should be snake_case.

globalsByName <- function(names, envir = parent.frame(), mustExist = TRUE,
^~~~~~~~~~~~~

R/globalsOf.R:177:58: style: Variable or function name should be snake_case.

globalsByName <- function(names, envir = parent.frame(), mustExist = TRUE,
                                                         ^~~~~~~~~

R/globalsOf.R:183:3: warning: no visible global function definition for ‘mdebug’, Did you mean 'debug'?

​  mdebug("- search from environment: %s", sQuote(envname(envir)))
  ^~~~~~

R/globalsOf.R:183:50: warning: no visible global function definition for ‘envname’, Did you mean 'unname'?

​  mdebug("- search from environment: %s", sQuote(envname(envir)))
                                                 ^~~~~~~

R/globalsOf.R:189:3: warning: no visible global function definition for ‘mdebug’, Did you mean 'debug'?

​  mdebug("- dotdotdot: %s", needs_dotdotdot)
  ^~~~~~

R/globalsOf.R:195:5: warning: no visible global function definition for ‘mdebug’, Did you mean 'debug'?

​    mdebug("- locating #%d (%s)", kk, sQuote(name))
    ^~~~~~

R/globalsOf.R:197:5: warning: no visible global function definition for ‘mdebug’, Did you mean 'debug'?

​    mdebug("  + found in environment: %s", sQuote(envname(env)))
    ^~~~~~

R/globalsOf.R:197:51: warning: no visible global function definition for ‘envname’, Did you mean 'unname'?

​    mdebug("  + found in environment: %s", sQuote(envname(env)))
                                                  ^~~~~~~

R/packagesOf.R:2:1: style: Variable or function name should be snake_case.

packagesOf <- function(...) UseMethod("packagesOf")
^~~~~~~~~~

R/packagesOf.R:13:1: style: Variable or function name should be snake_case.

packagesOf.Globals <- function(globals, ...) {
^~~~~~~~~~~~~~~~~~

R/utils.R:19:13: warning: no visible global function definition for ‘find_base_pkgs’

pkgs %in% find_base_pkgs()
            ^~~~~~~~~~~~~~

R/utils.R:25:3: warning: no visible global function definition for ‘is_base_pkg’

​  is_base_pkg(environmentName(environment(x)))
  ^~~~~~~~~~~

R/walkAST.R:17:1: style: Variable or function name should be snake_case.

walkAST <- function(expr, atomic = NULL, name = NULL, call = NULL,
^~~~~~~

R/walkAST.R:71:5: style: Variable or function name should be snake_case.

onUnknownType <- getOption("globals.walkAST.onUnknownType", "error")
    ^~~~~~~~~~~~~

R/where.R:25:7: warning: no visible global function definition for ‘mdebug’, Did you mean 'debug'?

​      mdebug("  + found in location: %s", sQuote(envname(env)))
      ^~~~~~

R/where.R:25:50: warning: no visible global function definition for ‘envname’, Did you mean 'unname'?

​      mdebug("  + found in location: %s", sQuote(envname(env)))
                                                 ^~~~~~~

R/where.R:31:7: warning: no visible global function definition for ‘mdebug’, Did you mean 'debug'?

​      mdebug("  + failed to locate: NULL")
      ^~~~~~

R/where.R:39:3: warning: no visible global function definition for ‘mdebug’, Did you mean 'debug'?

​  mdebug("- failed to locate: NULL")
  ^~~~~~

tests/dotdotdot.R:150:14: warning: no visible global function definition for ‘globalsOf’, Did you mean 'globals'?

globals <- globalsOf(expr, dotdotdot = "ignore")
             ^~~~~~~~~

tests/dotdotdot.R:159:14: warning: no visible global function definition for ‘globalsOf’, Did you mean 'globals'?

globals <- globalsOf(expr, dotdotdot = "return")
             ^~~~~~~~~

tests/dotdotdot.R:173:14: warning: no visible global function definition for ‘globalsOf’, Did you mean 'globals'?

globals <- globalsOf(expr, dotdotdot = "warn")
             ^~~~~~~~~

tests/dotdotdot.R:187:18: warning: no visible global function definition for ‘globalsOf’, Did you mean 'globals'?

globals <- try(globalsOf(expr, dotdotdot = "error"))
                 ^~~~~~~~~

tests/dotdotdot.R:199:12: warning: no visible global function definition for ‘globalsOf’, Did you mean 'globals'?

globals <- globalsOf(exprs, dotdotdot = "return")
           ^~~~~~~~~

tests/formulas.R:19:3: warning: no visible global function definition for ‘map’, Did you mean 'mad'?

​  map(1L, ~ typeof(x + .x))
  ^~~

tests/globalsOf.R:15:1: style: Lines should not be more than 80 characters.

expr <- substitute({ x <- b; b <- 1; y <- c; z <- d; a <- a + 1; e <- e() }, env = list())
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

tests/globalsOf.R:36:24: style: Variable or function name should be snake_case.

​  substitute({ x <- B; B <- 1; y <- C; z <- D }, env = list())
                       ^

tests/walkAST.R:50:4: style: Trailing whitespace is superfluous.

​  }  
   ^~

Please sign in to comment.