Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test/32 enable linters #52

Open
wants to merge 80 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
791d2f4
Enable `cyclocomp_linter`
AlexAxthelm Dec 16, 2024
120df7e
Enable `commented_code_linter`
AlexAxthelm Dec 16, 2024
6a19d8b
Standardize function definitions
AlexAxthelm Dec 16, 2024
85a709a
enable whitespace linters
AlexAxthelm Dec 16, 2024
e8a3afd
Enable space after comma linter
AlexAxthelm Dec 16, 2024
7cb5b35
enable `assignment_linter` (`=` vs `<-`)
AlexAxthelm Dec 16, 2024
15d22a8
Enable `indentation_linter`
AlexAxthelm Dec 16, 2024
1117e14
Enable `line_length_linter`
AlexAxthelm Dec 16, 2024
9d349af
Update formatting of helping functions
AlexAxthelm Dec 16, 2024
71004e5
Enable object_length linter
AlexAxthelm Dec 16, 2024
9564e57
wip: `object_usage_linter`
AlexAxthelm Dec 16, 2024
e3281e1
Expand from default linters to all
AlexAxthelm Dec 16, 2024
7841a50
Enable `missing_argument_linter`
AlexAxthelm Dec 16, 2024
05fc289
Enable `ifelse_censor_linter`
AlexAxthelm Dec 16, 2024
22980e2
Enable `if_not_else_linter`
AlexAxthelm Dec 16, 2024
0b618d6
Enable `undesirable_*_linter` (function & operator)
AlexAxthelm Dec 16, 2024
a7fe184
Enable `redundant_equals_linter`
AlexAxthelm Dec 16, 2024
6f33b17
Combine `get_scenario` and `get_scenario_source`
AlexAxthelm Dec 16, 2024
c821c41
Add tests for get_scenario and get_scenario_source
AlexAxthelm Dec 16, 2024
96d7c98
Enable `fixed_regex_linter` and refactor get_scenario
AlexAxthelm Dec 16, 2024
c859c7f
remove dead code, and exclude `teststhat.R`
AlexAxthelm Dec 17, 2024
7cc997b
Shorten test descriptions
AlexAxthelm Dec 17, 2024
a5e6cc2
Add test and lint `replace_contents`
AlexAxthelm Dec 17, 2024
9c53267
Finish linting for `fixed_regex_linter`
AlexAxthelm Dec 17, 2024
70b192d
Use `testthat`
AlexAxthelm Dec 17, 2024
dfe2d0c
Increment version number to 0.0.0.9009
AlexAxthelm Dec 17, 2024
b716511
Remove `stringr` dependency
AlexAxthelm Dec 17, 2024
0b43c1c
Enable `unnecessary_concatenation_linter`
AlexAxthelm Dec 17, 2024
7b2b917
Enable `nonportable_path_linter`
AlexAxthelm Dec 17, 2024
5c1bc6b
Enable `implicit_integer_linter`
AlexAxthelm Dec 17, 2024
030a66e
Enable `conjunct_test_linter`
AlexAxthelm Dec 17, 2024
c0b6f45
Enable `namespace_linter`
AlexAxthelm Dec 17, 2024
7a3e1a4
Enable `extraction_operator_linter`
AlexAxthelm Dec 17, 2024
7dbc9e4
remove mis-committed file
AlexAxthelm Dec 17, 2024
51a17f1
Add testing dependency
AlexAxthelm Dec 17, 2024
cf22c79
Remove misplaced `join_by`
AlexAxthelm Dec 18, 2024
8d95ebf
Convert magrittr pipes to base (`%>%` to `|>`)
AlexAxthelm Dec 18, 2024
d576408
Explicitly namespace `dplyr::filter` and remove from imports
AlexAxthelm Dec 18, 2024
d30db80
Un-importFrom `tidyr::unite`
AlexAxthelm Dec 18, 2024
cf42a86
Un-importFrom `tidyr::pivot_longer`
AlexAxthelm Dec 18, 2024
dc00e88
un-importFrom `tidyr::pivot_wider`
AlexAxthelm Dec 18, 2024
44557fc
Fix bad namespace to local function
AlexAxthelm Dec 18, 2024
3122c70
un-importFrom `dplyr::mutate` and `dplyr::mutate_at`
AlexAxthelm Dec 18, 2024
7cd7348
un-importFrom `dplyr::summarise`
AlexAxthelm Dec 18, 2024
1f29933
un-importFrom `dplyr::group_by`
AlexAxthelm Dec 18, 2024
b2b849f
un-importFrom `dplyr::ungroup`
AlexAxthelm Dec 18, 2024
2abfd56
un-importFrom `dplyr::all_of`
AlexAxthelm Dec 18, 2024
50bf887
un-importFrom `dplyr::bind_rows`
AlexAxthelm Dec 18, 2024
adde196
un-importFrom `dplyr::case_when`
AlexAxthelm Dec 18, 2024
ebe7702
un-importFrom `dplyr::if_else`
AlexAxthelm Dec 18, 2024
5009715
un-importFrom `dplyr::inner_join`
AlexAxthelm Dec 18, 2024
521ca11
un-importFrom `dplyr::left_join`
AlexAxthelm Dec 18, 2024
18d5a0f
un-importFrom `dplyr::join_by`
AlexAxthelm Dec 18, 2024
aba0bf2
un-importFrom `dplyr::transmute`
AlexAxthelm Dec 18, 2024
ee678ab
un-importFrom `dplyr::row_number`
AlexAxthelm Dec 18, 2024
f6e156e
un-importFrom `dplyr::reframe`
AlexAxthelm Dec 18, 2024
3afaff3
un-importFrom `dplyr::pull`
AlexAxthelm Dec 18, 2024
17c6355
un-importFrom `dplyr::rename`
AlexAxthelm Dec 18, 2024
da82039
un-importFrom `dplyr::across`
AlexAxthelm Dec 18, 2024
10d2b47
un-importFrom `dplyr::arrange`
AlexAxthelm Dec 18, 2024
5d2fcd9
un-importFrom `dplyr::desc`
AlexAxthelm Dec 18, 2024
cad3355
un-importFrom `dplyr::distinct`
AlexAxthelm Dec 18, 2024
e9d4377
un-importFrom `dplyr::tibble`
AlexAxthelm Dec 18, 2024
5654f75
un-importFrom `dplyr::everything`
AlexAxthelm Dec 18, 2024
345854a
un-importFrom `dplyr::first`
AlexAxthelm Dec 18, 2024
c84ddf6
un-importFrom `dplyr::last`
AlexAxthelm Dec 18, 2024
15de4b5
un-importFrom `dplyr::lag`
AlexAxthelm Dec 18, 2024
8cfb620
un-importFrom `dplyr::n`
AlexAxthelm Dec 18, 2024
ee2b89c
un-importFrom `dplyr::select`
AlexAxthelm Dec 18, 2024
8435b97
un-importFrom `dplyr::slice`
AlexAxthelm Dec 18, 2024
ddf02e6
linting: Line length
AlexAxthelm Dec 18, 2024
3cbf404
Style (manual): don't end lines in assignment operator
AlexAxthelm Dec 18, 2024
544d809
Linting: indentation
AlexAxthelm Dec 18, 2024
f52c4ec
Add docstrings from #53
AlexAxthelm Jan 2, 2025
568e8c7
Render Docs
AlexAxthelm Jan 2, 2025
578489d
Merge branch 'main' into test/32-enable-linters
AlexAxthelm Jan 2, 2025
2bff49b
Increment version number to 0.0.0.9010
AlexAxthelm Jan 2, 2025
d334d4c
linting (after GH webUI conflict resolution)
AlexAxthelm Jan 2, 2025
55b7de0
update docstring to new argument name
AlexAxthelm Jan 2, 2025
13dc609
Specify minimum R version (base pipe)
AlexAxthelm Jan 3, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 6 additions & 11 deletions .lintr
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
linters: linters_with_defaults(
cyclocomp_linter = NULL,
line_length_linter = NULL,
indentation_linter = NULL,
object_usage_linter = NULL,
trailing_whitespace_linter = NULL,
object_length_linter = NULL,
assignment_linter = NULL,
commas_linter = NULL,
trailing_blank_lines_linter = NULL,
commented_code_linter = NULL
linters: all_linters(
object_usage_linter = NULL
)
exclusions: list(
"inst/extdata/translation/",
"tests/testthat.R"
)
10 changes: 7 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: workflow.pacta.dashboard
Title: Run PACTA dashboard JSON generation
Version: 0.0.0.9009
Version: 0.0.0.9010
Authors@R:
c(person(given = "Alex",
family = "Axthelm",
Expand Down Expand Up @@ -30,15 +30,19 @@ Imports:
glue,
jsonlite,
logger,
magrittr,
pacta.portfolio.utils,
pacta.workflow.utils,
readr,
rlang,
stringr,
tidyr,
workflow.pacta
Remotes:
RMI-PACTA/pacta.portfolio.utils,
RMI-PACTA/pacta.workflow.utils,
RMI-PACTA/workflow.pacta
Suggests:
testthat (>= 3.0.0),
tibble
Config/testthat/edition: 3
Depends:
R (>= 4.1.0)
34 changes: 0 additions & 34 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -8,45 +8,11 @@ export(prep_key_bars_portfolio)
export(prep_techmix_sector)
export(prepare_schema_files)
export(run_dashboard_workflow)
importFrom(dplyr,across)
importFrom(dplyr,all_of)
importFrom(dplyr,arrange)
importFrom(dplyr,bind_rows)
importFrom(dplyr,case_when)
importFrom(dplyr,desc)
importFrom(dplyr,distinct)
importFrom(dplyr,everything)
importFrom(dplyr,filter)
importFrom(dplyr,first)
importFrom(dplyr,group_by)
importFrom(dplyr,if_else)
importFrom(dplyr,inner_join)
importFrom(dplyr,join_by)
importFrom(dplyr,lag)
importFrom(dplyr,last)
importFrom(dplyr,left_join)
importFrom(dplyr,mutate)
importFrom(dplyr,mutate_at)
importFrom(dplyr,n)
importFrom(dplyr,pull)
importFrom(dplyr,reframe)
importFrom(dplyr,rename)
importFrom(dplyr,row_number)
importFrom(dplyr,select)
importFrom(dplyr,slice)
importFrom(dplyr,summarise)
importFrom(dplyr,tibble)
importFrom(dplyr,transmute)
importFrom(dplyr,ungroup)
importFrom(logger,log_debug)
importFrom(logger,log_error)
importFrom(logger,log_info)
importFrom(logger,log_trace)
importFrom(logger,log_warn)
importFrom(magrittr,"%>%")
importFrom(rlang,":=")
importFrom(rlang,.data)
importFrom(rlang,.env)
importFrom(tidyr,pivot_longer)
importFrom(tidyr,pivot_wider)
importFrom(tidyr,unite)
2 changes: 2 additions & 0 deletions R/build_dashboard.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
dashboard_skeleton_files_dir = dashboard_skeleton_files_dir,
dashboard_output_dir = dashboard_output_dir
)
stopifnot(dashboard_copy_success)

Check warning on line 22 in R/build_dashboard.R

View check run for this annotation

Codecov / codecov/patch

R/build_dashboard.R#L22

Added line #L22 was not covered by tests

dashboard_output_data_dir <- file.path(dashboard_output_dir, "data")
if (dashboard_data_dir != dashboard_output_data_dir) {
Expand All @@ -31,6 +32,7 @@
to = dashboard_output_data_dir,
recursive = TRUE
)
stopifnot(data_copy_success)

Check warning on line 35 in R/build_dashboard.R

View check run for this annotation

Codecov / codecov/patch

R/build_dashboard.R#L35

Added line #L35 was not covered by tests
}

out <- list(
Expand Down
24 changes: 13 additions & 11 deletions R/choose_dictionary_language.R
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
choose_dictionary_language <-
function(data, language) {
language <- tolower(language)
choose_dictionary_language <- function(
data,
language
) {
language <- tolower(language)

Check warning on line 5 in R/choose_dictionary_language.R

View check run for this annotation

Codecov / codecov/patch

R/choose_dictionary_language.R#L5

Added line #L5 was not covered by tests

data %>%
transmute(
.data$id_data,
.data$id_column,
translate_key = .data$key,
translate_value = .data[[language]]
)
}
data |>
dplyr::transmute(
.data[["id_data"]],
.data[["id_column"]],
translate_key = .data[["key"]],
translate_value = .data[[language]]
)

Check warning on line 13 in R/choose_dictionary_language.R

View check run for this annotation

Codecov / codecov/patch

R/choose_dictionary_language.R#L7-L13

Added lines #L7 - L13 were not covered by tests
}
24 changes: 13 additions & 11 deletions R/filter_scenarios_per_sector.R
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
filter_scenarios_per_sector <-
function(data, select_scenario_other, select_scenario) {
special_sectors <- c("Aviation")
rest_of_sectors <- setdiff(unique(data$ald_sector), special_sectors)

data %>%
filter(
scenarios_found_in_sectors(.data, select_scenario_other, c("Aviation")) |
scenarios_found_in_sectors(.data, select_scenario, rest_of_sectors)
)
}
filter_scenarios_per_sector <- function(
data,
select_scenario_other,
select_scenario
) {
special_sectors <- "Aviation"
rest_of_sectors <- setdiff(unique(data[["ald_sector"]]), special_sectors)

Check warning on line 7 in R/filter_scenarios_per_sector.R

View check run for this annotation

Codecov / codecov/patch

R/filter_scenarios_per_sector.R#L6-L7

Added lines #L6 - L7 were not covered by tests

data |>
dplyr::filter(
scenarios_found_in_sectors(.data, select_scenario_other, "Aviation") |
scenarios_found_in_sectors(.data, select_scenario, rest_of_sectors)
)

Check warning on line 13 in R/filter_scenarios_per_sector.R

View check run for this annotation

Codecov / codecov/patch

R/filter_scenarios_per_sector.R#L9-L13

Added lines #L9 - L13 were not covered by tests
}
39 changes: 36 additions & 3 deletions R/get_scenario.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,37 @@
get_scenario <- function(scenario_parameter) {
scenario <- unlist(stringr::str_split(scenario_parameter,"_", n = 2))[2]
scenario
get_scenario <- function(
scenario_parameter
) {
scenario_name <- split_scenario_parameter(
scenario_parameter = scenario_parameter
)[["scenario_name"]]
return(scenario_name)
}

get_scenario_source <- function(
scenario_parameter
) {
scenario_source <- split_scenario_parameter(
scenario_parameter = scenario_parameter
)[["scenario_source"]]
return(scenario_source)
}

split_scenario_parameter <- function(
scenario_parameter
) {
split_parameter <- unlist(
strsplit(
x = scenario_parameter,
split = "_",
fixed = TRUE
)
)
scenario_source <- split_parameter[[1L]]
scenario_name <- paste(split_parameter[-1L], collapse = "_")
return(
list(
scenario_source = scenario_source,
scenario_name = scenario_name
)
)
}
4 changes: 0 additions & 4 deletions R/get_scenario_source.R

This file was deleted.

Loading
Loading