Metrics are calculated using Visual Studio.
The first method has CC = 4
private IEnumerable<string> GetRows(DataTable dt, string columnDelimiter) { return from DataRow row in dt.Rows select string.Join(columnDelimiter, row.ItemArray.Select(k => k.ToString())); }
The second method has CC = 5.
private IEnumerable<string> GetRowsForeach(DataTable dt, string columnDelimiter) { var rows = new List<string>(); foreach (DataRow row in dt.Rows) { var rowString = string.Join(columnDelimiter, row.ItemArray.Select(k => k.ToString())); rows.Add(rowString); } return rows; }
I would say that the first method should have CC = 1, and the second, perhaps CC = 1 or maybe 2 (understanding foreach as with the final condition, but I would never say that their CC is so high that I do not understand? / p>
source share