As soon as there is a comment after the return or stop, it is correctly not linted, but neither are the following lines.
Will produce lints:
foo <- function() {
return(3)
5 + 2
}
False negative:
foo <- function() {
return(3) # A comment
5 + 2
}
The same applies to something that @MichaelChirico has already marked as a todo in the code, but I haven't found an issue about it:
|
# TODO(michaelchirico): similarly, return(x); x+1 should also lint, even though |
However, not only will the following expression in the same line not be marked, but also those in subsequent lines will not be marked.
False negative:
foo <- function() {
return(3); x + 1
5 + 2
}
As soon as there is a comment after the
returnorstop, it is correctly not linted, but neither are the following lines.Will produce lints:
False negative:
The same applies to something that @MichaelChirico has already marked as a todo in the code, but I haven't found an issue about it:
lintr/tests/testthat/test-unreachable_code_linter.R
Line 181 in c8f0074
However, not only will the following expression in the same line not be marked, but also those in subsequent lines will not be marked.
False negative: