11using System ;
22using System . Collections . Generic ;
3- using System . IO ;
43using System . Linq ;
54using System . Text ;
65using Newtonsoft . Json ;
76
87namespace 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
0 commit comments