< Summary

Information
Class: DirectSight.Parser.Analysis.Assembly
Assembly DirectSight
File(s): /home/runner/work/DirectSight/DirectSight/DirectSight/Parser/Analysis/Assembly.cs
Line coverage
89%
Covered lines: 49
Uncovered lines: 6
Coverable lines: 55
Total lines: 207
Line coverage: 89%
Branch coverage
70%
Covered branches: 14
Total branches: 20
Branch coverage: 70%
Method coverage

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
.ctor(...)50%22100%
ToString()100%110%
Equals(...)100%44100%
GetHashCode()100%110%
AddClass(...)100%11100%
Merge(...)83.33%6688.23%

File(s)

/home/runner/work/DirectSight/DirectSight/DirectSight/Parser/Analysis/Assembly.cs

#LineLine coverage
 1using System;
 2using System.Collections.Concurrent;
 3using System.Collections.Generic;
 4using System.Linq;
 5using DirectSight.Common;
 6
 7namespace DirectSight.Parser.Analysis;
 8
 9/// <summary>
 10/// Represents one assembly.
 11/// </summary>
 12public class Assembly
 13{
 14    /// <summary>
 15    /// List of classes in assembly.
 16    /// </summary>
 10117    private readonly ConcurrentQueue<Class> classes = new ConcurrentQueue<Class>();
 18
 19    /// <summary>
 20    /// Initializes a new instance of the <see cref="Assembly"/> class.
 21    /// </summary>
 22    /// <param name="name">The name of the assembly.</param>
 10123    internal Assembly(string name)
 10124    {
 10125        this.Name = name ?? throw new ArgumentNullException(nameof(name));
 10126    }
 27
 28    /// <summary>
 29    /// Gets the list of classes in assembly.
 30    /// </summary>
 116231    public IEnumerable<Class> Classes => this.classes.OrderBy(c => c.Name);
 32
 33    /// <summary>
 34    /// Gets the name of the assembly.
 35    /// </summary>
 268336    public string Name { get; }
 37
 38    /// <summary>
 39    /// Gets the short name of the assembly.
 40    /// </summary>
 41    /// <value>The short name of the assembly.</value>
 42    public string ShortName
 43    {
 44        get
 18145        {
 18146            string shortName = this.Name;
 18147            return shortName.Substring(shortName.LastIndexOf('/') + 1);
 18148        }
 49    }
 50
 51    /// <summary>
 52    /// Gets the number of covered lines.
 53    /// </summary>
 54    /// <value>The covered lines.</value>
 87455    public int CoveredLines => this.classes.SafeSum(c => c.CoveredLines);
 56
 57    /// <summary>
 58    /// Gets the number of coverable lines.
 59    /// </summary>
 60    /// <value>The coverable lines.</value>
 140661    public int CoverableLines => this.classes.SafeSum(c => c.CoverableLines);
 62
 63    /// <summary>
 64    /// Gets the number of total lines.
 65    /// </summary>
 66    /// <value>The total lines.</value>
 11467    public int? TotalLines => this.classes.SafeSum(c => c.TotalLines);
 68
 69    /// <summary>
 70    /// Gets the coverage quota of the class.
 71    /// </summary>
 72    /// <value>The coverage quota.</value>
 1273    public decimal? CoverageQuota => (this.CoverableLines == 0) ? (decimal?)null : MathExtensions.CalculatePercentage(th
 74
 75    /// <summary>
 76    /// Gets the number of covered branches.
 77    /// </summary>
 78    /// <value>
 79    /// The number of covered branches.
 80    /// </value>
 87481    public int? CoveredBranches => this.classes.SafeSum(f => f.CoveredBranches);
 82
 83    /// <summary>
 84    /// Gets the number of total branches.
 85    /// </summary>
 86    /// <value>
 87    /// The number of total branches.
 88    /// </value>
 140689    public int? TotalBranches => this.classes.SafeSum(f => f.TotalBranches);
 90
 91    /// <summary>
 92    /// Gets the branch coverage quota of the class.
 93    /// </summary>
 94    /// <value>The branch coverage quota.</value>
 1295    public decimal? BranchCoverageQuota => (this.TotalBranches == 0) ? (decimal?)null : MathExtensions.CalculatePercenta
 96
 97    /// <summary>
 98    /// Gets the number of covered code elements.
 99    /// </summary>
 100    /// <value>
 101    /// The number of covered code elements.
 102    /// </value>
 228103    public int CoveredCodeElements => this.classes.SafeSum(f => f.CoveredCodeElements);
 104
 105    /// <summary>
 106    /// Gets the number of fully covered code elements.
 107    /// </summary>
 108    /// <value>
 109    /// The number of fully covered code elements.
 110    /// </value>
 228111    public int FullCoveredCodeElements => this.classes.SafeSum(f => f.FullCoveredCodeElements);
 112
 113    /// <summary>
 114    /// Gets the number of total code elements.
 115    /// </summary>
 116    /// <value>
 117    /// The number of total code elements.
 118    /// </value>
 684119    public int TotalCodeElements => this.classes.SafeSum(f => f.TotalCodeElements);
 120
 121    /// <summary>
 122    /// Gets the code elements coverage quota.
 123    /// </summary>
 124    /// <value>The code elements coverage quota.</value>
 4125    public decimal? CodeElementCoverageQuota => (this.TotalCodeElements == 0) ? (decimal?)null : MathExtensions.Calculat
 126
 127    /// <summary>
 128    /// Gets the full code elements coverage quota.
 129    /// </summary>
 130    /// <value>The full code elements coverage quota.</value>
 4131    public decimal? FullCodeElementCoverageQuota => (this.TotalCodeElements == 0) ? (decimal?)null : MathExtensions.Calc
 132
 133    /// <summary>
 134    /// Returns a <see cref="string" /> that represents this instance.
 135    /// </summary>
 136    /// <returns>
 137    /// A <see cref="string" /> that represents this instance.
 138    /// </returns>
 139    public override string ToString()
 0140    {
 0141        return this.Name;
 0142    }
 143
 144    /// <summary>
 145    /// Determines whether the specified <see cref="object"/> is equal to this instance.
 146    /// </summary>
 147    /// <param name="obj">The <see cref="object"/> to compare with this instance.</param>
 148    /// <returns>
 149    ///   <c>true</c> if the specified <see cref="object"/> is equal to this instance; otherwise, <c>false</c>.
 150    /// </returns>
 151    public override bool Equals(object obj)
 375152    {
 375153        if (obj == null || !obj.GetType().Equals(typeof(Assembly)))
 2154        {
 2155            return false;
 156        }
 157        else
 373158        {
 373159            var assembly = (Assembly)obj;
 373160            return assembly.Name.Equals(this.Name);
 161        }
 375162    }
 163
 164    /// <summary>
 165    /// Returns a hash code for this instance.
 166    /// </summary>
 167    /// <returns>
 168    /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.
 169    /// </returns>
 0170    public override int GetHashCode() => this.Name.GetHashCode();
 171
 172    /// <summary>
 173    /// Adds the given class to the assembly.
 174    /// </summary>
 175    /// <param name="class">The class to add.</param>
 176    internal void AddClass(Class @class)
 1472177    {
 1472178        this.classes.Enqueue(@class);
 1472179    }
 180
 181    /// <summary>
 182    /// Merges the given assembly with the current instance.
 183    /// </summary>
 184    /// <param name="assembly">The assembly to merge.</param>
 185    internal void Merge(Assembly assembly)
 24186    {
 24187        if (assembly == null)
 0188        {
 0189            throw new ArgumentNullException(nameof(assembly));
 190        }
 191
 814192        foreach (var @class in assembly.classes)
 371193        {
 3596194            var existingClass = this.classes.FirstOrDefault(c => c.Equals(@class));
 195
 371196            if (existingClass != null)
 370197            {
 370198                existingClass.Merge(@class);
 370199            }
 200            else
 1201            {
 1202                this.AddClass(@class);
 1203                @class.Assembly = this;
 1204            }
 371205        }
 24206    }
 207}