org.hackystat.telemetry.analyzer.reducer.impl
Class CyclomaticComplexityReducer

java.lang.Object
  extended by org.hackystat.telemetry.analyzer.reducer.impl.CyclomaticComplexityReducer
All Implemented Interfaces:
TelemetryReducer

public class CyclomaticComplexityReducer
extends java.lang.Object
implements TelemetryReducer

Returns a single stream providing a Cyclomatic Complexity value.

Options:

  1. mode: One of 'TotalMethods', 'TotalLines' 'TotalComplexity', 'AverageComplexityPerMethod', or 'TotalMethodsAboveComplexityThreshold'. Default is 'AverageComplexityPerMethod'
  2. threshold: A string indicating the threshold value. Defaults to '10', which is the generally accepted threshold. This parameter is ignored unless the mode is 'TotalMethodsAboveComplexityThreshold', in which case it must be parsed to an integer.
  3. tool: The tool whose sensor data is to be used to calculate the complexity value. Defaults to 'JavaNCSS'.

Author:
Philip Johnson

Nested Class Summary
static class CyclomaticComplexityReducer.Mode
          Possible mode values.
 
Constructor Summary
CyclomaticComplexityReducer()
           
 
Method Summary
 TelemetryStreamCollection compute(org.hackystat.sensorbase.resource.projects.jaxb.Project project, org.hackystat.dailyprojectdata.client.DailyProjectDataClient dpdClient, org.hackystat.utilities.time.interval.Interval interval, java.lang.String[] options)
          Computes and returns the required telemetry streams object.
(package private)  java.lang.Double getData(org.hackystat.dailyprojectdata.client.DailyProjectDataClient dpdClient, org.hackystat.sensorbase.resource.projects.jaxb.Project project, org.hackystat.utilities.time.period.Day startDay, org.hackystat.utilities.time.period.Day endDay, CyclomaticComplexityReducer.Mode mode, int threshold, java.lang.String tool)
          Returns a Complexity value for the specified time interval, or null if no SensorData.
(package private)  TelemetryStream getStream(org.hackystat.dailyprojectdata.client.DailyProjectDataClient dpdClient, org.hackystat.sensorbase.resource.projects.jaxb.Project project, org.hackystat.utilities.time.interval.Interval interval, CyclomaticComplexityReducer.Mode mode, int threshold, java.lang.String tool, java.lang.Object streamTagValue)
          Gets the telemetry stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CyclomaticComplexityReducer

public CyclomaticComplexityReducer()
Method Detail

compute

public TelemetryStreamCollection compute(org.hackystat.sensorbase.resource.projects.jaxb.Project project,
                                         org.hackystat.dailyprojectdata.client.DailyProjectDataClient dpdClient,
                                         org.hackystat.utilities.time.interval.Interval interval,
                                         java.lang.String[] options)
                                  throws TelemetryReducerException
Computes and returns the required telemetry streams object.

Specified by:
compute in interface TelemetryReducer
Parameters:
project - The project.
dpdClient - The DPD Client.
interval - The interval.
options - The optional parameters.
Returns:
Telemetry stream collection.
Throws:
TelemetryReducerException - If there is any error.

getStream

TelemetryStream getStream(org.hackystat.dailyprojectdata.client.DailyProjectDataClient dpdClient,
                          org.hackystat.sensorbase.resource.projects.jaxb.Project project,
                          org.hackystat.utilities.time.interval.Interval interval,
                          CyclomaticComplexityReducer.Mode mode,
                          int threshold,
                          java.lang.String tool,
                          java.lang.Object streamTagValue)
                    throws java.lang.Exception
Gets the telemetry stream.

Parameters:
dpdClient - The DailyProjectData client we will contact for the data.
project - The project.
interval - The interval.
mode - The mode.
threshold - The threshold (if mode is TOTALABOVETHRESHOLD).
tool - The tool whose sensor data will be used.
streamTagValue - The tag for the generated telemetry stream.
Returns:
The telemetry stream as required.
Throws:
java.lang.Exception - If there is any error.

getData

java.lang.Double getData(org.hackystat.dailyprojectdata.client.DailyProjectDataClient dpdClient,
                         org.hackystat.sensorbase.resource.projects.jaxb.Project project,
                         org.hackystat.utilities.time.period.Day startDay,
                         org.hackystat.utilities.time.period.Day endDay,
                         CyclomaticComplexityReducer.Mode mode,
                         int threshold,
                         java.lang.String tool)
                   throws TelemetryReducerException
Returns a Complexity value for the specified time interval, or null if no SensorData. We work backward through the time interval, and return a Complexity value for the first day in the interval for which Cyclomatic Complexity data exists.

Parameters:
dpdClient - The DailyProjectData client we will use to get this data.
project - The project.
startDay - The start day (inclusive).
endDay - The end day (inclusive).
mode - The mode.
threshold - The threshold, if mode is TOTALMETHODSABOVECOMPLEXITYTHRESHOLD.
tool - The tool whose sensor data will be used.
Returns:
The Complexity value, or null if there is no Complexity SensorData in that period.
Throws:
TelemetryReducerException - If anything goes wrong.