| 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 |
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.
assertVersionBumped(old_version, new_version)assertVersionBumped(old_version, new_version)
old_version |
character(1) version on the target branch. |
new_version |
character(1) version proposed by the merge/pull request. |
NULL invisibly if the version increased. Stops with an error
otherwise.
assertVersionBumped("1.0.0", "1.0.1")assertVersionBumped("1.0.0", "1.0.1")
Avoid new lines in sprintf output. Function helps to avoid line lenght limits without affecting sprintf output
avoid_new_lines(fmt)avoid_new_lines(fmt)
fmt |
string, formatted as sprintf input |
string
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")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 the package depedency version specifications in the
rplatform/dependencies.yaml and DESCRIPTION.
checkDependencies( dep_path, desc_path, skip_pkgs = "R", combo_path = "/mnt/vol/dependencies_combo.yaml" )checkDependencies( dep_path, desc_path, skip_pkgs = "R", combo_path = "/mnt/vol/dependencies_combo.yaml" )
dep_path |
String of path to the rplatform |
desc_path |
String of the path to the package |
skip_pkgs |
vector of packages from |
combo_path |
String of path to the combo image
|
This function is used for its side effects in the event that there are dependency clashes.
NULL invisibly.
checkDependencies( dep_path = system.file(package = "gDRstyle", "testdata", "dependencies.yaml"), desc_path = system.file(package = "gDRstyle", "DESCRIPTION"), skip_pkgs = c("testthat", "lintr") )checkDependencies( dep_path = system.file(package = "gDRstyle", "testdata", "dependencies.yaml"), desc_path = system.file(package = "gDRstyle", "DESCRIPTION"), skip_pkgs = c("testthat", "lintr") )
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.
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 )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 )
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 |
fail_on |
String specifying the level at which check fail. Supported
values: |
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 |
NULL invisibly.
checkPackage( pkgName = "fakePkg", repoDir = system.file(package = "gDRstyle", "tst_pkgs", "dummy_pkg"), fail_on = "error" )checkPackage( pkgName = "fakePkg", repoDir = system.file(package = "gDRstyle", "tst_pkgs", "dummy_pkg"), fail_on = "error" )
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.
checkPrTemplate(body, template_path)checkPrTemplate(body, template_path)
body |
character(1) PR body. |
template_path |
character(1) path to the |
NULL invisibly if no violations are found. Stops with an
error listing the missing headers otherwise.
tmpl <- tempfile() writeLines(c("# Description", "## What changed?"), tmpl) checkPrTemplate("# Description\n## What changed?\ndetails", tmpl)tmpl <- tempfile() writeLines(c("# Description", "## What changed?"), tmpl) checkPrTemplate("# Description\n## What changed?\ndetails", tmpl)
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.
consecutive_spaces_linter()consecutive_spaces_linter()
linter class function
Bartosz Czech [email protected]
linters_config <- lintr::linters_with_defaults( consecutive_spaces_linter = consecutive_spaces_linter() )linters_config <- lintr::linters_with_defaults( consecutive_spaces_linter = consecutive_spaces_linter() )
Install all package dependencies from yaml file for building image purposes
installAllDeps( additionalRepos = NULL, base_dir = "/mnt/vol", use_ssh = FALSE, test_mode = FALSE )installAllDeps( additionalRepos = NULL, base_dir = "/mnt/vol", use_ssh = FALSE, test_mode = FALSE )
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) |
NULL
installAllDeps( base_dir = system.file(package = "gDRstyle", "testdata"), test_mode = TRUE )installAllDeps( base_dir = system.file(package = "gDRstyle", "testdata"), test_mode = TRUE )
Install locally cloned repo for builiding image purposes
installLocalPackage(repo_path, additionalRepos = NULL, base_dir = "/mnt/vol")installLocalPackage(repo_path, additionalRepos = NULL, base_dir = "/mnt/vol")
repo_path |
String of repository directory. |
additionalRepos |
List of additional Repos |
base_dir |
String of base working directory. |
NULL
installLocalPackage(system.file( package = "gDRstyle", "tst_pkgs", "dummy_pkg" ))installLocalPackage(system.file( package = "gDRstyle", "tst_pkgs", "dummy_pkg" ))
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.
internal_docs_linter()internal_docs_linter()
linter class function
Bartosz Czech [email protected]
linters_config <- lintr::linters_with_defaults( internal_docs_linter = internal_docs_linter() )linters_config <- lintr::linters_with_defaults( internal_docs_linter = internal_docs_linter() )
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.
lintBranchName( branch, pattern = "^GDR-[0-9]+$", exempt = "^(main|master|devel|RELEASE_[0-9]+_[0-9]+)$" )lintBranchName( branch, pattern = "^GDR-[0-9]+$", exempt = "^(main|master|devel|RELEASE_[0-9]+_[0-9]+)$" )
branch |
character(1) branch name. |
pattern |
character(1) regular expression a feature branch name must
match. Defaults to |
exempt |
character(1) regular expression for branch names that are
skipped entirely. Defaults to |
NULL invisibly if the name is valid. Stops with an error
otherwise.
lintBranchName("GDR-1234") # nolint: ticket_ref_linter.lintBranchName("GDR-1234") # nolint: ticket_ref_linter.
The ticket ID belongs in the branch name only. Commit messages must not
carry a reference such as GDR-<id>.
lintCommitMessages(messages)lintCommitMessages(messages)
messages |
character vector of full commit messages. |
NULL invisibly if no violations are found. Stops with an
error listing all violations otherwise.
lintCommitMessages("fix: correct edge case in parser")lintCommitMessages("fix: correct edge case in parser")
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.
lintMergeRequest(title, body, pkg_dir = ".", branch = NULL)lintMergeRequest(title, body, pkg_dir = ".", branch = NULL)
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 invisibly if no violations are found. Stops with an
error otherwise.
lintMergeRequest("feat: add contribution linter", "details", tempdir())lintMergeRequest("feat: add contribution linter", "details", tempdir())
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.
lintNewsEntries(pkg_dir = ".", max_chars = 120L, max_bullets = 3L)lintNewsEntries(pkg_dir = ".", max_chars = 120L, max_bullets = 3L)
pkg_dir |
character(1) path to the package root directory containing
|
max_chars |
integer(1) maximum number of characters allowed per bullet
entry (excluding the leading |
max_bullets |
integer(1) maximum number of bullet entries allowed per
version section. Defaults to |
NULL invisibly if no violations are found. Stops with an
error listing all violations otherwise.
pkg_dir <- system.file(package = "gDRstyle", "tst_pkgs", "dummy_pkg") lintNewsEntries(pkg_dir)pkg_dir <- system.file(package = "gDRstyle", "tst_pkgs", "dummy_pkg") lintNewsEntries(pkg_dir)
Lint select subdirectories in a package directory.
lintPkgDirs(pkg_dir = ".", shiny = FALSE)lintPkgDirs(pkg_dir = ".", shiny = FALSE)
pkg_dir |
String of path to package directory. |
shiny |
Boolean of whether or not a |
Will look for files in the following directories:
"R", "tests", and conditionally "inst/shiny"
if shiny is TRUE.
NULL invisibly.
lintPkgDirs( pkg_dir= system.file(package = "gDRstyle", "tst_pkgs", "dummy_pkg"))lintPkgDirs( pkg_dir= system.file(package = "gDRstyle", "tst_pkgs", "dummy_pkg"))
The ticket ID belongs in the branch name only. The PR title must not
carry any reference such as GDR-<id> or (GDR-<id>).
lintPrTitle(title)lintPrTitle(title)
title |
character(1) PR title. |
NULL invisibly if no violations are found. Stops with an
error otherwise.
lintPrTitle("feat: add contribution linter")lintPrTitle("feat: add contribution linter")
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.
lintRmdDeps(rmd_path, verbose = FALSE)lintRmdDeps(rmd_path, verbose = FALSE)
rmd_path |
string path to an |
verbose |
logical(1) if |
Mustache template syntax ({{param}}) is stripped before parsing
so parametrised report templates can be checked without syntax errors.
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.
## 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)## 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)
The ticket ID belongs in the branch name only. It must not appear in the
changelog (NEWS.md) or package metadata (DESCRIPTION).
lintTicketRefs(pkg_dir = ".")lintTicketRefs(pkg_dir = ".")
pkg_dir |
character(1) path to the package root directory. Defaults to the current directory. |
NULL invisibly if no violations are found. Stops with an
error listing all violations otherwise.
pkg_dir <- system.file(package = "gDRstyle", "tst_pkgs", "dummy_pkg") lintTicketRefs(pkg_dir)pkg_dir <- system.file(package = "gDRstyle", "tst_pkgs", "dummy_pkg") lintTicketRefs(pkg_dir)
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).
lintVersionConsistency(pkg_dir = ".")lintVersionConsistency(pkg_dir = ".")
pkg_dir |
character(1) path to the package root directory. Defaults to the current directory. |
NULL invisibly if consistent. Stops with an error listing all
mismatches otherwise.
pkg_dir <- system.file(package = "gDRstyle", "tst_pkgs", "dummy_pkg") lintVersionConsistency(pkg_dir)pkg_dir <- system.file(package = "gDRstyle", "tst_pkgs", "dummy_pkg") lintVersionConsistency(pkg_dir)
Check that function has documented specific tag in Roxygen
skeleton (default @author).
roxygen_tag_linter(tag = "@author")roxygen_tag_linter(tag = "@author")
tag |
character (default |
linter class function
Kamil Foltynski [email protected]
linters_config <- lintr::linters_with_defaults( line_length_linter = lintr::line_length_linter(120), roxygen_tag_linter = roxygen_tag_linter() )linters_config <- lintr::linters_with_defaults( line_length_linter = lintr::line_length_linter(120), roxygen_tag_linter = roxygen_tag_linter() )
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.
ticket_ref_linter()ticket_ref_linter()
linter class function
Bartosz Czech [email protected]
linters_config <- lintr::linters_with_defaults( ticket_ref_linter = ticket_ref_linter() )linters_config <- lintr::linters_with_defaults( ticket_ref_linter = ticket_ref_linter() )