Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions CodeLineCounter.Tests/CsvExporterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,11 @@ public void ExportToCsv_NullData_ThrowsNullReferenceException()
{
// Arrange
string filePath = "test3.csv";
List<NamespaceMetrics> namespaceMetrics = null;//new List<NamespaceMetrics>();
Dictionary<string, int> projectTotals = null;
int totalLines = 0;
List<DuplicationCode> duplicationCodes = null;
string? additionalInfo = null;

// Act & Assert
Assert.Throws<NullReferenceException>(() => CsvExporter.ExportToCsv(filePath, namespaceMetrics, projectTotals, totalLines, duplicationCodes, additionalInfo));
#pragma warning disable CS8625
Assert.Throws<NullReferenceException>(() => CsvExporter.ExportToCsv(filePath, null, null, totalLines, null, null));
}

[Fact]
Expand Down
6 changes: 4 additions & 2 deletions CodeLineCounter/Services/CodeAnalyzer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,11 @@ public static void AnalyzeSourceCode(Dictionary<string, int> projectNamespaceMet
{
currentNamespace = null;
fileLineCount = 0;
fileCyclomaticComplexity = 0;

var tree = CSharpSyntaxTree.ParseText(File.ReadAllText(file));
// lines variable should contain all source code lines
string sourceCode = string.Join(Environment.NewLine, lines);
var tree = CSharpSyntaxTree.ParseText(sourceCode);

var compilation = CSharpCompilation.Create("CodeAnalysis", new[] { tree });
var model = compilation.GetSemanticModel(tree);

Expand Down
2 changes: 1 addition & 1 deletion generate-covertura.cmd
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
rem echo off
echo
rem - remove older test results
rmdir /s /q CodeLineCounter.Tests\TestResults
if exist rmdir /s /q CodeLineCounter.Tests\TestResults
rem - collect code coverage
dotnet test --collect:"XPlat Code Coverage;Format=json,lcov,cobertura" --results-directory CodeLineCounter.Tests\TestResults --logger trx;LogFileName=testresults.trx