Skip to content

Commit

Permalink
Adhere to coding conventions
Browse files Browse the repository at this point in the history
Add single quotes around coding variables in comments, improve
description of return value for 'get.bin.dates.from.ranges',
and move said method closer to similar methods in file for
consistency.

Signed-off-by: Maximilian Löffler <[email protected]>
  • Loading branch information
maxloeffler committed Feb 27, 2024
1 parent 93051ab commit 2497e23
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
20 changes: 10 additions & 10 deletions util-misc.R
Original file line number Diff line number Diff line change
Expand Up @@ -984,6 +984,16 @@ get.range.bounds = function(range) {
return (range)
}

#' Obtain the start and end dates from given ranges.
#'
#' @param ranges the ranges to get the dates from
#'
#' @return a vector that contains the start and end dates of all given ranges
#' sorted and disambiguated
get.bin.dates.from.ranges = function(ranges) {
dates = sort(unique(get.date.from.unix.timestamp(unlist(ranges))))
return(dates)
}

#' Get the data from a data frame in a specific range.
#'
Expand Down Expand Up @@ -1012,13 +1022,3 @@ get.data.from.range = function(range, data) {
}
}

#' Obtain the start and end dates from given ranges.
#'
#' @param ranges the ranges to get the dates from
#'
#' @return a sorted vector of all the start the end dates of the given ranges
get.bin.dates.from.ranges = function(ranges) {
dates = sort(unname(unique(get.date.from.unix.timestamp(unlist(ranges)))))
return(dates)
}

7 changes: 4 additions & 3 deletions util-networks.R
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ NetworkBuilder = R6::R6Class("NetworkBuilder",
## we would need to guess the correct direction.
if (!private$network.conf$get.entry("artifact.directed")) {

## obtain add_link events from jira
## obtain 'add_link' events from jira
jira.add.links = add.links[add.links$issue.source == "jira", ]
matched = c()

Expand All @@ -506,18 +506,19 @@ NetworkBuilder = R6::R6Class("NetworkBuilder",

add.link = jira.add.links[i, ]
if (all(add.link %in% matched)) {
## make sure to not remove both duplicate edges
next
}

## match any add_link events, that are the reverse direction of 'add.link',
## match any 'add_link' events, that are the reverse direction of 'add.link',
## but the same timestamp and author information.
match = jira.add.links[(
jira.add.links$issue.id == add.link$event.info.1 &
jira.add.links$event.info.1 == add.link$issue.id &
jira.add.links$date == add.link$date &
jira.add.links$author.name == add.link$author.name), ]

## if a match is found, remove 'add.link' and its corresponding referenced_by event
## if a match is found, remove 'add.link' and its corresponding 'referenced_by' event
if (nrow(match) > 0) {
add.links = add.links[!(
add.links$issue.id == match$issue.id &
Expand Down
4 changes: 2 additions & 2 deletions util-split.R
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ split.data.activity.based = function(project.data, activity.type = c("commits",

## Both, the last sliding range and the last regular range end at the very last item.
## This is the case because the end of the data is never cropped (like the beginning is).
## split.data.activity.based, which is invoked to obtain both set of ranges, creates
## 'split.data.activity.based', which is invoked to obtain both set of ranges, creates
## ranges until all elements are in one.
##
## The conditional below inspects whether the very last item is in the first or the second
Expand Down Expand Up @@ -736,7 +736,7 @@ split.network.activity.based = function(network, number.edges = 5000, number.win

## Both, the last sliding network and the last regular network end at the very last edge.
## This is the case because the end of the edges is never cropped (like the beginning is).
## Both split.network.activity.based, and split.network.by.bins, which are invoked to obtain
## Both 'split.network.activity.based', and 'split.network.by.bins', which are invoked to obtain
## the two set of networks, creates networks until all edges are contained.
##
## The conditional below inspects whether the very last edge is in the first or the second
Expand Down

0 comments on commit 2497e23

Please sign in to comment.