Skip to content

Un-braced nested if/else gives false positive for unreachable_code_linter #2710

@MichaelChirico

Description

@MichaelChirico

Found in {bit64}:

lint(linters = unreachable_code_linter(), '
function(x, ...){
    if(is.null(env))
        has.cache <- FALSE
    else if (exists("nunique", envir=env, inherits=FALSE))
        return(get("nunique", envir=env, inherits=FALSE))
    else
        has.cache <- TRUE
}
')
# <text>:7:5: warning: [unreachable_code_linter] Remove code and comments coming after return() or stop().
#     else
#     ^~~~

https://github.com/r-lib/bit64/blob/cb4552b8345550d158cc7ae9b937b009f4dcd200/R/cache.R#L358-L363

Metadata

Metadata

Assignees

No one assigned

    Labels

    false-positivecode that shouldn't lint, but does

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions