Skip to content

More robust unreachable_code_linter #2127

Closed
@MEO265

Description

@MEO265

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
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    featurea feature request or enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions