Skip to content

New linter for utils::hasName() #2650

@m-muecke

Description

@m-muecke

Since R 3.4.0 utils::hasName() was added as a convient way of testing the existence of a name i.e. the pattern "name" %in% names(x) or for checking the !is.null(x$abc) pattern without partial matching (taken from the docs):

 x <- list(abc = 1, def = 2)
 !is.null(x$abc) # correct
 !is.null(x$a)   # this is the wrong test!
 hasName(x, "abc")
 hasName(x, "a")

There is also the basically equivalent rlang::has_name() as a common pattern.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions