I have a simple code to print the rows and columns of a CSV file. This is my code and the cyclomatic complexity is coming out to be 6 for this class. I want to reduce it to as low as possible.
class PrintCSV
{
/// <summary>
/// Print all the rows of CSV File
/// </summary>
/// <param name="lines"> </param>
public static void PrintCSVRows(string[] lines)
{
foreach (string line in lines)
{
if (!string.IsNullOrEmpty(line) && line.Contains(','))
{
string columns = line.Split(',')[1];
if (!string.IsNullOrEmpty(columns))
{
PrintCSVCol(columns);
}
}
}
}
/// <summary>
/// Prints the column of CSV File
/// </summary>
/// <param name="columns"></param>
public static void PrintCSVCol(string columns)
{
Console.WriteLine("{0}", columns);
}
}
How do I change the loops to reduce the overall cyclomatic complexity??