< Summary

Information
Class: DirectSight.ReportConfiguration
Assembly DirectSight
File(s): /home/runner/work/DirectSight/DirectSight/DirectSight/ReportConfiguration.cs
Line coverage
87%
Covered lines: 49
Uncovered lines: 7
Coverable lines: 56
Total lines: 120
Line coverage: 87.5%
Branch coverage
87%
Covered branches: 14
Total branches: 16
Branch coverage: 87.5%
Method coverage

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
.ctor(...)87.5%161685.41%

File(s)

/home/runner/work/DirectSight/DirectSight/DirectSight/ReportConfiguration.cs

#LineLine coverage
 1using System;
 2using System.Collections.Generic;
 3using System.Linq;
 4using DirectSight.Common;
 5
 6namespace DirectSight;
 7
 8/// <summary>
 9/// Provides all parameters that are required for report generation.
 10/// </summary>
 11public class ReportConfiguration
 12{
 13    /// <summary>
 14    /// The report files.
 15    /// </summary>
 1116    private readonly List<string> reportFiles = [];
 17
 18    /// <summary>
 19    /// The report file pattern that could not be parsed.
 20    /// </summary>
 1121    private readonly List<string> invalidReportFilePatterns = [];
 22
 23    /// <summary>
 24    /// Initializes a new instance of the <see cref="ReportConfiguration" /> class.
 25    /// </summary>
 26    /// <param name="reportFilePatterns">The report file patterns.</param>
 27    /// <param name="targetDirectory">The target directory.</param>
 28    /// <param name="debugMode">The indicator for debug mode.</param>
 1129    public ReportConfiguration(
 1130        IEnumerable<string> reportFilePatterns,
 1131        string targetDirectory,
 1132        string debugMode)
 1133    {
 1134        ArgumentNullException.ThrowIfNull(reportFilePatterns);
 35
 1136        var seen = new HashSet<string>();
 37
 5738        foreach (var reportFilePattern in reportFilePatterns)
 1239        {
 40            try
 1241            {
 1242                var files = GlobbingFileSearch.GetFiles(reportFilePattern);
 43
 1244                if (files.Any())
 945                {
 4546                    foreach (var file in files)
 947                    {
 948                        if (seen.Add(file))
 949                        {
 950                            this.reportFiles.Add(file);
 951                        }
 952                    }
 953                }
 54                else
 355                {
 356                    this.invalidReportFilePatterns.Add(reportFilePattern);
 357                }
 1258            }
 059            catch (Exception)
 060            {
 061                this.invalidReportFilePatterns.Add(reportFilePattern);
 062            }
 1263        }
 64
 1165        this.TargetDirectory = targetDirectory ?? throw new ArgumentNullException(nameof(targetDirectory));
 66
 1167        if (debugMode != null)
 1168        {
 1169            this.DebugModeValid = bool.TryParse(debugMode, out bool parsedDebugMode);
 70
 1171            if (this.DebugModeValid)
 1072            {
 1073                if (parsedDebugMode == true)
 174                {
 175                    this.DebugMode = true;
 176                }
 1077            }
 1178        }
 79        else
 080        {
 081            this.DebugModeValid = true;
 082        }
 1183    }
 84
 85    /// <summary>
 86    /// Gets the report files.
 87    /// </summary>
 2288    public IReadOnlyCollection<string> ReportFiles => this.reportFiles;
 89
 90    /// <summary>
 91    /// Gets the target directory.
 92    /// </summary>
 10193    public string TargetDirectory { get; }
 94
 95    /// <summary>
 96    /// Gets the plugins.
 97    /// </summary>
 1898    public IReadOnlyCollection<string> Plugins { get; } = [];
 99
 100    /// <summary>
 101    /// Gets whether to run the generator in debug mode (more verbose).
 102    /// </summary>
 5103    public bool DebugMode { get; }
 104
 105    /// <summary>
 106    /// Gets the invalid file patters supplied by the user.
 107    /// </summary>
 108    public IReadOnlyCollection<string> InvalidReportFilePatterns
 109    {
 110        get
 11111        {
 11112            return this.invalidReportFilePatterns;
 11113        }
 114    }
 115
 116    /// <summary>
 117    /// Gets a value indicating whether the debug mode was successfully parsed during initialization.
 118    /// </summary>
 32119    public bool DebugModeValid { get; private set; }
 120}