Package 'gDRstyle'

Title: A package with style requirements for the gDR suite
Description: Package fills a helper package role for whole gDR suite. It helps to support good development practices by keeping style requirements and style tests for other packages. It also contains build helpers to make all package requirements met.
Authors: Allison Vuong [aut], Dariusz Scigocki [aut], Marcin Kamianowski [aut], Aleksander Chlebowski [ctb], Janina Smola [aut] (ORCID: <https://orcid.org/0009-0007-4347-7748>), Arkadiusz Gladki [cre, aut] (ORCID: <https://orcid.org/0000-0002-7059-6378>), Bartosz Czech [aut] (ORCID: <https://orcid.org/0000-0002-9908-3007>)
Maintainer: Arkadiusz Gladki <[email protected]>
License: Artistic-2.0
Version: 1.13.1
Built: 2026-11-24 11:20:41 UTC
Source: https://github.com/bioc/gDRstyle

Help Index


Assert that a package version was bumped

Description

Compares the incoming DESCRIPTION Version against the version on the target branch and stops unless it strictly increased. Intended for CI on merge/pull requests, giving GitLab the version-bump guarantee that the GitHub auto-changelog workflow provides.

Usage

assertVersionBumped(old_version, new_version)

Arguments

old_version

character(1) version on the target branch.

new_version

character(1) version proposed by the merge/pull request.

Value

NULL invisibly if the version increased. Stops with an error otherwise.

Examples

assertVersionBumped("1.0.0", "1.0.1")

Avoid new lines in sprintf output. Function helps to avoid line lenght limits without affecting sprintf output

Description

Avoid new lines in sprintf output. Function helps to avoid line lenght limits without affecting sprintf output

Usage

avoid_new_lines(fmt)

Arguments

fmt

string, formatted as sprintf input

Value

string

Examples

sprintf(avoid_new_lines(
  "Lorem ipsum dolor sit amet, %s adipiscing elit, sed do eiusmod
  tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
  veniam."
), "consectetur")

Check for alignment of package dependencies across Rplatform and package specifications.

Description

Check the package depedency version specifications in the rplatform/dependencies.yaml and DESCRIPTION.

Usage

checkDependencies(
  dep_path,
  desc_path,
  skip_pkgs = "R",
  combo_path = "/mnt/vol/dependencies_combo.yaml"
)

Arguments

dep_path

String of path to the rplatform dependencies.yaml file.

desc_path

String of the path to the package DESCRIPTION file.

skip_pkgs

vector of packages from DESCRIPTION to skip; defaults to R

combo_path

String of path to the combo image dependencies.yaml file. Defaults to the current directory.

Details

This function is used for its side effects in the event that there are dependency clashes.

Value

NULL invisibly.

Examples

checkDependencies(
  dep_path =
        system.file(package = "gDRstyle", "testdata", "dependencies.yaml"),
  desc_path = system.file(package = "gDRstyle", "DESCRIPTION"),
  skip_pkgs = c("testthat", "lintr")
)

Check R package

Description

Used in gDR platform pacakges' CI/CD pipelines to check that the package abides by gDRstyle stylistic requirements, passes rcmdcheck, and ensures that the dependencies.yml file used to build gDR platform's docker image is kept up-to-date with the dependencies listed in the package's DESCRIPTION file.

Usage

checkPackage(
  pkgName,
  repoDir,
  subdir = NULL,
  fail_on = "warning",
  bioc_check = FALSE,
  run_examples = TRUE,
  skip_lint = FALSE,
  skip_tests = FALSE,
  skip_pkgdown = FALSE,
  build_vignettes = TRUE,
  check_vignettes = TRUE,
  as_cran = FALSE
)

Arguments

pkgName

String of package name.

repoDir

String of path to repository directory.

subdir

String of relative path to the R package root directory from the repoDir.

fail_on

String specifying the level at which check fail. Supported values: "note", "warning" (default) and "error".

bioc_check

Logical whether bioc check should be performed

run_examples

Logical whether examples check should be performed

skip_lint

skip lint checks

skip_tests

skip tests

skip_pkgdown

skip pkgdown build

build_vignettes

build vignettes

check_vignettes

check vignettes

as_cran

run with as_cran flag

Value

NULL invisibly.

Examples

checkPackage(
  pkgName = "fakePkg",
  repoDir = system.file(package = "gDRstyle", "tst_pkgs", "dummy_pkg"),
  fail_on = "error"
)

Check a PR body against the gDR PR template

Description

Verifies that the PR body contains every section header from the repository's PULL_REQUEST_TEMPLATE.md, so the template is actually filled in rather than deleted.

Usage

checkPrTemplate(body, template_path)

Arguments

body

character(1) PR body.

template_path

character(1) path to the PULL_REQUEST_TEMPLATE.md file.

Value

NULL invisibly if no violations are found. Stops with an error listing the missing headers otherwise.

Examples

tmpl <- tempfile()
writeLines(c("# Description", "## What changed?"), tmpl)
checkPrTemplate("# Description\n## What changed?\ndetails", tmpl)

consecutive_spaces_linter

Description

Flag runs of two or more internal spaces, e.g. alignment padding before <-/= (x <- 1) or extra spaces after a comma (f(a, b)). Leading indentation, trailing whitespace, and spaces inside string literals or comments (including alignment before an end-of-line comment) are ignored.

Usage

consecutive_spaces_linter()

Value

linter class function

Author(s)

Bartosz Czech [email protected]

Examples

linters_config <- lintr::linters_with_defaults(
  consecutive_spaces_linter = consecutive_spaces_linter()
)

Install all package dependencies from yaml file for building image purposes

Description

Install all package dependencies from yaml file for building image purposes

Usage

installAllDeps(
  additionalRepos = NULL,
  base_dir = "/mnt/vol",
  use_ssh = FALSE,
  test_mode = FALSE
)

Arguments

additionalRepos

List of additional Repos

base_dir

String of base working directory.

use_ssh

logical, if use ssh keys

test_mode

logical, whether to run the function in the test mode (if TRUE the dependencies are not installed but only listed)

Value

NULL

Examples

installAllDeps(
  base_dir = system.file(package = "gDRstyle", "testdata"),
  test_mode = TRUE
)

Install locally cloned repo for builiding image purposes

Description

Install locally cloned repo for builiding image purposes

Usage

installLocalPackage(repo_path, additionalRepos = NULL, base_dir = "/mnt/vol")

Arguments

repo_path

String of repository directory.

additionalRepos

List of additional Repos

base_dir

String of base working directory.

Value

NULL

Examples

installLocalPackage(system.file(
package = "gDRstyle", "tst_pkgs", "dummy_pkg"
))

internal_docs_linter

Description

Flag a documented function whose Roxygen block does not declare its visibility. Every function with a #' block must carry @export, @noRd, or @keywords internal, so internal helpers do not leak into NAMESPACE or the pkgdown reference. Undocumented functions (including inline/anonymous ones) are ignored.

Usage

internal_docs_linter()

Value

linter class function

Author(s)

Bartosz Czech [email protected]

Examples

linters_config <- lintr::linters_with_defaults(
  internal_docs_linter = internal_docs_linter()
)

Lint a branch name

Description

Feature branches must be named after the Jira ticket only, e.g. GDR-NNNN, with no trailing description. Branches matching exempt (protected and Bioconductor release branches by default) are skipped, so long-lived branches created before this rule are not blocked.

Usage

lintBranchName(
  branch,
  pattern = "^GDR-[0-9]+$",
  exempt = "^(main|master|devel|RELEASE_[0-9]+_[0-9]+)$"
)

Arguments

branch

character(1) branch name.

pattern

character(1) regular expression a feature branch name must match. Defaults to "^GDR-[0-9]+$".

exempt

character(1) regular expression for branch names that are skipped entirely. Defaults to main, master, devel and RELEASE_<x>_<y> Bioconductor branches.

Value

NULL invisibly if the name is valid. Stops with an error otherwise.

Examples

lintBranchName("GDR-1234") # nolint: ticket_ref_linter.

Lint commit messages for Jira ticket references

Description

The ticket ID belongs in the branch name only. Commit messages must not carry a reference such as GDR-<id>.

Usage

lintCommitMessages(messages)

Arguments

messages

character vector of full commit messages.

Value

NULL invisibly if no violations are found. Stops with an error listing all violations otherwise.

Examples

lintCommitMessages("fix: correct edge case in parser")

Lint a merge/pull request title and body

Description

Convenience wrapper for CI: checks the title for ticket references and, when the repository ships a PR/MR template, checks that the body keeps its sections. The template check is skipped (with a message) when no template is present, so repositories without one are not blocked.

Usage

lintMergeRequest(title, body, pkg_dir = ".", branch = NULL)

Arguments

title

character(1) merge/pull request title.

body

character(1) merge/pull request description.

pkg_dir

character(1) path to the repository root used to locate the PR/MR template. Defaults to the current directory.

branch

character(1) source branch name, or NULL to skip the branch-name check. Defaults to NULL.

Value

NULL invisibly if no violations are found. Stops with an error otherwise.

Examples

lintMergeRequest("feat: add contribution linter", "details", tempdir())

Lint NEWS.md entries for style and brevity

Description

Checks that every bullet entry in NEWS.md follows the gDR style guidelines: starts with an imperative verb, is concise (no verbose phrases, no trailing period, within the character limit), and that each version section contains at most max_bullets entries.

Usage

lintNewsEntries(pkg_dir = ".", max_chars = 120L, max_bullets = 3L)

Arguments

pkg_dir

character(1) path to the package root directory containing NEWS.md. Defaults to the current directory.

max_chars

integer(1) maximum number of characters allowed per bullet entry (excluding the leading "* "). Defaults to 120L.

max_bullets

integer(1) maximum number of bullet entries allowed per version section. Defaults to 3L.

Value

NULL invisibly if no violations are found. Stops with an error listing all violations otherwise.

Examples

pkg_dir <- system.file(package = "gDRstyle", "tst_pkgs", "dummy_pkg")
lintNewsEntries(pkg_dir)

Lint select subdirectories in a package directory.

Description

Lint select subdirectories in a package directory.

Usage

lintPkgDirs(pkg_dir = ".", shiny = FALSE)

Arguments

pkg_dir

String of path to package directory.

shiny

Boolean of whether or not a shiny directory should also be lint. Defaults to the current directory.

Details

Will look for files in the following directories: "R", "tests", and conditionally "inst/shiny" if shiny is TRUE.

Value

NULL invisibly.

Examples

lintPkgDirs(
    pkg_dir= system.file(package = "gDRstyle", "tst_pkgs", "dummy_pkg"))

Lint a PR title for Jira ticket references

Description

The ticket ID belongs in the branch name only. The PR title must not carry any reference such as GDR-<id> or (GDR-<id>).

Usage

lintPrTitle(title)

Arguments

title

character(1) PR title.

Value

NULL invisibly if no violations are found. Stops with an error otherwise.

Examples

lintPrTitle("feat: add contribution linter")

Check an Rmd file for unresolved function calls

Description

Parses all R chunks in an Rmd file, collects packages loaded via library() / require(), detects the host package from the nearest DESCRIPTION file, identifies locally defined names, and flags any unqualified function call that cannot be resolved to a known symbol.

Usage

lintRmdDeps(rmd_path, verbose = FALSE)

Arguments

rmd_path

string path to an .Rmd file.

verbose

logical(1) if TRUE, prints diagnostics (host package, loaded packages, local definitions, known symbol count). Default FALSE.

Details

Mustache template syntax ({{param}}) is stripped before parsing so parametrised report templates can be checked without syntax errors.

Value

A data.table with columns func (character) and line (integer) - one row per unique unresolved call site. Returns NULL when the file contains no R chunks.

Examples

## Not run: 
# Check a single template
lintRmdDeps("inst/report_templates/3-analysis.Rmd")

# Check with verbose diagnostics
lintRmdDeps("inst/report_templates/3-analysis.Rmd", verbose = TRUE)

## End(Not run)

Lint NEWS.md and DESCRIPTION for Jira ticket references

Description

The ticket ID belongs in the branch name only. It must not appear in the changelog (NEWS.md) or package metadata (DESCRIPTION).

Usage

lintTicketRefs(pkg_dir = ".")

Arguments

pkg_dir

character(1) path to the package root directory. Defaults to the current directory.

Value

NULL invisibly if no violations are found. Stops with an error listing all violations otherwise.

Examples

pkg_dir <- system.file(package = "gDRstyle", "tst_pkgs", "dummy_pkg")
lintTicketRefs(pkg_dir)

Lint version consistency between NEWS.md and DESCRIPTION

Description

Checks that the top NEWS.md header matches the package metadata: the package name, version, and date in ## <Pkg> <version> - <date> must equal the Package, Version, and Date fields in DESCRIPTION. This catches a version bump that forgot to update the changelog (or vice versa).

Usage

lintVersionConsistency(pkg_dir = ".")

Arguments

pkg_dir

character(1) path to the package root directory. Defaults to the current directory.

Value

NULL invisibly if consistent. Stops with an error listing all mismatches otherwise.

Examples

pkg_dir <- system.file(package = "gDRstyle", "tst_pkgs", "dummy_pkg")
lintVersionConsistency(pkg_dir)

roxygen_tag_linter

Description

Check that function has documented specific tag in Roxygen skeleton (default @author).

Usage

roxygen_tag_linter(tag = "@author")

Arguments

tag

character (default @author)

Value

linter class function

Author(s)

Kamil Foltynski [email protected]

Examples

linters_config <- lintr::linters_with_defaults(
  line_length_linter = lintr::line_length_linter(120),
  roxygen_tag_linter = roxygen_tag_linter()
)

ticket_ref_linter

Description

Flag Jira ticket references such as GDR-<id> left in the source (in code, comments, or strings). The ticket ID belongs in the branch name only, never in the committed source. A reference inside a TODO or FIXME comment is allowed, since it legitimately links deferred work to the ticket that tracks it.

Usage

ticket_ref_linter()

Value

linter class function

Author(s)

Bartosz Czech [email protected]

Examples

linters_config <- lintr::linters_with_defaults(
  ticket_ref_linter = ticket_ref_linter()
)