Skip to content

Commit 8354f55

Browse files
committed
[#68] Integrate Model Orphans Reporting
Trying to make it a bit more logical
1 parent 4c40df1 commit 8354f55

File tree

4 files changed

+29
-22
lines changed

4 files changed

+29
-22
lines changed

src/LemonTree.Pipeline.Tools.ModelCheck/Checks/Checks.cs

+7-6
Original file line numberDiff line numberDiff line change
@@ -410,10 +410,10 @@ select count(t_object.Object_Type) as ['Count'], t_object.Object_Type as ['Measu
410410

411411
result.Level = IssueLevel.Information;
412412
result.Title = "Project Statistics";
413+
result.Detail = "Executed Project Statistics on Model";
413414

414415

415-
416-
result.Detail = ToMD(resultTable.DefaultView.ToTable(), header: true);
416+
result.Markdown = ToMD(resultTable.DefaultView.ToTable(), header: true);
417417

418418

419419
#endregion
@@ -447,10 +447,10 @@ internal static Issue CheckTableSize(string model)
447447

448448
result.Level = IssueLevel.Information;
449449
result.Title = "Table Statistics (all >32)";
450+
result.Detail = $"Found {resultTable.Rows.Count} Tables bigger 32";
450451

451452

452-
453-
result.Detail = ToMD(resultTable.DefaultView.ToTable(), header: true);
453+
result.Markdown = ToMD(resultTable.DefaultView.ToTable(), header: true);
454454

455455

456456
#endregion
@@ -497,12 +497,13 @@ AND t_object.ea_guid NOT IN (SELECT t_operation.Behaviour FROM t_operation WHERE
497497
Issue result = new Issue();
498498

499499
result.Level = IssueLevel.Information;
500-
result.Title = "Model Orphans Statistics (all >32)";
500+
result.Title = "Model Orphans Statistics";
501501

502502

503503
if (resultTable.Rows.Count > 0)
504504
{
505-
result.Detail = ToMD(resultTable.DefaultView.ToTable(), header: true);
505+
result.Markdown = ToMD(resultTable.DefaultView.ToTable(), header: true);
506+
result.Detail = $"Found {resultTable.Rows.Count} Orphans in Model";
506507
}
507508
else
508509
{

src/LemonTree.Pipeline.Tools.ModelCheck/Checks/Issue.cs

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ internal class Issue
66
internal string Detail { get; set; }
77
internal string Title { get; set; }
88

9+
internal string Markdown { get; set; }
10+
911
internal string Symbol
1012
{
1113
get

src/LemonTree.Pipeline.Tools.ModelCheck/Checks/Issues.cs

-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ internal string ToMd()
1717
var mySortedList = this.OrderBy(x => x.Level);
1818
foreach (Issue issue in mySortedList)
1919
{
20-
21-
2220
sb.AppendLine($"|{issue.Symbol}|{issue.Level}|{issue.Title}|{issue.Detail}|");
2321
}
2422
return sb.ToString();

src/LemonTree.Pipeline.Tools.ModelCheck/Program.cs

+20-14
Original file line numberDiff line numberDiff line change
@@ -75,49 +75,55 @@ private static int RunModelCheck(ModelCheckOptions opts)
7575

7676
Console.WriteLine(issues.ToString());
7777

78-
StringBuilder sb = new StringBuilder();
79-
sb.AppendLine(issues.ToMd());
80-
sb.AppendLine("# Project Statistics");
81-
sb.AppendLine(Checks.Checks.CheckProjectStatitics(opts.Model).Detail);
78+
8279

80+
Issue resultTableSize = null;
8381
if (opts.TableSize == true)
8482
{
8583
if (ModelAccess.IsSqlLite())
8684
{
87-
var result = Checks.Checks.CheckTableSize(opts.Model);
88-
sb.AppendLine(result.Detail);
89-
issues.AddIfNotNull(result);
85+
resultTableSize = Checks.Checks.CheckTableSize(opts.Model);
86+
87+
issues.AddIfNotNull(resultTableSize);
9088
}
9189
else
9290
{
9391
Console.WriteLine("Talbesize reporting only supported for SqlLite!");
9492
}
9593
}
9694

95+
Issue resultOrphans = null;
9796
if (opts.Orphans == true)
9897
{
9998
if (ModelAccess.IsSqlLite())
10099
{
101-
var result = Checks.Checks.CheckModelOrphans(opts.Model);
102-
sb.AppendLine(result.Detail);
103-
issues.AddIfNotNull(result);
100+
resultOrphans = Checks.Checks.CheckModelOrphans(opts.Model);
101+
issues.AddIfNotNull(resultOrphans);
104102
}
105103
else
106104
{
107105
Console.WriteLine("Orphans reporting only supported for SqlLite!");
108106
}
109107
}
110108

111-
112-
109+
StringBuilder sb = new StringBuilder();
110+
sb.AppendLine(issues.ToMd());
111+
sb.AppendLine("# Project Statistics");
112+
sb.AppendLine(Checks.Checks.CheckProjectStatitics(opts.Model).Markdown);
113+
if (resultTableSize != null)
114+
{
115+
sb.AppendLine(resultTableSize.Markdown);
116+
}
117+
if (resultOrphans != null)
118+
{
119+
sb.AppendLine(resultOrphans.Markdown);
120+
}
113121

114122
if (opts.Out != null)
115123
{
116124
File.WriteAllText(opts.Out, sb.ToString());
117125
}
118126

119-
120-
121127
if (opts.FailOnErrors == true)
122128
{
123129
if (issues.HasErrors())

0 commit comments

Comments
 (0)