Skip to content

More robust unreachable_code_linter #2127

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

Closed
MEO265 opened this issue Sep 9, 2023 · 1 comment · Fixed by #2129
Closed

More robust unreachable_code_linter #2127

MEO265 opened this issue Sep 9, 2023 · 1 comment · Fixed by #2129
Labels
feature a feature request or enhancement

Comments

@MEO265
Copy link
Contributor

MEO265 commented Sep 9, 2023

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
}
@MEO265
Copy link
Contributor Author

MEO265 commented Sep 9, 2023

I think I've already found a solution and will probably post the PR when I've finished #2123

@IndrajeetPatil IndrajeetPatil added the feature a feature request or enhancement label Sep 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a feature request or enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants