Skip to content

Commit

Permalink
Merge pull request #73 from Infectious-Disease-Modeling-Hubs/enhancem…
Browse files Browse the repository at this point in the history
…ent/hubstyle

Upgrade to hubStyle template. Fix linting issues
  • Loading branch information
annakrystalli authored Feb 15, 2024
2 parents 38f96af + 3d6d081 commit 2eb6b10
Show file tree
Hide file tree
Showing 89 changed files with 861 additions and 828 deletions.
6 changes: 6 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,9 @@
^attic$
^data-raw$
^vignettes/articles$
^\.DS_Store$
^\.Rhistory$
^\.Rdata$
^\.httr-oauth$
^\.secrets$
^\.lintr$
74 changes: 6 additions & 68 deletions .github/CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,80 +38,18 @@ Examples of unacceptable behavior include:

## 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 are responsible for clarifying our standards of acceptable behavior. Enforcement is the responsibility of the [Code of Conduct Committee](https://hubdocs.readthedocs.io/en/latest/coc/committee.html), who 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.
Instances of abusive, harassing, or otherwise unacceptable behavior [may be reported to any member of the Code of Conduct Committee](https://hubdocs.readthedocs.io/en/latest/coc/committee.html). All complaints will be reviewed and investigated promptly and fairly.

## 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 any of the following community leaders responsible for enforcement: Lucie Contamin ([email protected]),
Emily Howerton ([email protected]) or
Seb Funk ([email protected]).
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
The Code of Conduct Committee will use the [Enforcement Manual](https://hubdocs.readthedocs.io/en/latest/coc/enforcement-manual.html) in determining the consequences for any action they deem in violation of this Code of Conduct. All community leaders and Code of Conduct Committee members are obligated to respect the privacy and security of the reporter of any incident.

**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
## Scope

**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.
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.

**Consequence**: A permanent ban from any sort of public interaction within the
community.

## Attribution

Expand Down
10 changes: 1 addition & 9 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
#
# NOTE: This workflow is overkill for most R packages and
# check-standard.yaml is likely a better choice.
# usethis::use_github_action("check-standard") will install it.
on:
push:
branches: [main, master]
Expand All @@ -23,11 +19,7 @@ jobs:
matrix:
config:
- {os: macos-latest, r: 'release'}

- {os: windows-latest, r: 'release'}
# use 4.1 to check with rtools40's older compiler
- {os: windows-latest, r: '4.1'}

- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-latest, r: 'release'}
- {os: ubuntu-latest, r: 'oldrel-1'}
Expand All @@ -37,7 +29,7 @@ jobs:
R_KEEP_PKG_SOURCE: yes

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-pandoc@v2

Expand Down
32 changes: 32 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]

name: lint

jobs:
lint:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::lintr, local::.
needs: lint

- name: Lint
run: lintr::lint_package()
shell: Rscript {0}
env:
LINTR_ERROR_ON_LINT: true
2 changes: 1 addition & 1 deletion .github/workflows/pkgdown-netlify-preview.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# # Workflow derived from https://github.com/r-lib/pkgdown/blob/main/.github/workflows/pkgdown.yaml
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-r@v2
with:
Expand All @@ -31,7 +31,7 @@ jobs:
covr::codecov(
quiet = FALSE,
clean = FALSE,
install_path = file.path(Sys.getenv("RUNNER_TEMP"), "package")
install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package")
)
shell: Rscript {0}

Expand All @@ -44,7 +44,7 @@ jobs:

- name: Upload test results
if: failure()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: coverage-test-failures
path: ${{ runner.temp }}/package
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
.DS_Store
docs
attic
.secrets
5 changes: 5 additions & 0 deletions .lintr
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
linters: linters_with_defaults(
line_length_linter = line_length_linter(120L),
commented_code_linter = NULL,
object_length_linter = object_length_linter(length = 50L)
)
28 changes: 14 additions & 14 deletions R/capture_exec_error.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ capture_exec_error <- function(file_path, msg, call = NULL) {
if (is.null(call)) {
call <- rlang::caller_call()
if (!is.null(call)) {
call <- rlang::call_name(call)
call <- rlang::call_name(call)
}
}

Expand All @@ -37,18 +37,18 @@ capture_exec_error <- function(file_path, msg, call = NULL) {
#' inherits from subclass `<hub_check>`.
#' @export
capture_exec_warning <- function(file_path, msg, call = NULL) {
if (is.null(call)) {
call <- rlang::caller_call()
}
if (!is.null(call)) {
call <- rlang::call_name(call)
}
if (is.null(call)) {
call <- rlang::caller_call()
}
if (!is.null(call)) {
call <- rlang::call_name(call)
}

rlang::warning_cnd(
c("check_exec_warn", "hub_check"),
where = file_path,
call = call,
message = msg,
use_cli_format = TRUE
)
rlang::warning_cnd(
c("check_exec_warn", "hub_check"),
where = file_path,
call = call,
message = msg,
use_cli_format = TRUE
)
}
4 changes: 2 additions & 2 deletions R/check_config_hub_valid.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
#' @export
check_config_hub_valid <- function(hub_path) {
valid_config <- hubUtils::validate_hub_config(hub_path) %>%
suppressMessages() %>%
suppressWarnings()
suppressMessages() %>%
suppressWarnings()

check <- all(unlist(valid_config))

Expand Down
29 changes: 16 additions & 13 deletions R/check_file_exists.R
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
#' Check file exists at the file path specified
#'
#'
#' @param subdir subdirectory within the hub
#' @inheritParams check_valid_round_id
#' @inherit check_valid_round_id return
#'
#' @export
check_file_exists <- function(file_path, hub_path = ".",
subdir = c("model-output", "model-metadata",
"hub-config")) {
abs_path <- abs_file_path(file_path, hub_path, subdir)
rel_path <- rel_file_path(file_path, hub_path, subdir)
check <- fs::file_exists(abs_path)
subdir = c(
"model-output", "model-metadata",
"hub-config"
)) {
abs_path <- abs_file_path(file_path, hub_path, subdir)
rel_path <- rel_file_path(file_path, hub_path, subdir) # nolint: object_usage_linter
check <- fs::file_exists(abs_path)

capture_check_cnd(
check = check,
file_path = file_path,
msg_subject = "File",
msg_attribute = cli::format_inline("at path {.path {rel_path}}."),
msg_verbs = c("exists", "does not exist"),
error = TRUE)
capture_check_cnd(
check = check,
file_path = file_path,
msg_subject = "File",
msg_attribute = cli::format_inline("at path {.path {rel_path}}."),
msg_verbs = c("exists", "does not exist"),
error = TRUE
)
}
31 changes: 16 additions & 15 deletions R/check_file_format.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,24 @@
#'
#' @export
check_file_format <- function(file_path, hub_path, round_id) {
file_format <- fs::path_ext(file_path)
file_formats <- get_hub_file_formats(hub_path, round_id)
file_format <- fs::path_ext(file_path)
file_formats <- get_hub_file_formats(hub_path, round_id)

check <- file_format %in% file_formats
check <- file_format %in% file_formats

if (check) {
details <- NULL
} else {
details <- cli::format_inline("Must be one of {.val {file_formats}}
if (check) {
details <- NULL
} else {
details <- cli::format_inline("Must be one of {.val {file_formats}}
not {.val {file_format}}")
}
}

capture_check_cnd(
check = check,
file_path = file_path,
msg_subject = "File",
msg_attribute = "accepted hub format.",
error = TRUE,
details = details)
capture_check_cnd(
check = check,
file_path = file_path,
msg_subject = "File",
msg_attribute = "accepted hub format.",
error = TRUE,
details = details
)
}
36 changes: 18 additions & 18 deletions R/check_file_location.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,26 @@
#'
#' @export
check_file_location <- function(file_path) {
dir_name <- dirname(file_path)
model_id <- parse_file_name(file_path)$model_id
check <- model_id == dir_name

dir_name <- dirname(file_path)
model_id <- parse_file_name(file_path)$model_id
check <- model_id == dir_name

if (check) {
details <- NULL
} else {
details <- cli::format_inline(
"File should be submitted to directory
if (check) {
details <- NULL
} else {
details <- cli::format_inline(
"File should be submitted to directory
{.val {model_id}} not {.val {dir_name}}"
)
}
)
}

capture_check_cnd(
check = check,
file_path = file_path,
msg_subject = "File directory name",
msg_attribute = cli::format_inline("{.var model_id}
capture_check_cnd(
check = check,
file_path = file_path,
msg_subject = "File directory name",
msg_attribute = cli::format_inline("{.var model_id}
metadata in file name."),
msg_verbs = c("matches", "must match"),
details = details)
msg_verbs = c("matches", "must match"),
details = details
)
}
4 changes: 2 additions & 2 deletions R/check_file_name.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ check_file_name <- function(file_path) {
"try-error"
)
if (check) {
details <- NULL
details <- NULL
} else {
details <- "Could not correctly parse submission metadata."
details <- "Could not correctly parse submission metadata."
}
capture_check_cnd(
check = check,
Expand Down
Loading

0 comments on commit 2eb6b10

Please sign in to comment.