Skip to content

Commit

Permalink
Improve code readability
Browse files Browse the repository at this point in the history
Signed-off-by: Maximilian Löffler <[email protected]>
  • Loading branch information
maxloeffler committed Nov 21, 2023
1 parent bb5aeb2 commit 5d3dd57
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions util-split.R
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ split.data.time.based = function(project.data, time.period = "3 months", bins =

# validate existence and type of the 'bins' parameter
if (!is.null(bins) && !lubridate::is.POSIXct(bins)) {
dates = parallel::mclapply(bins, function(bin) get.date.from.string(bin))
dates = parallel::mclapply(bins, get.date.from.string)
if (any(is.na(dates))) {
logging::logerror("The bins parameter, if present, needs to be a character representing a date")
stop("Stopped due to incorrect parameter types")
Expand Down Expand Up @@ -105,12 +105,12 @@ split.data.by.bins = function(project.data, activity.amount, bins, split.basis =
}

# validate existence and type of the 'bins' component of the 'bins' parameter
if (!"bins" %in% names(bins)) {
if (!("bins" %in% names(bins))) {
logging::logerror("The 'bins' parameter needs to include a component 'bins'")
stop("Stopped due to incorrect parameter types")
}

dates = parallel::mclapply(bins[["bins"]], function(bin) get.date.from.string(bin))
dates = parallel::mclapply(bins[["bins"]], get.date.from.string)
if (any(is.na(dates))) {
logging::logerror("The 'bins' component of the bins parameter needs to be a character representing a date")
stop("Stopped due to incorrect parameter types")
Expand Down

0 comments on commit 5d3dd57

Please sign in to comment.