Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
MichaelChirico opened this issue Jan 21, 2025 · 0 comments
Labels
false-positive code that shouldn't lint, but does

Comments

@MichaelChirico
Copy link
Collaborator

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

@MichaelChirico MichaelChirico added the false-positive code that shouldn't lint, but does label Jan 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
false-positive code that shouldn't lint, but does
Projects
None yet
Development

No branches or pull requests

1 participant