The unreachable_code_linter should also mark code inside if, else, for, and while loops as unreachable, especially when a return or stop function is called.
The following code currently generates only one annotation:
x <- function() {
if(TRUE) {
stop('This is a test')
5+5
}
return(5L)
4+4
}
And this one generates none:
x <- function() {
if(TRUE) {
stop('This is a test')
5+5
}
4+4
}
The
unreachable_code_lintershould also mark code inside if, else, for, and while loops as unreachable, especially when a return or stop function is called.The following code currently generates only one annotation:
And this one generates none: