Skip to content

return_linter() for implicit returns has a false positive on nested early returns #2354

@MichaelChirico

Description

@MichaelChirico
          Corrected this test, and added the incorrect test as a new regression test.

That said, the new fix is more expedient than perfect -- it'll throw an incorrect lint here:

foo <- function() {
  if (TRUE) {
    if (TRUE) {
      return(1)
    }
    2
  } else {
    3
  }

(the return() is a valid early return within that branch).

But as this issue is not relevant to the implicit else returns feature, I'm pushing to follow-up.

Originally posted by @MichaelChirico in #2321 (comment)

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