Skip to content
This repository was archived by the owner on Jul 3, 2020. It is now read-only.

Commit b4a0669

Browse files
committed
add code documentation and fix code formatting
- docs: add code documentation - codestyle: fix formatting Signed-off-by: Luís Ferreira <[email protected]>
1 parent 92dc29a commit b4a0669

File tree

16 files changed

+222
-14
lines changed

16 files changed

+222
-14
lines changed

src/Models/DotCover/ClassCoverage.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,26 @@
44

55
namespace Codacy.CSharpCoverage.Models.DotCover
66
{
7+
/// <summary>
8+
/// Class coverage.
9+
/// This represents a class coverage parsed from
10+
/// DotCover format.
11+
/// </summary>
712
public sealed class ClassCoverage
813
{
14+
/// <summary>
15+
/// Parsed coverage percentage
16+
/// </summary>
917
public double CoveragePercent { get; set; }
18+
19+
/// <summary>
20+
/// Parsed file id
21+
/// </summary>
1022
public int FileId { get; set; }
23+
24+
/// <summary>
25+
/// Covered lines for the referred file id.
26+
/// </summary>
1127
public List<LineCoverage> CoveredLines { get; set; }
1228

1329
public override bool Equals(object obj)

src/Models/DotCover/LineCoverage.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,25 @@
11
namespace Codacy.CSharpCoverage.Models.DotCover
22
{
3+
/// <summary>
4+
/// Line Coverage.
5+
/// This represents a line coverage parsed from
6+
/// DotCover format.
7+
/// </summary>
38
public sealed class LineCoverage
49
{
10+
/// <summary>
11+
/// Parsed start line number
12+
/// </summary>
513
public int Line { get; set; }
14+
15+
/// <summary>
16+
/// Parsed end line number
17+
/// </summary>
618
public int EndLine { get; set; }
19+
20+
/// <summary>
21+
/// Parsed boolean of the coverage hit.
22+
/// </summary>
723
public bool Covered { get; set; }
824

925
public override bool Equals(object obj)

src/Models/DotCover/Report.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,19 @@
33

44
namespace Codacy.CSharpCoverage.Models.DotCover
55
{
6+
/// <summary>
7+
/// Report model based on DotCover file format.
8+
/// </summary>
69
public sealed class Report : IReport
710
{
11+
/// <summary>
12+
/// List of class coverages for each file id.
13+
/// </summary>
814
public List<ClassCoverage> ClassCoverages { get; set; }
15+
16+
/// <summary>
17+
/// Dictionary of file ids and file paths.
18+
/// </summary>
919
public Dictionary<int, string> FilesList { get; set; }
1020

1121
public override bool Equals(object obj)

src/Models/IReport.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
namespace Codacy.CSharpCoverage.Models
22
{
3+
/// <summary>
4+
/// Report interface.
5+
/// This implements a report format model.
6+
/// </summary>
37
public interface IReport
48
{
59
}

src/Models/OpenCover/ClassCoverage.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,26 @@
44

55
namespace Codacy.CSharpCoverage.Models.OpenCover
66
{
7+
/// <summary>
8+
/// Class coverage.
9+
/// This contains, for each file id, the class coverage
10+
/// parsed from the OpenCover format.
11+
/// </summary>
712
public sealed class ClassCoverage
813
{
14+
/// <summary>
15+
/// Parsed sequence coverage (in percentage)
16+
/// </summary>
917
public double SequenceCoverage { get; set; }
18+
19+
/// <summary>
20+
/// Parsed file id.
21+
/// </summary>
1022
public int FileId { get; set; }
23+
24+
/// <summary>
25+
/// List of covered lines of the referred file id.
26+
/// </summary>
1127
public List<LineCoverage> CoveredLines { get; set; }
1228

1329
public override bool Equals(object obj)

src/Models/OpenCover/LineCoverage.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
11
namespace Codacy.CSharpCoverage.Models.OpenCover
22
{
3+
/// <summary>
4+
/// Line coverage.
5+
/// This contains the line number and the visit count of that line
6+
/// in terms of coverage. This is based OpenCover file format.
7+
/// </summary>
38
public sealed class LineCoverage
49
{
10+
/// <summary>
11+
/// Parsed line number
12+
/// </summary>
513
public int LineNumber { get; set; }
14+
15+
/// <summary>
16+
/// Parsed coverage visit count
17+
/// </summary>
618
public int VisitCount { get; set; }
719

820
public override bool Equals(object obj)

src/Models/OpenCover/ModuleElement.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,22 @@
33

44
namespace Codacy.CSharpCoverage.Models.OpenCover
55
{
6+
/// <summary>
7+
/// Module element.
8+
/// This contains Module elements parsed from OpenCover format.
9+
/// This has a dictionary of file ids and file paths. It also has
10+
/// a list of class coverages for each file id.
11+
/// </summary>
612
public sealed class ModuleElement
713
{
14+
/// <summary>
15+
/// Dictionary of file ids and file paths.
16+
/// </summary>
817
public Dictionary<int, string> FilesList { get; set; }
18+
19+
/// <summary>
20+
/// List of class coverages for each file id.
21+
/// </summary>
922
public List<ClassCoverage> ClassCoverages { get; set; }
1023

1124
public override bool Equals(object obj)

src/Models/OpenCover/Report.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,14 @@
33

44
namespace Codacy.CSharpCoverage.Models.OpenCover
55
{
6+
/// <summary>
7+
/// Report model based on OpenCover file format.
8+
/// </summary>
69
public sealed class Report : IReport
710
{
11+
/// <summary>
12+
/// List of module elements
13+
/// </summary>
814
public List<ModuleElement> ModuleElements { get; set; }
915

1016
public override bool Equals(object obj)

src/Models/Result/CodacyReport.cs

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,50 @@
11
using System;
22
using System.Collections.Generic;
3-
using System.IO;
43
using System.Linq;
54
using System.Text;
65
using Newtonsoft.Json;
76

87
namespace Codacy.CSharpCoverage.Models.Result
98
{
9+
/// <summary>
10+
/// Codacy report model.
11+
/// This represents the codacy report format.
12+
/// </summary>
1013
public class CodacyReport
1114
{
15+
/// <summary>
16+
/// File reports constructor.
17+
/// This construct a codacy report using a list of
18+
/// file reports.
19+
/// </summary>
20+
/// <param name="fileReports">list of file reports</param>
1221
public CodacyReport(IEnumerable<FileInfo> fileReports)
1322
{
1423
var totalTuple = fileReports
1524
.Select(f => (Covered: f.Coverage.Count(l => l.Value > 0), Total: f.Coverage.Count))
1625
.Aggregate((Covered: 0, Total: 0),
1726
(t, n) => t = (Covered: t.Covered + n.Covered, Total: t.Total + n.Total));
1827

19-
Total = Convert.ToInt32(Math.Round(((double) totalTuple.Covered / totalTuple.Total * 100)));
28+
Total = Convert.ToInt32(Math.Round((double) totalTuple.Covered / totalTuple.Total * 100));
2029
FileReports = fileReports;
2130
}
2231

23-
[JsonProperty(PropertyName = "total")] public int Total { get; set; }
32+
/// <summary>
33+
/// Total of coverage (in percentage)
34+
/// </summary>
35+
[JsonProperty(PropertyName = "total")]
36+
public int Total { get; set; }
2437

38+
/// <summary>
39+
/// List of file reports
40+
/// </summary>
2541
[JsonProperty(PropertyName = "fileReports")]
2642
public IEnumerable<FileInfo> FileReports { get; set; }
2743

44+
/// <summary>
45+
/// Convert to a string-based json format.
46+
/// </summary>
47+
/// <returns>string-based json format</returns>
2848
public override string ToString()
2949
{
3050
return JsonConvert.SerializeObject(this,
@@ -35,12 +55,18 @@ public override string ToString()
3555
});
3656
}
3757

58+
/// <summary>
59+
/// Get a pretty summary of this coverage report file.
60+
/// </summary>
61+
/// <returns>stats summary</returns>
3862
public string GetStats()
3963
{
4064
var stringBuilder = new StringBuilder($"Coverage report:{Environment.NewLine}{Environment.NewLine}");
4165

4266
foreach (var file in FileReports)
67+
{
4368
stringBuilder.Append($" {file.Total} %\t{file.Filename}{Environment.NewLine}");
69+
}
4470

4571
stringBuilder.Append($"{Environment.NewLine}Total Coverage: {Total}%");
4672

src/Models/Result/FileInfo.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,28 @@
44

55
namespace Codacy.CSharpCoverage.Models.Result
66
{
7+
/// <summary>
8+
/// File info.
9+
/// This represents the coverage information of
10+
/// a single file.
11+
/// </summary>
712
public class FileInfo
813
{
14+
/// <summary>
15+
/// File name
16+
/// </summary>
917
[JsonProperty(PropertyName = "filename")]
1018
public string Filename { get; set; }
1119

12-
[JsonProperty(PropertyName = "total")] public int Total { get; set; }
20+
/// <summary>
21+
/// Total of coverage (in percentage)
22+
/// </summary>
23+
[JsonProperty(PropertyName = "total")]
24+
public int Total { get; set; }
1325

26+
/// <summary>
27+
/// Dictionary of file line and coverage hits.
28+
/// </summary>
1429
[JsonProperty(PropertyName = "coverage")]
1530
public Dictionary<int, int> Coverage { get; set; }
1631

0 commit comments

Comments
 (0)