Note that there are some explanatory texts on larger screens.

plurals
  1. POCyclomatic complexity count of 31, where has this come from?
    primarykey
    data
    text
    <p>I'm developing an application that pulls data from an Excel file (I don't have access to the actual database) and I've written a method which has as its only function to pull the data from the Excel Spreadsheet, as seen below.</p> <pre><code>private IEnumerable&lt;SMEntity&gt; ExtractSMData(List&lt;MSExcel.Range&gt; SMData) { List&lt;SMEntity&gt; SMEntities = new List&lt;SMEntity&gt;(); foreach (MSExcel.Range Row in SMData) { SMEntity entity = new SMEntity(); entity.IncidentNumber = Row.get_Range("K1").get_Value(); entity.SRNumber = Row.get_Range("L1").get_Value(); entity.SRCategory = Row.get_Range("M1").get_Value(); entity.SiebelClientCall = EntityConversions.DateTimeConversion(Row.get_Range("N1").get_Value()); entity.SiebelOpenedDate = EntityConversions.DateTimeConversion(Row.get_Range("O1").get_Value()); entity.IncidentOpenDate = EntityConversions.DateTimeConversion(Row.get_Range("P1").get_Value()); entity.PickedUpBeforeClient = Row.get_Range("Q1").get_Value().ToString().ToLowerCase() == "no" ? false : true; entity.OutageStartTime = EntityConversions.DateTimeConversion(Row.get_Range("R1").get_Value()); entity.DetectionPoint = EntityConversions.DateTimeConversion(Row.get_Range("S1").get_Value()); entity.SecondsToDetection = EntityConversions.ConvertDetectionTimeToInt(Row.get_Range("T1").get_Value()); entity.OutageEndTime = EntityConversions.DateTimeConversion(Row.get_Range("U1").get_Value()); entity.MTTR = EntityConversions.ConvertMTTRStringToInt(Row.get_Range("V1").get_Value()); entity.RepairedOnTime = Row.get_Range("W1").get_Value().ToString().ToLowerCase() == "no" ? false : true; SMEntities.Add(entity); } return SMEntities; } </code></pre> <p>I've run Code Analysis (I'm using Visual Studio 2012 and developing in .NET 4.5) and I have a <code>CA1502: Avoid excessive complexity</code> (copied below). As a junior developer (I'm 17) I tried finding out more about this using MSDN however, I'm a little stumped as to why I have a cyclomatic complexity of 33.</p> <blockquote> <p>CA1502</p> <p>Avoid excessive complexity</p> <p><code>'Extraction.ExtractSMData(List&lt;Range&gt;)'</code> has a cyclomatic complexity of 33. Rewrite or refactor the method to reduce complexity to 25.</p> <p><code>Core.Extraction.cs:104</code></p> </blockquote> <p>I can see with my quick-ifs (<code>condition ? if_true : if_false</code>, what are these called?) that it might be bad, but I can still only see it as 5.</p> <p><strong>UPDATE</strong>:</p> <p>Cyclomatic complexity is now at 33...</p> <p>If I comment out <code>entity.IncidentNumber = Row.get_Range("K1").get_Value();</code> the complexity becomes 32. I thought <code>get_Range()</code> and <code>get_Value()</code> were one each but okay...</p> <p>If I comment out <code>entity.RepairedOnTime = Row.get_Range("W1").get_Value().ToString().ToLower() == "no" ? false : true;</code> the complexity becomes 28...</p> <p><code>get_Range()</code>, <code>get_Value()</code>, quick-if is 3, do <code>ToString()</code> and <code>ToLower()</code> count?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload