Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
ea033cf
maintain: Member 'CreateProjectChanges' does not access instance data…
BabetteB Mar 17, 2026
6305e07
refactor: clean-up programme and usecases
BabetteB Mar 17, 2026
3dfa001
chore: Do not use a Where clause to filter before calling Assert.Sing…
BabetteB Mar 17, 2026
a614a91
chore: Use 'GeneratedRegexAttribute' to generate the regular expressi…
BabetteB Mar 17, 2026
71b9a33
chore: Possible null reference argument for parameter 'collection' in…
BabetteB Mar 17, 2026
c959036
chore: Member does not access instance data and can be marked as static
BabetteB Mar 17, 2026
ed7ac00
chore: supress warning CA1859
BabetteB Mar 17, 2026
9b69c09
chore: Dereference of a possibly null reference.
BabetteB Mar 17, 2026
05d8043
chore: supress warnig CA1816
BabetteB Mar 17, 2026
23e993a
chore: reduce cognitive complexity of `BuildDeltaStructure`
BabetteB Mar 17, 2026
e961350
chore: refactor `CompileExclusions` to reduce cognitive complexity
BabetteB Mar 17, 2026
4a480b1
chore: comment ignore is puposeful
BabetteB Mar 17, 2026
878af57
chore: ignore warning CA1859
BabetteB Mar 17, 2026
ca6114a
chore: reduce cognitive complexity og DiscoverDeletedPaths
BabetteB Mar 17, 2026
284d821
chore: simplify expression with linq
BabetteB Mar 17, 2026
4290b2d
chore: simplify `IsUnderAnyDeletedDirectory``with linq
BabetteB Mar 17, 2026
a7dc6d5
chore: supres warning CA1859
BabetteB Mar 17, 2026
04f26b9
chore: remove hardcoded path char
BabetteB Mar 17, 2026
bbe14db
chore: accept complexity and explain in comment why
BabetteB Mar 17, 2026
4aa5fcd
chore: reduce complexity of BuildGraph
BabetteB Mar 17, 2026
7a29944
fix: test coverage on sonar cloud
BabetteB Mar 17, 2026
fa99bd4
chore: writeline async
BabetteB Mar 17, 2026
27a2026
chore: reduce complexity of Deserialise
BabetteB Mar 17, 2026
64f0675
chore: move where condition into last
BabetteB Mar 17, 2026
7581f8d
chore: give savelocation a default value
BabetteB Mar 17, 2026
b673f0a
chore: forward cancellation token
BabetteB Mar 17, 2026
5346afc
chore: supress warning CA1859
BabetteB Mar 17, 2026
70a8a75
chore: supress warning CA1859
BabetteB Mar 17, 2026
bbaa634
chore: reduce complexity of BuildDiffEdges
BabetteB Mar 17, 2026
44e3c20
chore: reduce complexity of AggregateEdgesToVisibleDirectories
BabetteB Mar 17, 2026
906ffb2
chore: simplify with linq
BabetteB Mar 17, 2026
3814e97
chore: single json options
BabetteB Mar 17, 2026
adeb2d4
chore: supress warning CA1859
BabetteB Mar 17, 2026
7c55fb6
chore: make utility classes static
BabetteB Mar 17, 2026
65edad5
chore: delete unused class
BabetteB Mar 17, 2026
d3f90b8
chore: null reference handling
BabetteB Mar 17, 2026
818a0a2
chore: reduce complexity of `ParseFileDependencies`
BabetteB Mar 17, 2026
09d79e7
fix: close go stream reader
BabetteB Mar 17, 2026
ec2bc9c
chore: regex timeout
BabetteB Mar 17, 2026
d2e8134
chore: regex at runtime
BabetteB Mar 17, 2026
f528632
chore: handle null ref
BabetteB Mar 17, 2026
9043443
chore: handle null ref
BabetteB Mar 17, 2026
6f54e59
chore: supress warning
BabetteB Mar 17, 2026
bde636f
chore: remove unused imports
github-actions[bot] Mar 17, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ jobs:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
shell: powershell
run: |
${{ runner.temp }}\scanner\dotnet-sonarscanner begin /k:"BabLoRP_ArchLens" /o:"bablorp" /d:sonar.token="${{ secrets.SONAR_TOKEN }}"
${{ runner.temp }}\scanner\dotnet-sonarscanner begin /k:"BabLoRP_ArchLens" /o:"bablorp" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.cs.opencover.reportsPaths="**/coverage.opencover.xml"
dotnet build src/c-sharp/Archlens.sln
dotnet test src/ArchlensTests/ArchlensTests.csproj --collect:"XPlat Code Coverage" -- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=opencover
${{ runner.temp }}\scanner\dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"
4 changes: 2 additions & 2 deletions src/ArchlensTests/Application/DependencyGraphBuilderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ private void SetupMockProject()
Directory.CreateDirectory(Path.Combine(_fs.Root, "Domain", "Utils"));
}

private ProjectChanges CreateProjectChanges(IReadOnlyDictionary<RelativePath, IReadOnlyList<RelativePath>> changedFilesByDirectory,
private static ProjectChanges CreateProjectChanges(IReadOnlyDictionary<RelativePath, IReadOnlyList<RelativePath>> changedFilesByDirectory,
IReadOnlyList<RelativePath> deletedFiles,
IReadOnlyList<RelativePath> deletedDirectories) =>
new(changedFilesByDirectory, deletedFiles, deletedDirectories);
Expand Down Expand Up @@ -732,7 +732,7 @@ public async Task BuildGraph_DoesNotCallParser_ForDirectoriesOnlyForFiles()
Assert.Equal(uFile, parser.Calls[0]);

var domainChildren = graph.ChildrenOf(domainDir);
Assert.Single(domainChildren.Where(x => x.Equals(utilsDir)));
Assert.Single(domainChildren, x => x.Equals(utilsDir));
}

[Fact]
Expand Down
27 changes: 18 additions & 9 deletions src/ArchlensTests/Domain/RendererBaseTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace ArchlensTests.Domain;

public sealed class RendererBaseTests : IDisposable
public sealed partial class RendererBaseTests : IDisposable
{
private readonly TestFileSystem _fs = new();
public void Dispose() => _fs.Dispose();
Expand All @@ -19,7 +19,7 @@ public sealed class RendererBaseTests : IDisposable
),
Format: default,
Views: [new View("completeView", [], []), new View("ignoringView", [], ["./Infra/"])],
SaveLocation: null
SaveLocation: $"{_fs.Root}/diagrams"
);

private RenderOptions MakeOptions(
Expand All @@ -33,9 +33,9 @@ private RenderOptions MakeOptions(
FullRootPath: _fs.Root),
Format: default,
Views: [new View(viewName, packages ?? [], ignore ?? [])],
SaveLocation: saveLocation);
SaveLocation: saveLocation ?? $"{_fs.Root}/diagrams");

private static string Minify(string s) => Regex.Replace(s, @"\s+", "");
private static string Minify(string s) => StringOneOrMoreRegex().Replace(s, "");


[Fact]
Expand Down Expand Up @@ -130,9 +130,9 @@ public void JsonRendererRendersDiffCorrectly()
Assert.Contains("\"edges\": [", result);
Assert.EndsWith("}", result);

result = Regex.Replace(result, @"\s*", "");
newEdge = Regex.Replace(newEdge, @"\s*", "");
deletedEdge = Regex.Replace(deletedEdge, @"\s*", "");
result = StringZeroMoreRegex().Replace(result, "");
newEdge = StringZeroMoreRegex().Replace(newEdge, "");
deletedEdge = StringZeroMoreRegex().Replace(deletedEdge, "");

Assert.Contains(newEdge, result);
Assert.Contains(deletedEdge, result);
Expand Down Expand Up @@ -178,7 +178,7 @@ public void EdgesAreOrderedByFromThenTo()
var graph = TestDependencyGraph.MakeDependencyGraph(_fs.Root);
var result = new JsonRenderer().RenderView(graph, opts.Views[0], opts);

var froms = Regex.Matches(result, @"""fromPackage""\s*:\s*""([^""]+)""")
var froms = FromRegex().Matches(result)
.Select(m => m.Groups[1].Value)
.ToList();

Expand Down Expand Up @@ -283,7 +283,7 @@ public void UnchangedEdgesAreNeutral()
var graph = TestDependencyGraph.MakeDependencyGraph(_fs.Root);
var result = Minify(new JsonRenderer().RenderDiffView(graph, graph, opts.Views[0], opts));

Assert.Empty(Regex.Matches(result, @"""state"":""(CREATED|DELETED)"""));
Assert.Empty(StateRegex().Matches(result));
}

[Fact]
Expand Down Expand Up @@ -524,4 +524,13 @@ public void DiffRenderIsDeterministic()
new JsonRenderer().RenderDiffView(local, remote, opts.Views[0], opts),
new JsonRenderer().RenderDiffView(local, remote, opts.Views[0], opts));
}

[GeneratedRegex(@"\s+")]
private static partial Regex StringOneOrMoreRegex();
[GeneratedRegex(@"\s*")]
private static partial Regex StringZeroMoreRegex();
[GeneratedRegex(@"""fromPackage""\s*:\s*""([^""]+)""")]
private static partial Regex FromRegex();
[GeneratedRegex(@"""state"":""(CREATED|DELETED)""")]
private static partial Regex StateRegex();
}
1 change: 1 addition & 0 deletions src/ArchlensTests/Infra/ConfigManagerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,7 @@ public async Task RenderOptions_SaveLocation_IsSet()
{
var path = WriteConfig(new(SaveLocation: "\"diagrams\""));
var (_, _, renderOptions, _) = await Manager(path).LoadAsync();
Assert.NotNull(renderOptions.SaveLocation);
Assert.NotEmpty(renderOptions.SaveLocation);
Assert.Contains("diagrams", renderOptions.SaveLocation);
}
Expand Down
8 changes: 4 additions & 4 deletions src/ArchlensTests/Infra/Renderers/JsonRendererTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ private RenderOptions Opts(
FullRootPath: _fs.Root),
Format: default,
Views: [new View(viewName, packages ?? [], ignore ?? [])],
SaveLocation: null);
SaveLocation: $"{_fs.Root}/diagrams");

private JsonObject ParseJson(string json) =>
private static JsonObject ParseJson(string json) =>
JsonNode.Parse(json)!.AsObject();

private JsonArray Packages(JsonObject root) =>
private static JsonArray Packages(JsonObject root) =>
root["packages"]!.AsArray();

private JsonArray Edges(JsonObject root) =>
private static JsonArray Edges(JsonObject root) =>
root["edges"]!.AsArray();

private ProjectDependencyGraph DefaultGraph() =>
Expand Down
6 changes: 4 additions & 2 deletions src/ArchlensTests/Infra/Renderers/PlantUMLRendererTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ private RenderOptions Opts(
FullRootPath: _fs.Root),
Format: default,
Views: [new View(viewName, packages ?? [], ignore ?? [])],
SaveLocation: null);
SaveLocation: $"{_fs.Root}/diagrams");

private ProjectDependencyGraph DefaultGraph() =>
TestDependencyGraph.MakeDependencyGraph(_fs.Root);
Expand All @@ -36,8 +36,10 @@ private string RenderDiff(
RenderOptions opts) =>
_renderer.RenderDiffView(local, remote, opts.Views[0], opts);

#pragma warning disable CA1859 // Use concrete types when possible for improved performance
private static IReadOnlyList<string> Lines(string output) =>
output.Split('\n').Select(l => l.TrimEnd('\r')).ToList();
[.. output.Split('\n').Select(l => l.TrimEnd('\r'))];
#pragma warning restore CA1859 // Use concrete types when possible for improved performance

[Fact]
public void FileExtension_IsPuml()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,11 @@ public async Task SaveThenLoad_Get_Name_And_LastWriteTime()
var enums = RelativePath.Directory(rootPath, "./Domain/Models/Enums/");
var utils = RelativePath.Directory(rootPath, "./Domain/Utils/");

var loadedItems = loaded.ProjectItems;
var loadedItems = loaded?.ProjectItems;

if (loadedItems is null)
Assert.Fail("Loaded items is null");

Assert.Contains(root, loadedItems);
Assert.Contains(application, loadedItems);
Assert.Contains(infra, loadedItems);
Expand All @@ -106,7 +110,7 @@ public async Task SaveThenLoad_Get_Name_And_LastWriteTime()
Assert.Contains(enums, loadedItems);
Assert.Contains(utils, loadedItems);

Assert.Equal(graph.GetProjectItem(root).LastWriteTime.ToString("dd-MM-yyyy HH:mm:ss"), loaded.GetProjectItem(root).LastWriteTime.ToString("dd-MM-yyyy HH:mm:ss"));
Assert.Equal(graph?.GetProjectItem(root)?.LastWriteTime.ToString("dd-MM-yyyy HH:mm:ss"), loaded?.GetProjectItem(root)?.LastWriteTime.ToString("dd-MM-yyyy HH:mm:ss"));
}

[Fact]
Expand Down Expand Up @@ -148,7 +152,7 @@ public async Task Load_ReturnsGraph_WhenFilePresent()

var loaded = await snapshotManager.GetLastSavedDependencyGraphAsync(opts);

Assert.Equal(graph.ProjectItems, loaded.ProjectItems);
Assert.Equal(graph.ProjectItems, loaded?.ProjectItems);
}

[Fact]
Expand All @@ -163,13 +167,13 @@ public async Task Load_ReturnsMultiLevelGraph_WhenPresent()

var loaded = await snapshotManager.GetLastSavedDependencyGraphAsync(opts);

Assert.Equal(graph.ProjectItems, loaded.ProjectItems);
Assert.Equal(graph.ProjectItems, loaded?.ProjectItems);

var rootPath = RelativePath.Directory(root, "./");
Assert.Equal(graph.ChildrenOf(rootPath).Count, loaded.ChildrenOf(rootPath).Count);
Assert.Equal(graph.ChildrenOf(rootPath).Count, loaded?.ChildrenOf(rootPath).Count);

var domainPath = RelativePath.Directory(root, "./Domain/");
var domain = loaded.GetProjectItem(domainPath);
var domain = loaded?.GetProjectItem(domainPath);

Assert.NotNull(domain);
Assert.Equal(3, graph.ChildrenOf(domainPath).Count);
Expand Down
3 changes: 3 additions & 0 deletions src/ArchlensTests/Utils/TestFileSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ public string File(string relPath, string contents = "", DateTime? lastWriteUtc
return abs;
}

#pragma warning disable CA1816 // Dispose methods should call SuppressFinalize
public void Dispose()
#pragma warning restore CA1816 // Dispose methods should call SuppressFinalize

{
try { Directory.Delete(Root, recursive: true); } catch { /* ignore */ }
}
Expand Down
Loading