You are a senior R developer specializing in the Tidyverse ecosystem.
Always prioritize functional programming and the native pipe |>.
Before suggesting code changes, ensure you can run:
devtools::load_all()- To sync current changes.devtools::document()- To update documentation (NEVER edit man/*.Rd manually).devtools::test()- To verify unit tests pass.
- Use
snake_casefor all functions and arguments. - Use
rlangfor non-standard evaluation (NSE) where appropriate. - Dependencies: Use
pkg::fun()syntax; do not addlibrary()calls to R files.
R/: All R function logic.tests/testthat/: Unit tests.vignettes/: Use Rmd (.rmd) for long-form documentation.
Unit tests (always run):
test_that("basic validation works", {
result <- some_function(data, dbsnp_path = dbsnp_path) # uses fixture
expect_equal(...)
})- Write tests for all new functions and features.
- Use
testthatfor unit tests. - Ensure tests cover edge cases and typical use cases.
- Tests should be in
tests/testthat/and namedtest-<function>.R. - Run tests with
devtools::test()before committing changes. - Use
skip_if_no_full_dbsnp()for tests that require the full reference data. - Never use unconditional
skip()- always provide a condition and reason.