Title: | Opinionated Package Coding Styles |
---|---|
Description: | A set of functions to enforce styling in functions. This package would typically be used in with a CI platform, such as GitHub and GitLab. |
Authors: | Jumping Rivers [aut, cre] |
Maintainer: | Jumping Rivers <[email protected]> |
License: | GPL-2 | GPL-3 |
Version: | 1.0.22 |
Built: | 2025-03-11 04:46:50 UTC |
Source: | https://github.com/jumpingrivers/inteRgrate |
Builds and sets the PKG_TARBALL & PKG_TARBALL_PATH variables.
build_pkg() get_pkg_tar_ball()
build_pkg() get_pkg_tar_ball()
This function will run all checks within the package. See the corresponding check functions for details.
check_all( pkg = TRUE, lintr = TRUE, namespace = TRUE, r_filenames = TRUE, version = TRUE, gitignore = TRUE, tidy_description = TRUE, readme = TRUE, file_permissions = TRUE, line_breaks = TRUE, tag = TRUE, news = TRUE, rproj = TRUE )
check_all( pkg = TRUE, lintr = TRUE, namespace = TRUE, r_filenames = TRUE, version = TRUE, gitignore = TRUE, tidy_description = TRUE, readme = TRUE, file_permissions = TRUE, line_breaks = TRUE, tag = TRUE, news = TRUE, rproj = TRUE )
pkg |
Build and check package. See details for further information. |
lintr , namespace , r_filenames , version , gitignore , readme , tidy_description
|
Checks |
file_permissions , line_breaks
|
Windows related checks. |
tag |
Create a tagged release. |
news |
Check the top line of NEWS.md |
rproj |
Runs check_rproj |
The arguments for the function correspond to a particular check, e.g. check_ARGNAME(). Note: As this package matures, this function will include the newer checks.
This check tests for windows line breaks and file permissions. It ensures that the file is not executable (txt|md|Rmd|yml|json|).
check_file_permissions(repo_files = NULL, path = ".")
check_file_permissions(repo_files = NULL, path = ".")
repo_files |
By default, we use git to determine the files in the repo. By a vector of files can be passed instead. |
path |
Location of the package |
check_file_permissions()
check_file_permissions()
Checks the gitignore files for recommended patterns. If any of these patterns are missing, an error is raised.
check_gitignore(path = ".")
check_gitignore(path = ".")
path |
Location of the package |
Runs lint from the lintr
package. Also scans for all
.Rmd
and .R
files in other directories.
check_lintr(path = ".")
check_lintr(path = ".")
path |
Location of the package |
Importing too many packages can cause bugs due to namespace clashes. This check
enforces a set number of imports. As a rule of thumb, if you only use a few functions from
a package, use importFrom
instead of import
in your NAMESPACE file.
check_namespace(no_imports = NULL, path = ".")
check_namespace(no_imports = NULL, path = ".")
no_imports |
Default NULL. Number of package imports via |
path |
Location of the package |
Checks that NEWS.md exists and title lines follow the correct format.
If the pattern
is NULL
, then the expected format is either:
# pkg_name Version _YYYY-MM-DD_
or # pkg_name (development version)
check_news(pattern = NULL, path = ".") check_all_news(pattern = NULL)
check_news(pattern = NULL, path = ".") check_all_news(pattern = NULL)
pattern |
Regular expression NEWS title. |
path |
Location of the package |
The check_all_news()
function isn't used in the CI. It's a
convient command line function to quickly assess your NEWS.md file
Path is the CI project directory or .
.
Installs and checks the R package. The number of notes
and warnings is specified by enviromental variables.
Default number of Notes/Warnings is 0.
check_pkg(path = ".")
check_pkg(path = ".")
path |
Location of the package |
Checks that all filenames in the directory R/
are lower case and the file extension matches .extension
check_r_filenames(path = ".", extension = "R")
check_r_filenames(path = ".", extension = "R")
path |
Location of the package |
extension |
Preferred R file extension. Default |
check_r_filenames()
check_r_filenames()
If README.Rmd exists, the timestamp will be compared to README.md. An error will be raised if README.md is a newer file.
check_readme(path = ".")
check_readme(path = ".")
path |
Location of the package |
check_readme()
check_readme()
Checks for a tidy description file (via the usethis
function
use_tidy_description
). It also checks that the version numbers conform
to the tidy format - X.Y.Z or X.Y.Z.9ABC
check_tidy_description(path = ".")
check_tidy_description(path = ".")
path |
Location of the package |
Check if the package version has been updated compared to the a master repo (default is origin/master). This ensures that when branches are merged the package version is bumped.
check_version(repo = NULL, path = ".")
check_version(repo = NULL, path = ".")
repo |
Default origin/master or origin/main. The repo to compare against. |
path |
Location of the package |
Files listed in .Rbuildignore don't count as changes.
Technically we only check for a change in the Version line of the DESCRIPTION file, not an actual version increase.
This function will run all checks within the package.
See the corresponding check functions for details. When default = "true"
, all
checks will run unless the associated environment variable is "false"
.
check_via_env( pkg = NULL, lintr = NULL, namespace = NULL, r_filenames = NULL, version = NULL, gitignore = NULL, tidy_description = NULL, readme = NULL, file_permissions = NULL, line_breaks = NULL, tag = NULL, news = NULL, rproj = NULL, default = FALSE )
check_via_env( pkg = NULL, lintr = NULL, namespace = NULL, r_filenames = NULL, version = NULL, gitignore = NULL, tidy_description = NULL, readme = NULL, file_permissions = NULL, line_breaks = NULL, tag = NULL, news = NULL, rproj = NULL, default = FALSE )
pkg |
Build and check package. See details for further information. |
lintr , namespace , r_filenames , version , gitignore , readme , tidy_description
|
Default |
file_permissions , line_breaks
|
Windows related checks. |
tag |
Default |
news |
Check the top line of NEWS.md |
rproj |
Check Rproject file |
default |
Default |
The arguments for the function correspond to a particular check, e.g. check_ARGNAME().
By default, all arguments are NULL
and hence run. However, a value of
FALSE
or changing the corresponding environment variable
INTERGRATE_ARGNAME
can turn off the check, e.g.INTERGRATE_NAMESPACE
.
On GitLab you can set environment variables at an organisation level.
Note: As this package matures, this function will include the newer checks.
Automatically tag the commit via the version number. This requires the environment variable GITHUB_TOKEN that has write permission.
create_tag(branch = get_origin_name(), in_development = FALSE)
create_tag(branch = get_origin_name(), in_development = FALSE)
branch |
The branch where the tagging will occur. Default master or main. |
in_development |
Logical default FALSE. |
If the version contains an in development component (e.g. X.Y.Z.9001), by default a tag isn't created.
If a .Rproj file exists, then the values should correspond to those given by
get_default_rproj
. If more than one .Rproj file exists, an error is raised.
get_default_rproj() check_rproj(default_rproj = get_default_rproj(), path = ".")
get_default_rproj() check_rproj(default_rproj = get_default_rproj(), path = ".")
default_rproj |
Default Rproj values. |
path |
Location of the package |
check_readme()
check_readme()
git_pre_commit only tests files that have changed. Makes things, especially linting a lot faster.
Add a pre-commit or pre-push hook. Both hooks are identical. They just get triggered at different times.
git_pre_commit() add_pre_commit() add_pre_push()
git_pre_commit() add_pre_commit() add_pre_push()
Rewrites the gitlab URL. This can be handy if you want to push to another GitLab repo on successful builds. Uses the environment variable CI_SERVER_HOST to determine the HOST.
gitlab_instead_of()
gitlab_instead_of()
Set an variable in the .Renviron file. Calls readEnviron
to enable R
to use the variable in future function calls.
set_renviron_var(variable, value)
set_renviron_var(variable, value)
variable |
The variable name |
value |
The value |