Skip to content

Conversation

MichaelChirico
Copy link
Collaborator

@MichaelChirico MichaelChirico commented Jul 26, 2025

Split off from #2899, this one is large enough to get its own PR. Part of #2827. Also progress on #2737.

@MichaelChirico MichaelChirico marked this pull request as ready for review July 26, 2025 21:18
MichaelChirico added a commit that referenced this pull request Jul 26, 2025
#' @seealso [linters] for a complete list of linters available in lintr.
#' @export
unreachable_code_linter <- function(allow_comment_regex = getOption("covr.exclude_end", "# nocov end")) {
# nolint next: object_usage_linter. Used in glue() in statically-difficult fashion to detect.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can both remove the lint and break up the code into more digestible parts by only glueing once like

glue::glue("
  ({expr_after_control} | {last_function_call})/{unreachable_expr_ws} |
  ({expr_after_control} | {last_function_call})/{unreachable_expr_sc} |
  ({expr_after_control})/{next_or_break}/{unreachable_expr_ws} |
  ({expr_after_control})/{next_or_break}/{unreachable_expr_sc}
")

WDYT?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I did what you had in mind -- merge the logic for the [return/stop] and [next/break] cases, then use lint customization to give the right message in every case. That includes improving the customization beyond what existed already to mention return() / stop() specifically.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checking back :)

Copy link

codecov bot commented Jul 28, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (main@38db1ac). Learn more about missing BASE report.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2900   +/-   ##
=======================================
  Coverage        ?   99.27%           
=======================================
  Files           ?      128           
  Lines           ?     7211           
  Branches        ?        0           
=======================================
  Hits            ?     7159           
  Misses          ?       52           
  Partials        ?        0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

MichaelChirico added a commit that referenced this pull request Jul 28, 2025
* Robust linters for comments in "natural" places

* revert whats in #2900 already

* missed file not matching linter names
@MichaelChirico MichaelChirico added this to the 3.3.0 milestone Jul 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants