Skip to content

Commit

Permalink
display summary
Browse files Browse the repository at this point in the history
  • Loading branch information
ignatandrei committed Oct 15, 2024
1 parent 09935d5 commit b245261
Show file tree
Hide file tree
Showing 17 changed files with 176 additions and 42 deletions.
7 changes: 7 additions & 0 deletions src/NetPackageAnalyzer/.config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@
"PackageAnalyzer"
],
"rollForward": false
},
"dotnet-depends": {
"version": "0.8.0",
"commands": [
"dotnet-depends"
],
"rollForward": false
}
}
}
2 changes: 1 addition & 1 deletion src/NetPackageAnalyzer/AnalyzeMerge/AnalyzeMerge.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

<ItemGroup>
<PackageReference Include="LibGit2Sharp" Version="0.30.0" />
<PackageReference Include="RazorBlade" Version="0.5.0" PrivateAssets="all" ReferenceOutputAssembly="false" OutputItemType="Analyzer" />
<PackageReference Include="RazorBlade" Version="0.6.0" PrivateAssets="all" ReferenceOutputAssembly="false" OutputItemType="Analyzer" />

</ItemGroup>

Expand Down
28 changes: 21 additions & 7 deletions src/NetPackageAnalyzer/NPA.HtmlData/ExtractImages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,17 @@ public async Task<bool> GetImagesAsync()
{

var dir = Path.GetDirectoryName(HtmlPath)!;
var nameFile= Path.GetFileNameWithoutExtension(HtmlPath);
var imagesDir = Path.Combine(dir, "images");
if (!Directory.Exists(imagesDir))
{
Directory.CreateDirectory(imagesDir);
}
imagesDir = Path.Combine(imagesDir, nameFile);
if (!Directory.Exists(imagesDir))
{
Directory.CreateDirectory(imagesDir);
}
using var playwright = await Playwright.CreateAsync();
await using var browser = await playwright.Chromium.LaunchAsync(new BrowserTypeLaunchOptions()
{
Expand All @@ -37,23 +48,26 @@ public async Task<bool> GetImagesAsync()

var page = await context.NewPageAsync();
//await page.SetContentAsync(File.ReadAllText(HtmlPath));
await page.GotoAsync(new Uri(HtmlPath).AbsoluteUri);
var resp= await page.GotoAsync(new Uri(HtmlPath).AbsoluteUri);
await page.WaitForLoadStateAsync(LoadState.NetworkIdle);

await page.EvaluateAsync("driverObj.destroy()");
var titles = await page.Locator("//div[starts-with(@title,'image')]").AllAsync();
var nr = titles.Count();
Console.WriteLine($"Found {nr} images");
//Console.WriteLine($"Found {nr} images");
for (var i = 0; i < nr; i++)
{
var title = titles[i];
var name=await title.GetAttributeAsync("title");
name=name.Replace("image", "").Trim();

if(string.IsNullOrWhiteSpace(name))
continue;
name =name.Replace("image", "").Trim();
name = name.Replace(" ", "-");
var buffer = await title.ScreenshotAsync();
await File.WriteAllBytesAsync(Path.Combine(dir, $"{name}.png"), buffer);

await File.WriteAllBytesAsync(Path.Combine(imagesDir, $"{name}.png"), buffer);
}
await browser.CloseAsync();
Console.WriteLine("Done in "+dir);
//Console.WriteLine("Done in "+dir);
return true;
}
}
4 changes: 4 additions & 0 deletions src/NetPackageAnalyzer/NPA.HtmlData/NPA.HtmlData.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<NoWarn>CS0436</NoWarn>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>

</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Playwright" Version="1.47.0" />
<PackageReference Include="System.Text.Json" Version="8.0.5" />
</ItemGroup>
</Project>
3 changes: 0 additions & 3 deletions src/NetPackageAnalyzer/NPA.HtmlData/globals.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,3 @@
using System.Threading.Tasks;

namespace NPA.HtmlData;
internal class globals
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
</ItemGroup>
<PropertyGroup>
<Version>8.2024.1014.2028</Version>
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
<PackAsTool>true</PackAsTool>
<ToolCommandName>PackageAnalyzer</ToolCommandName>
<Authors>Andrei Ignat</Authors>
Expand Down Expand Up @@ -75,24 +74,17 @@
</PackageReference>

</ItemGroup>
<ItemGroup>
<!--<ItemGroup>
<PackageReference Include="RSCG_WhatIAmDoing" Version="8.2024.10405.851" />
<PackageReference Include="RSCG_WhatIAmDoing_Common" Version="8.2024.10405.851" />
</ItemGroup>
</ItemGroup>-->
<PropertyGroup>

<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
<CompilerGeneratedFilesOutputPath>$(BaseIntermediateOutputPath)\GX</CompilerGeneratedFilesOutputPath>
<InterceptorsPreviewNamespaces>$(InterceptorsPreviewNamespaces);RSCG_InterceptorTemplate</InterceptorsPreviewNamespaces>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
</PropertyGroup>

</Project>
12 changes: 6 additions & 6 deletions src/NetPackageAnalyzer/NetPackageAnalyzerConsole/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@
// "--verbose","false"
//};

//args = new[] { "generateFiles",
// "--folder", @"D:\gth\RSCG_Examples\v2",
// "-wg","HtmlSummary",
// "--where", @"D:\gth\PackageAnalyzer\src\documentation1",
// "--verbose","false"
//};
args = new[] { "generateFiles",
"--folder", @"D:\gth\RSCG_Examples\v2",
"-wg","HtmlSummary",
"--where", @"D:\gth\PackageAnalyzer\src\documentation1",
"--verbose","false"
};
//args = new[] { "generateFiles",
// "--folder", @"D:\source\test\NetPackageAnalyzer",
// "-wg","HtmlSummary",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

using Microsoft.Extensions.Logging;
using NetPackageAnalyzerExportHTML;
using System.Runtime.InteropServices;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,16 @@ public override async Task<string> GenerateNow(string folder, string where)

var nameFile = Path.Combine(where, $"{NameSolution}_summary.html");
await system.File.WriteAllTextAsync(nameFile, html);
WriteJs(where);
WriteJs(where);
var ex = new ExtractImages(nameFile);
await ex.GetImagesAsync();


MDSummaryData md = new ();
md.nameSolution = GlobalsForGenerating.NameSolution;
md.ExistsMajorDiffers= (modelMore1Version.KeysPackageMultipleMajorDiffers().Length > 0);
var mdSummary = new MDSummary(md);
var mdHtml = mdSummary.Render();
var nameFileMD = Path.Combine(where, $"{NameSolution}_summary.md");
await system.File.WriteAllTextAsync(nameFileMD, mdHtml);
return nameFile;
}
finally
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@
<td>
<a href="#Cyclomatic-Complexity-for-Assembly">
With most Cyclomatic Complexity
</a>:@CycAssIndex.First1()?Count
</a>:@CycAssIndex.First1()?.Count
</td>
<td>@CycAssIndex.First1()?.Name</td>
</tr>
Expand Down Expand Up @@ -476,7 +476,7 @@
<td>@(++tableRow)</td>
<td>
<a href="#executable-lines-per-class">
With most lines:@execClassLines.First1()??.Count
With most lines:@execClassLines.First1()?.Count
</a>
</td>
<td>@execClassLines.First1()?.Name</td>
Expand Down Expand Up @@ -1073,7 +1073,7 @@ columns: [
<h2 id="packages-with-major-version-different">@keysPackageMultiple.Length Packages with major version different</h2>
@if (keysPackageMultiple.Length > 0)
{
<table border="1">
<table border="1" title="image packages with major different">
<thead>
<tr>
<th>Nr</th>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

namespace NetPackageAnalyzerExportHTML;
internal class MDSummaryData
{
public string nameSolution { get; set; }=string.Empty;
public bool ExistsMajorDiffers { get; internal set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
<Nullable>enable</Nullable>

<NoWarn>CS0436</NoWarn>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="TestableIO.System.IO.Abstractions.Wrappers" Version="21.0.2" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
@inherits RazorBlade.PlainTextTemplate<MDSummaryData>
@{
var name = Model.nameSolution;
var nameFolder = name + "_summary";
}

# Summary for @name

## Project relations

![Project relations](./images/@(nameFolder)/projects-without-tests.png)



## Project Data

### Public Classes per project

![Class per project](./images/@(nameFolder)/Public-class-per-project.png)

### Number lines per project

![Number lines per project](./images/@(nameFolder)/Number-exec-lines-per-project.png)


## Class data

### Public methods per class

![Public methods](./images/@(nameFolder)/Public-methods-per-class.png)

### Number methods per class

![Number-methods-per-class](./images/@(nameFolder)/Number-methods-per-class.png)

### Number lines per class
![Number-exec-lines-per-class](./images/@(nameFolder)/Number-exec-lines-per-class.png)

## Method data

### Cyclomatic complexity per method

![Cyclomatic-Complexity-for-Method](./images/@(nameFolder)/Cyclomatic-Complexity-for-Method.png)

### Maintainability index per method
![Maintainability-for-Method](./images/@(nameFolder)/Maintainability-for-Method.png)

### Number lines per method
![Number-exec-lines-per-method](./images/@(nameFolder)/Number-exec-lines-per-method.png)



## Commits
![Number-exec-lines-per-method](./images/@(nameFolder)/commits-year-project.png)
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,65 @@
+ "]";
var maxCount = nameCount.Max(it => it.Count);
var yAxis = "[" + string.Join(',', nameCount.Select(it => it.Count).ToArray()) + "]";

var nameCountGraphic = nameCount;
if (nameCount.Length > 10)
{
nameCountGraphic = nameCount.Take(10).ToArray();
}
string assNamesMaintIndex = string.Join(",", nameCountGraphic.Select(it => "'" + it.Name + "'"));
string valuesMaintIndex = string.Join(",\r\n",
nameCountGraphic.Select(it => "{value:" + it.Count +"}")
);

StatisticsDisplay statisticsDisplay = new(arr.Statistics());

}
@statisticsDisplay.Render()


<div id="@nameId" style="height: 100%" title="image @name"></div>
<script type="text/javascript">
var dom = document.getElementById('@nameId');
var myChart = echarts.init(dom, null, {
renderer: 'canvas',
useDirtyRect: false
});
var app = {};
var option;
option = {
xAxis: {
type: 'category',
data: [@assNamesMaintIndex]
},
yAxis: {
type: 'value'
},
tooltip: {
trigger: 'item',
},
series: [
{
data: [
@valuesMaintIndex
],
type: 'bar'
}
]
};
if (option && typeof option === 'object') {
myChart.setOption(option);
}
window.addEventListener('resize', myChart.resize);
</script>


@*
<div class="mermaid" title="image @name">
---
config:
Expand All @@ -57,7 +111,8 @@ y-axis "" 0--> @maxCount
bar @yAxis
</div>
<br />
*@
<br />
<div id="@(nameId+"-table")" title="image @(nameId+"-table")"></div>

<script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<text>


<div id="containerBarYearNameCount" style="height: 100%"></div>
<div id="containerBarYearNameCount" title="image commits year project" style="height: 100%"></div>

<script type="text/javascript">
var dom = document.getElementById('containerBarYearNameCount');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@
<!--<PackageReference Include="rscgutils" Version="2024.2000.2000" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />-->

</ItemGroup>
<ItemGroup>
<!--<ItemGroup>
<PackageReference Include="RSCG_WhatIAmDoing" Version="8.2024.10405.851" />
<PackageReference Include="RSCG_WhatIAmDoing_Common" Version="8.2024.10405.851" />
</ItemGroup>
</ItemGroup>-->
<ItemGroup>
<Folder Include="rscgutilsGenerated\" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,11 @@
<ProjectReference Include="..\NetPackageAnalyzerObjects\NetPackageAnalyzerObjects.csproj" />
</ItemGroup>

<ItemGroup>
<!--<ItemGroup>
<PackageReference Include="RSCG_WhatIAmDoing" Version="8.2024.10405.851" />
<PackageReference Include="RSCG_WhatIAmDoing_Common" Version="8.2024.10405.851" />
</ItemGroup>
</ItemGroup>-->
<PropertyGroup>

<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
Expand Down

0 comments on commit b245261

Please sign in to comment.