Skip to content

Fix outstanding linting issues - #348

Open
jamesmbaazam wants to merge 4 commits into
mainfrom
fix-linting-issues
Open

Fix outstanding linting issues#348
jamesmbaazam wants to merge 4 commits into
mainfrom
fix-linting-issues

Conversation

@jamesmbaazam

Copy link
Copy Markdown
Member

Summary

All open PRs were failing the lint-changed-files CI check because of pre-existing linting issues on main. Since that workflow only lints the files changed by each PR, the failures surfaced across different PRs depending on which files they touched. This PR resolves every genuine {lintr} issue in the package source and vignettes in one place so that, once merged, the other branches pass linting after rebasing onto main.

Issues addressed

Detected with lintr::lint_package() (using the repo's .lintr config with the etdev and cyclocomp packages):

  • return_linter (28) — removed redundant explicit return() calls in R/borel.R, R/helpers.R, R/simulate.R, R/stat_likelihoods.R, R/utils.R and the vignettes, using implicit return instead.
  • condition_call_linter (5) — added call. = FALSE to stop() calls in R/borel.R, R/helpers.R and R/stat_likelihoods.R.
  • sprintf_linter (2) — replaced constant-string sprintf() calls with plain strings in R/epichains.R.
  • object_overwrite_linter (1) — renamed the local dist variable (which shadowed the exported stats::dist) to simulated_stats in R/stat_likelihoods.R.
  • sample_int_linter (4) — used sample.int(10, ...) instead of sample(1:10, ...) in vignettes/epichains.Rmd.
  • one_call_pipe_linter (2) — removed single-call %>% pipes in vignettes/projecting_incidence.Rmd.

The remaining lints reported locally (object_usage_linter / missing_package_linter for epicontacts, truncdist, etc.) are environment-only false positives that clear on CI where those packages are installed.

Verification

  • lintr::lint_package() reports 0 genuine lints after the changes.
  • Full test suite passes (testthat::test_local()).

Checklist

  • Added a NEWS.md item
  • Changes are behaviour-preserving (explicit → implicit returns, internal rename, style-only fixes)
  • Tests pass locally

Copilot AI review requested due to automatic review settings July 7, 2026 16:51

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR aims to eliminate pre-existing {lintr} findings on main so the lint-changed-files workflow stops failing unrelated open PRs, by applying behavior-preserving lint fixes across package R sources and vignettes.

Changes:

  • Replaced redundant explicit return() calls with implicit returns in multiple R functions and vignette helper functions.
  • Updated several stop() calls to include call. = FALSE, and adjusted vignette code to satisfy lintr rules (e.g., sample.int(), removing one-call pipes).
  • Minor refactors to avoid shadowing (distsimulated_stats) and remove unnecessary sprintf() usage in writeLines().

Reviewed changes

Copilot reviewed 10 out of 11 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
vignettes/projecting_incidence.Rmd Removes redundant return() and replaces one-call %>% filter() with direct filter() calls.
vignettes/interventions.Rmd Removes redundant return() from vignette helper functions.
vignettes/epichains.Rmd Uses sample.int() and removes redundant return()s in vignette helper functions.
R/utils.R Removes redundant explicit returns in internal helpers.
R/stat_likelihoods.R Removes redundant explicit returns, adds call. = FALSE to stop(), and renames a local variable to avoid shadowing.
R/simulate.R Removes redundant explicit returns in simulation functions.
R/helpers.R Removes return(switch(...)) wrappers, adds call. = FALSE to stop(), and uses implicit returns.
R/epichains.R Replaces constant-string sprintf() usage in writeLines() with plain strings.
R/borel.R Removes redundant explicit returns and adds call. = FALSE to stop().
NEWS.md Adds a NEWS entry noting linting issue resolution.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread R/helpers.R
Comment on lines 79 to +83
"Offspring distribution must return integers" =
!all(possible_new_offspring %% 1 > 0)
)

return(possible_new_offspring)
possible_new_offspring
Comment thread R/borel.R
Comment on lines +120 to +123
vapply(
x, rborel,
n = 1, censor_at = censor_at, FUN.VALUE = numeric(1)
))
)
Remove redundant explicit return() calls, add call. = FALSE to stop()
messages, replace constant-string sprintf() calls, avoid re-using the
exported stats::dist symbol, use sample.int() and drop single-call pipes
in vignettes.
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