i am trying to calculate the cyclomatic complexity of my software but i am a bit confused. From what i understand it is the amounts of paths that are needed to be tested to cover the whole software. Usually there are if statements and loops which cause decisions and therefor increase the path however my code below has no loops or if statements and therefore is it just a complexity of 1?
btn_length.addEventListener (MouseEvent.CLICK, LengthFunc);
function LengthFunc (e: MouseEvent):void
{
gotoAndStop (1,"Scene 2");
}
btn_speed.addEventListener (MouseEvent.CLICK, SpeedFunc);
function SpeedFunc (e: MouseEvent):void
{
gotoAndStop (1,"Scene 6");
}
btn_currency.addEventListener (MouseEvent.CLICK, CurrencyFunc);
function CurrencyFunc (e: MouseEvent):void
{
gotoAndStop (1,"Scene 10");
}
btn_weight.addEventListener (MouseEvent.CLICK, WeightFunc);
function WeightFunc (e: MouseEvent):void
{
gotoAndStop (1,"Scene 11");
}
btn_data.addEventListener (MouseEvent.CLICK, dataFunc);
function dataFunc (e: MouseEvent):void
{
gotoAndStop (1,"Scene 16");
}
stop();
also this class has also a complexity of 1 i believe.
import fl.data.DataProvider;
var dpcurr:DataProvider = new DataProvider();
var fromVal:Number;
var toVal:Number;
var inputValcurr:Number
var resultValcurr:Number;
input_txt.restrict = "0-9\\.\\";
dpcurr.addItem( { label: "EUR, Euro", data: 1.18 });
dpcurr.addItem( { label: "GBP, British Pound", data: 1 });
dpcurr.addItem( { label: "USD, US Dollar", data:1.54});
fromList.dataProvider = dpcurr;
toList.dataProvider = dpcurr;
fromList.addEventListener(Event.CHANGE, calculateResultcurr);
toList.addEventListener(Event.CHANGE, calculateResultcurr);
input_txt.addEventListener(Event.CHANGE, calculateResultcurr);
fromList.selectedIndex = 0;
toList.selectedIndex = 2;
fromVal = fromList.selectedItem.data;
toVal = toList.selectedItem.data;
function calculateResultcurr(e:Event):void{
fromVal = fromList.selectedItem.data;
toVal = toList.selectedItem.data;
inputValcurr = Number(input_txt.text);
resultValcurr = inputValcurr * (fromVal / toVal);
convert_btn.addEventListener(MouseEvent.CLICK, convertcurr);
function convertcurr(evt:MouseEvent):void {
result_txt.text = resultValcurr.toString()}
}
home_btn. addEventListener (MouseEvent. CLICK, homecurr);
function homecurr ( e: MouseEvent ): void {
gotoAndStop (1, "Scene 1" );
}
stop();
if some could just let me know if i am right or wrong i would be grateful. It was a flash project and therefore the code is written in ActionScript 3.