Skip to content

tree() throws warning if passed a tibble #238

@cjyetman

Description

@cjyetman

The cli::tree() function throws a (presumably) undesirable warning if it's passed a tibble instead of a data frame (presumably, a likely use case). It's caused by

cli/R/tree.R

Line 117 in bc066c1

trimlabs <- data$trimmed %||% labels

where data$trimmed returns NULL as expected but also a warning if data is a tibble. There are numerous obvious, easy ways to work around that, so I won't bother suggesting a solution/PR.

data <- data.frame(
  stringsAsFactors = FALSE,
  package = c("A", "B", "C"),
  dependencies = c("B", "C", "")
)

cli::tree(data)
#> A
#> └─B
#>   └─C

cli::tree(tibble::as_tibble(data))
#> Warning: Unknown or uninitialised column: `trimmed`.
#> A
#> └─B
#>   └─C

data$trimmed
#> NULL

tibble::as_tibble(data)$trimmed
#> Warning: Unknown or uninitialised column: `trimmed`.
#> NULL

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behavior

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions