[codeface] [PATCH 4/4] Skip time-series analysis if too few releases are given

  • From: Claus Hunsen <hunsen@xxxxxxxxxxxxxxxxx>
  • To: codeface@xxxxxxxxxxxxx
  • Date: Fri, 1 Apr 2016 13:06:52 +0200

The time-series analysis prints an error message to the console if two
or less releases are present in the current configuration. However, the
analysis is continued and cosequently produces errors and stack-traces
in the console output.

To prevent obfuscated console output and confusion on the user side, the
time-series analysis now only logs a warning message and skips the
analysis if too few releases are given. As the previously given error
was not actually an error, this is the obvious solution.

Signed-off-by: Claus Hunsen <hunsen@xxxxxxxxxxxxxxxxx>
---
 codeface/R/analyse_ts.r | 12 +++++++-----
 codeface/R/ts_utils.r   |  4 +++-
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/codeface/R/analyse_ts.r b/codeface/R/analyse_ts.r
index 97998cd..49c443f 100755
--- a/codeface/R/analyse_ts.r
+++ b/codeface/R/analyse_ts.r
@@ -606,12 +606,14 @@ do.release.analysis <- function(resdir, graphdir, conf) {
   plot.id <- get.clear.plot.id(conf, plot.name)
 
   dat <- compute.release.distance(series.merged, conf)
-  dat <- data.frame(time=as.character(conf$boundaries$date.end[-1]), value=dat,
-                    value_scaled=dat, plotId=plot.id)
+  if (!is.na(dat)) { # if too few revisions are present, skip further analysis
+    dat <- data.frame(time=as.character(conf$boundaries$date.end[-1]), 
value=dat,
+                      value_scaled=dat, plotId=plot.id)
 
-  res <- dbWriteTable(conf$con, "timeseries", dat, append=TRUE, 
row.names=FALSE)
-  if (!res) {
-    stop("Internal error: Could not write release distance TS into database!")
+    res <- dbWriteTable(conf$con, "timeseries", dat, append=TRUE, 
row.names=FALSE)
+    if (!res) {
+      stop("Internal error: Could not write release distance TS into 
database!")
+    }
   }
 
   ## TODO: Compute the difference between release cycles and a
diff --git a/codeface/R/ts_utils.r b/codeface/R/ts_utils.r
index e1aa191..1c4c780 100644
--- a/codeface/R/ts_utils.r
+++ b/codeface/R/ts_utils.r
@@ -81,6 +81,7 @@ compute.ts.distance <- function(series1, series2) {
 
 ## Compute the distance between a specific time series of a project
 ## for all subsequent releases
+## Returns NA if only 2 or less revisions are present
 compute.release.distance <- function(series.merged, conf) {
   series <- gen.series(series.merged, "Averaged (large window)")
   series <- split.by.ranges(series, conf$boundaries)
@@ -88,8 +89,9 @@ compute.release.distance <- function(series.merged, conf) {
   ## Number of series is equal to (1 - number of revisions) provided
   ## by the configuration file
   if(length(series) < 2) {
-    logerror("Less than 3 revisions provided by configuration file",
+    logwarn("Less than 3 revisions provided by configuration file, skipping 
analysis",
              logger="ts_ulits")
+    return(NA)
   }
 
   res <- sapply(1:(length(series)-1), function(i) {
-- 
2.8.0


Other related posts:

  • » [codeface] [PATCH 4/4] Skip time-series analysis if too few releases are given - Claus Hunsen