Skip to content

Commit 55833f5

Browse files
authored
Fix items discovered via SonarCloud (#58)
1 parent 53765ac commit 55833f5

3 files changed

Lines changed: 5 additions & 29 deletions

File tree

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
[![NuGet](https://img.shields.io/nuget/v/CSVFile.svg?style=plastic)](https://www.nuget.org/packages/CSVFile/)
22
![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/tspence/csharp-csv-reader/dotnet.yml?branch=main)
3-
[![SonarCloud Coverage](https://sonarcloud.io/api/project_badges/measure?project=tspence_csharp-csv-reader&metric=coverage)](https://sonarcloud.io/component_measures/metric/coverage/list?id=tspence_csharp-csv-reader)
4-
[![SonarCloud Bugs](https://sonarcloud.io/api/project_badges/measure?project=tspence_csharp-csv-reader&metric=bugs)](https://sonarcloud.io/component_measures/metric/reliability_rating/list?id=tspence_csharp-csv-reader)
5-
[![SonarCloud Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=tspence_csharp-csv-reader&metric=vulnerabilities)](https://sonarcloud.io/component_measures/metric/security_rating/list?id=tspence_csharp-csv-reader)
3+
[![SonarCloud Coverage](https://sonarcloud.io/api/project_badges/measure?project=tspence_csharp-csv-reader&metric=coverage)](https://sonarcloud.io/component_measures?id=tspence_csharp-csv-reader&metric=coverage&view=list)
4+
[![SonarCloud Bugs](https://sonarcloud.io/api/project_badges/measure?project=tspence_csharp-csv-reader&metric=bugs)](https://sonarcloud.io/project/issues?resolved=false&types=BUG&id=tspence_csharp-csv-reader)
5+
[![SonarCloud Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=tspence_csharp-csv-reader&metric=vulnerabilities)](https://sonarcloud.io/project/issues?resolved=false&types=VULNERABILITY&id=tspence_csharp-csv-reader)
66

77
# CSVFile
88
This library is a series of unit tested, thoroughly commented CSV parsing functions which I have developed off and on since 2006. Extremely small and easy to implement; includes unit tests for the majority of odd CSV edge cases. Library supports different delimiters, qualifiers, and embedded newlines. Can read and write from data tables.

src/CSV.cs

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -320,30 +320,6 @@ internal static string RemoveByteOrderMarker(string rawString)
320320
sb.Append(line);
321321
}
322322

323-
/// <summary>
324-
/// Append an array of objects to a StringBuilder in CSV format
325-
/// </summary>
326-
/// <param name="sb">The StringBuilder to append</param>
327-
/// <param name="row">The list of objects to append</param>
328-
/// <param name="settings">The CSV settings to use when exporting this array (Default: CSV)</param>
329-
#if NET2_0
330-
private static void AppendCSVRow(StringBuilder sb, IEnumerable<object> row, CSVSettings settings = null)
331-
#else
332-
private static void AppendCSVRow(this StringBuilder sb, IEnumerable<object> row, CSVSettings settings = null)
333-
#endif
334-
{
335-
if (settings == null)
336-
{
337-
settings = CSVSettings.CSV;
338-
}
339-
340-
var riskyChars = settings.GetRiskyChars();
341-
var forceQualifierTypes = settings.GetForceQualifierTypes();
342-
var csv = ItemsToCsv(row, settings, riskyChars, forceQualifierTypes);
343-
sb.Append(csv);
344-
sb.Append(settings.LineSeparator);
345-
}
346-
347323
/// <summary>
348324
/// Internal method to convert a list of things into a CSV line using the specified settings object
349325
///
@@ -394,7 +370,7 @@ internal static string ItemsToCsv(IEnumerable<object> items, CSVSettings setting
394370
// Only go character-by-character if necessary
395371
if (s.IndexOf(settings.TextQualifier) >= 0)
396372
{
397-
foreach (var c in s.ToCharArray())
373+
foreach (var c in s)
398374
{
399375
// Double up text qualifiers
400376
if (c == settings.TextQualifier)

src/CSVSettings.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ public char[] GetRiskyChars()
172172
var riskyChars = new List<char>();
173173
riskyChars.Add(FieldDelimiter);
174174
riskyChars.Add(TextQualifier);
175-
foreach (var c in LineSeparator.ToCharArray())
175+
foreach (var c in LineSeparator)
176176
{
177177
riskyChars.Add(c);
178178
}

0 commit comments

Comments
 (0)