From ab49d250fb08c9d20f82cc7c79b069c6e9775f50 Mon Sep 17 00:00:00 2001 From: Nicolas Casajus Date: Sat, 21 Oct 2023 16:54:14 +0200 Subject: [PATCH] feat: create CODE_OF_CONDUCT - fix #46 --- .github/CODE_OF_CONDUCT.md | 27 ------- CODE_OF_CONDUCT.md | 126 ++++++++++++++++++++++++++++++ NAMESPACE | 1 + NEWS.md | 1 + R/add_code_of_conduct.R | 88 +++++++++++++++++++++ _pkgdown.yml | 1 + inst/templates/CODE_OF_CONDUCT.md | 126 ++++++++++++++++++++++++++++++ man/add_citation.Rd | 1 + man/add_code_of_conduct.Rd | 55 +++++++++++++ man/add_compendium.Rd | 1 + man/add_contributing.Rd | 1 + man/add_description.Rd | 1 + man/add_dockerfile.Rd | 1 + man/add_license.Rd | 1 + man/add_makefile.Rd | 1 + man/add_package_doc.Rd | 1 + man/add_readme_rmd.Rd | 1 + man/add_renv.Rd | 1 + man/add_testthat.Rd | 1 + man/add_vignette.Rd | 1 + 20 files changed, 410 insertions(+), 27 deletions(-) delete mode 100644 .github/CODE_OF_CONDUCT.md create mode 100644 CODE_OF_CONDUCT.md create mode 100644 R/add_code_of_conduct.R create mode 100644 inst/templates/CODE_OF_CONDUCT.md create mode 100644 man/add_code_of_conduct.Rd diff --git a/.github/CODE_OF_CONDUCT.md b/.github/CODE_OF_CONDUCT.md deleted file mode 100644 index 1c73bfd..0000000 --- a/.github/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,27 +0,0 @@ -# Contributor Code of Conduct - -As contributors and maintainers of this project, we pledge to respect all people -who contribute through reporting issues, posting feature requests, updating -documentation, submitting pull requests or patches, and other activities. - -We are committed to making participation in this project a harassment-free -experience for everyone, regardless of level of experience, gender, gender -identity and expression, sexual orientation, disability, personal appearance, -body size, race, ethnicity, age, or religion. - -Examples of unacceptable behavior by participants include the use of sexual -language or imagery, derogatory comments or personal attacks, trolling, public -or private harassment, insults, or other unprofessional conduct. - -Project maintainers have the right and responsibility to remove, edit, or reject -comments, commits, code, wiki edits, issues, and other contributions that are -not aligned to this Code of Conduct. Project maintainers who do not follow the -Code of Conduct may be removed from the project team. - -Instances of abusive, harassing, or otherwise unacceptable behavior may be -reported by opening an issue or contacting one or more of the project -maintainers. - -This Code of Conduct is adapted from the Contributor Covenant -(http://contributor-covenant.org), version 1.0.0, available at -http://contributor-covenant.org/version/1/0/0/ diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..26e2be7 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,126 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +We as members, contributors, and leaders pledge to make participation in our +community a harassment-free experience for everyone, regardless of age, body +size, visible or invisible disability, ethnicity, sex characteristics, gender +identity and expression, level of experience, education, socio-economic status, +nationality, personal appearance, race, caste, color, religion, or sexual +identity and orientation. + +We pledge to act and interact in ways that contribute to an open, welcoming, +diverse, inclusive, and healthy community. + +## Our Standards + +Examples of behavior that contributes to a positive environment for our +community include: + +* Demonstrating empathy and kindness toward other people +* Being respectful of differing opinions, viewpoints, and experiences +* Giving and gracefully accepting constructive feedback +* Accepting responsibility and apologizing to those affected by our mistakes, + and learning from the experience +* Focusing on what is best not just for us as individuals, but for the overall + community + +Examples of unacceptable behavior include: + +* The use of sexualized language or imagery, and sexual attention or advances of + any kind +* Trolling, insulting or derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or email address, + without their explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Enforcement Responsibilities + +Community leaders are responsible for clarifying and enforcing our standards of +acceptable behavior and will take appropriate and fair corrective action in +response to any behavior that they deem inappropriate, threatening, offensive, +or harmful. + +Community leaders have the right and responsibility to remove, edit, or reject +comments, commits, code, wiki edits, issues, and other contributions that are +not aligned to this Code of Conduct, and will communicate reasons for moderation +decisions when appropriate. + +## Scope + +This Code of Conduct applies within all community spaces, and also applies when +an individual is officially representing the community in public spaces. +Examples of representing our community include using an official e-mail address, +posting via an official social media account, or acting as an appointed +representative at an online or offline event. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported to the community leaders responsible for enforcement at +. +All complaints will be reviewed and investigated promptly and fairly. + +All community leaders are obligated to respect the privacy and security of the +reporter of any incident. + +## Enforcement Guidelines + +Community leaders will follow these Community Impact Guidelines in determining +the consequences for any action they deem in violation of this Code of Conduct: + +### 1. Correction + +**Community Impact**: Use of inappropriate language or other behavior deemed +unprofessional or unwelcome in the community. + +**Consequence**: A private, written warning from community leaders, providing +clarity around the nature of the violation and an explanation of why the +behavior was inappropriate. A public apology may be requested. + +### 2. Warning + +**Community Impact**: A violation through a single incident or series of +actions. + +**Consequence**: A warning with consequences for continued behavior. No +interaction with the people involved, including unsolicited interaction with +those enforcing the Code of Conduct, for a specified period of time. This +includes avoiding interactions in community spaces as well as external channels +like social media. Violating these terms may lead to a temporary or permanent +ban. + +### 3. Temporary Ban + +**Community Impact**: A serious violation of community standards, including +sustained inappropriate behavior. + +**Consequence**: A temporary ban from any sort of interaction or public +communication with the community for a specified period of time. No public or +private interaction with the people involved, including unsolicited interaction +with those enforcing the Code of Conduct, is allowed during this period. +Violating these terms may lead to a permanent ban. + +### 4. Permanent Ban + +**Community Impact**: Demonstrating a pattern of violation of community +standards, including sustained inappropriate behavior, harassment of an +individual, or aggression toward or disparagement of classes of individuals. + +**Consequence**: A permanent ban from any sort of public interaction within the +community. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org), +version 2.1, available at +. + +Community Impact Guidelines were inspired by +[Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/inclusion). + +For answers to common questions about this code of conduct, see the FAQ at +. Translations are available at +. diff --git a/NAMESPACE b/NAMESPACE index 8d1215a..d8bd6fd 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,6 +1,7 @@ # Generated by roxygen2: do not edit by hand export(add_citation) +export(add_code_of_conduct) export(add_codecov_badge) export(add_compendium) export(add_contributing) diff --git a/NEWS.md b/NEWS.md index bf16cd5..ac960ab 100644 --- a/NEWS.md +++ b/NEWS.md @@ -12,6 +12,7 @@ the `CITATION.cff` file * Improve detection of dependencies in `get_deps_*()` functions * New feature: `get_git_branch_name()` detects git branch name * New feature: `add_contributing()` adds a `CONTRIBUTING.md` file and issue templates +* New feature: `add_code_of_conduct()` adds a `CODE_OF_CONDUCT.md` file # rcompendium 1.1 diff --git a/R/add_code_of_conduct.R b/R/add_code_of_conduct.R new file mode 100644 index 0000000..5f3ae62 --- /dev/null +++ b/R/add_code_of_conduct.R @@ -0,0 +1,88 @@ +#' Add code of conduct +#' +#' @description +#' This function creates a `CODE_OF_CONDUCT.md` file adapted from the +#' Contributor Covenant, version 2.1 available at +#' \url{https://www.contributor-covenant.org/version/2/1/code_of_conduct.html}. +#' +#' @param open A logical value. If `TRUE` (default) the `CONTRIBUTING.md` file +#' is opened in the editor. +#' +#' @param overwrite A logical value. If files are already present and +#' `overwrite = TRUE`, they will be erased and replaced. Default is `FALSE`. +#' +#' @param quiet A logical value. If `TRUE` messages are deleted. Default is +#' `FALSE`. +#' +#' @inheritParams set_credentials +#' +#' @return No return value. +#' +#' @export +#' +#' @family create files +#' +#' @examples +#' \dontrun{ +#' add_code_of_conduct() +#' } + +add_code_of_conduct <- function(email = NULL, + open = TRUE, overwrite = FALSE, quiet = FALSE) { + + + stop_if_not_logical(open, overwrite, quiet) + + path <- file.path(path_proj(), "CODE_OF_CONDUCT.md") + + + ## Do not replace current file but open it if required ---- + + if (file.exists(path) && !overwrite) { + + if (!open) { + + stop("A 'CODE_OF_CONDUCT.md' file is already present. If you want to ", + "replace it, please use `overwrite = TRUE`.") + + } else { + + edit_file(path) + return(invisible(NULL)) + } + } + + + ## Get fields values ---- + + if (is.null(email)) email <- getOption("email") + + + stop_if_not_string(email) + + + ## Copy Template ---- + + invisible( + file.copy(system.file(file.path("templates", "CODE_OF_CONDUCT.md"), + package = "rcompendium"), path, overwrite = TRUE)) + + + ## Change defaults values ---- + + xfun::gsub_file(path, "{{email}}", email, fixed = TRUE) + + + ## Messages ---- + + if (!quiet) { + ui_done("Writing {ui_value('CODE_OF_CONDUCT.md')} file") + } + + add_to_buildignore("CODE_OF_CONDUCT.md", quiet = quiet) + + + if (open) edit_file(path) + + invisible(NULL) +} diff --git a/_pkgdown.yml b/_pkgdown.yml index b8efa63..5eef81e 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -36,6 +36,7 @@ reference: - add_license - add_package_doc - add_citation + - add_code_of_conduct - add_contributing - add_testthat - add_vignette diff --git a/inst/templates/CODE_OF_CONDUCT.md b/inst/templates/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..0e06071 --- /dev/null +++ b/inst/templates/CODE_OF_CONDUCT.md @@ -0,0 +1,126 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +We as members, contributors, and leaders pledge to make participation in our +community a harassment-free experience for everyone, regardless of age, body +size, visible or invisible disability, ethnicity, sex characteristics, gender +identity and expression, level of experience, education, socio-economic status, +nationality, personal appearance, race, caste, color, religion, or sexual +identity and orientation. + +We pledge to act and interact in ways that contribute to an open, welcoming, +diverse, inclusive, and healthy community. + +## Our Standards + +Examples of behavior that contributes to a positive environment for our +community include: + +* Demonstrating empathy and kindness toward other people +* Being respectful of differing opinions, viewpoints, and experiences +* Giving and gracefully accepting constructive feedback +* Accepting responsibility and apologizing to those affected by our mistakes, + and learning from the experience +* Focusing on what is best not just for us as individuals, but for the overall + community + +Examples of unacceptable behavior include: + +* The use of sexualized language or imagery, and sexual attention or advances of + any kind +* Trolling, insulting or derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or email address, + without their explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Enforcement Responsibilities + +Community leaders are responsible for clarifying and enforcing our standards of +acceptable behavior and will take appropriate and fair corrective action in +response to any behavior that they deem inappropriate, threatening, offensive, +or harmful. + +Community leaders have the right and responsibility to remove, edit, or reject +comments, commits, code, wiki edits, issues, and other contributions that are +not aligned to this Code of Conduct, and will communicate reasons for moderation +decisions when appropriate. + +## Scope + +This Code of Conduct applies within all community spaces, and also applies when +an individual is officially representing the community in public spaces. +Examples of representing our community include using an official e-mail address, +posting via an official social media account, or acting as an appointed +representative at an online or offline event. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported to the community leaders responsible for enforcement at +<{{email}}>. +All complaints will be reviewed and investigated promptly and fairly. + +All community leaders are obligated to respect the privacy and security of the +reporter of any incident. + +## Enforcement Guidelines + +Community leaders will follow these Community Impact Guidelines in determining +the consequences for any action they deem in violation of this Code of Conduct: + +### 1. Correction + +**Community Impact**: Use of inappropriate language or other behavior deemed +unprofessional or unwelcome in the community. + +**Consequence**: A private, written warning from community leaders, providing +clarity around the nature of the violation and an explanation of why the +behavior was inappropriate. A public apology may be requested. + +### 2. Warning + +**Community Impact**: A violation through a single incident or series of +actions. + +**Consequence**: A warning with consequences for continued behavior. No +interaction with the people involved, including unsolicited interaction with +those enforcing the Code of Conduct, for a specified period of time. This +includes avoiding interactions in community spaces as well as external channels +like social media. Violating these terms may lead to a temporary or permanent +ban. + +### 3. Temporary Ban + +**Community Impact**: A serious violation of community standards, including +sustained inappropriate behavior. + +**Consequence**: A temporary ban from any sort of interaction or public +communication with the community for a specified period of time. No public or +private interaction with the people involved, including unsolicited interaction +with those enforcing the Code of Conduct, is allowed during this period. +Violating these terms may lead to a permanent ban. + +### 4. Permanent Ban + +**Community Impact**: Demonstrating a pattern of violation of community +standards, including sustained inappropriate behavior, harassment of an +individual, or aggression toward or disparagement of classes of individuals. + +**Consequence**: A permanent ban from any sort of public interaction within the +community. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org), +version 2.1, available at +. + +Community Impact Guidelines were inspired by +[Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/inclusion). + +For answers to common questions about this code of conduct, see the FAQ at +. Translations are available at +. diff --git a/man/add_citation.Rd b/man/add_citation.Rd index 091e043..41e6b53 100644 --- a/man/add_citation.Rd +++ b/man/add_citation.Rd @@ -62,6 +62,7 @@ citation("pkg") # If you have installed your package } \seealso{ Other create files: +\code{\link{add_code_of_conduct}()}, \code{\link{add_compendium}()}, \code{\link{add_contributing}()}, \code{\link{add_description}()}, diff --git a/man/add_code_of_conduct.Rd b/man/add_code_of_conduct.Rd new file mode 100644 index 0000000..57fc711 --- /dev/null +++ b/man/add_code_of_conduct.Rd @@ -0,0 +1,55 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/add_code_of_conduct.R +\name{add_code_of_conduct} +\alias{add_code_of_conduct} +\title{Add code of conduct} +\usage{ +add_code_of_conduct( + email = NULL, + open = TRUE, + overwrite = FALSE, + quiet = FALSE +) +} +\arguments{ +\item{email}{A character of length 1. The email address of the project +maintainer.} + +\item{open}{A logical value. If \code{TRUE} (default) the \code{CONTRIBUTING.md} file +is opened in the editor.} + +\item{overwrite}{A logical value. If files are already present and +\code{overwrite = TRUE}, they will be erased and replaced. Default is \code{FALSE}.} + +\item{quiet}{A logical value. If \code{TRUE} messages are deleted. Default is +\code{FALSE}.} +} +\value{ +No return value. +} +\description{ +This function creates a \code{CODE_OF_CONDUCT.md} file adapted from the +Contributor Covenant, version 2.1 available at +\url{https://www.contributor-covenant.org/version/2/1/code_of_conduct.html}. +} +\examples{ +\dontrun{ +add_code_of_conduct() +} +} +\seealso{ +Other create files: +\code{\link{add_citation}()}, +\code{\link{add_compendium}()}, +\code{\link{add_contributing}()}, +\code{\link{add_description}()}, +\code{\link{add_dockerfile}()}, +\code{\link{add_license}()}, +\code{\link{add_makefile}()}, +\code{\link{add_package_doc}()}, +\code{\link{add_readme_rmd}()}, +\code{\link{add_renv}()}, +\code{\link{add_testthat}()}, +\code{\link{add_vignette}()} +} +\concept{create files} diff --git a/man/add_compendium.Rd b/man/add_compendium.Rd index 7d812d0..6726792 100644 --- a/man/add_compendium.Rd +++ b/man/add_compendium.Rd @@ -30,6 +30,7 @@ add_compendium() \seealso{ Other create files: \code{\link{add_citation}()}, +\code{\link{add_code_of_conduct}()}, \code{\link{add_contributing}()}, \code{\link{add_description}()}, \code{\link{add_dockerfile}()}, diff --git a/man/add_contributing.Rd b/man/add_contributing.Rd index 4bfc6a3..c2a5fde 100644 --- a/man/add_contributing.Rd +++ b/man/add_contributing.Rd @@ -55,6 +55,7 @@ add_contributing() \seealso{ Other create files: \code{\link{add_citation}()}, +\code{\link{add_code_of_conduct}()}, \code{\link{add_compendium}()}, \code{\link{add_description}()}, \code{\link{add_dockerfile}()}, diff --git a/man/add_description.Rd b/man/add_description.Rd index 51b18dc..ce0ea70 100644 --- a/man/add_description.Rd +++ b/man/add_description.Rd @@ -60,6 +60,7 @@ add_description(organisation = "MySociety") \seealso{ Other create files: \code{\link{add_citation}()}, +\code{\link{add_code_of_conduct}()}, \code{\link{add_compendium}()}, \code{\link{add_contributing}()}, \code{\link{add_dockerfile}()}, diff --git a/man/add_dockerfile.Rd b/man/add_dockerfile.Rd index 7c92e10..aab4377 100644 --- a/man/add_dockerfile.Rd +++ b/man/add_dockerfile.Rd @@ -70,6 +70,7 @@ add_dockerfile() \seealso{ Other create files: \code{\link{add_citation}()}, +\code{\link{add_code_of_conduct}()}, \code{\link{add_compendium}()}, \code{\link{add_contributing}()}, \code{\link{add_description}()}, diff --git a/man/add_license.Rd b/man/add_license.Rd index 4083e82..e14e3bc 100644 --- a/man/add_license.Rd +++ b/man/add_license.Rd @@ -40,6 +40,7 @@ add_license(license = "GPL (>= 2)") \seealso{ Other create files: \code{\link{add_citation}()}, +\code{\link{add_code_of_conduct}()}, \code{\link{add_compendium}()}, \code{\link{add_contributing}()}, \code{\link{add_description}()}, diff --git a/man/add_makefile.Rd b/man/add_makefile.Rd index fa36065..aa96676 100644 --- a/man/add_makefile.Rd +++ b/man/add_makefile.Rd @@ -49,6 +49,7 @@ add_makefile() \seealso{ Other create files: \code{\link{add_citation}()}, +\code{\link{add_code_of_conduct}()}, \code{\link{add_compendium}()}, \code{\link{add_contributing}()}, \code{\link{add_description}()}, diff --git a/man/add_package_doc.Rd b/man/add_package_doc.Rd index c28808d..fa83f86 100644 --- a/man/add_package_doc.Rd +++ b/man/add_package_doc.Rd @@ -33,6 +33,7 @@ add_package_doc() \seealso{ Other create files: \code{\link{add_citation}()}, +\code{\link{add_code_of_conduct}()}, \code{\link{add_compendium}()}, \code{\link{add_contributing}()}, \code{\link{add_description}()}, diff --git a/man/add_readme_rmd.Rd b/man/add_readme_rmd.Rd index 20f50b1..44dcb63 100644 --- a/man/add_readme_rmd.Rd +++ b/man/add_readme_rmd.Rd @@ -55,6 +55,7 @@ add_readme_rmd(type = "package") \seealso{ Other create files: \code{\link{add_citation}()}, +\code{\link{add_code_of_conduct}()}, \code{\link{add_compendium}()}, \code{\link{add_contributing}()}, \code{\link{add_description}()}, diff --git a/man/add_renv.Rd b/man/add_renv.Rd index 92d24ea..1d670e0 100644 --- a/man/add_renv.Rd +++ b/man/add_renv.Rd @@ -25,6 +25,7 @@ add_renv() \seealso{ Other create files: \code{\link{add_citation}()}, +\code{\link{add_code_of_conduct}()}, \code{\link{add_compendium}()}, \code{\link{add_contributing}()}, \code{\link{add_description}()}, diff --git a/man/add_testthat.Rd b/man/add_testthat.Rd index 63284fe..3878a7a 100644 --- a/man/add_testthat.Rd +++ b/man/add_testthat.Rd @@ -23,6 +23,7 @@ add_testthat() \seealso{ Other create files: \code{\link{add_citation}()}, +\code{\link{add_code_of_conduct}()}, \code{\link{add_compendium}()}, \code{\link{add_contributing}()}, \code{\link{add_description}()}, diff --git a/man/add_vignette.Rd b/man/add_vignette.Rd index 8ef9874..82571e3 100644 --- a/man/add_vignette.Rd +++ b/man/add_vignette.Rd @@ -51,6 +51,7 @@ add_vignette(filename = "pkg", title = "Get started") \seealso{ Other create files: \code{\link{add_citation}()}, +\code{\link{add_code_of_conduct}()}, \code{\link{add_compendium}()}, \code{\link{add_contributing}()}, \code{\link{add_description}()},