docs(tests): fix CommentChecker findings across tests/ — 13,392 → 0 (repo-wide scan clean)

Comment/XML-doc changes only:
- add summaries to ~10k test methods, fixtures, fakes and helpers
  (+ <param> on theories, <returns> on async Task methods,
  <inheritdoc/> on interface implementations the checker can resolve)
- strip ~2.6k project-tracking references (WP*, P*-*, row-NN, Task N,
  #NN, Component-0NN) from comments, keeping the explanatory text;
  reword false positives in comments only
- real docs on fakes implementing BCL/library interfaces
  (IDisposable, ILogger, IOptionsMonitor, IAsyncLifetime)
- reword the last 5 src/ false positives (CWE-1236, failures-1,
  year-0001, M365)

Only non-comment edits: four one-line nested classes split across lines
so members can carry docs. Build 0 errors / 0 warnings.
This commit is contained in:
Joseph Doherty
2026-10-07 15:05:49 -04:00
parent 0ffd4bdbea
commit 513fa1aa16
998 changed files with 17896 additions and 2395 deletions
@@ -3,7 +3,7 @@ using System.Text.RegularExpressions;
namespace ZB.MOM.WW.ScadaBridge.ConfigurationDatabase.Tests;
/// <summary>
/// Code-level guard for the AuditLog append-only invariant (task M2.10, #18).
/// Code-level guard for the AuditLog append-only invariant.
///
/// The DB-role control (DENY UPDATE / DENY DELETE on dbo.AuditLog in migration
/// 20260602174346_CollapseAuditLogToCanonical) is the runtime enforcement layer.
@@ -36,12 +36,12 @@ namespace ZB.MOM.WW.ScadaBridge.ConfigurationDatabase.Tests;
/// <see cref="AuditPurgeAllowedMarker"/> trailing comment:
/// <list type="bullet">
/// <item><description>
/// M5.5 (T3) — <c>AuditLogRepository.PurgeChannelOlderThanAsync</c>: the
/// <c>AuditLogRepository.PurgeChannelOlderThanAsync</c>: the
/// one sanctioned batched <c>DELETE TOP (@batch) FROM dbo.AuditLog</c>,
/// running on the purge/maintenance connection.
/// </description></item>
/// <item><description>
/// M5.6 (T5) — <c>AuditLogRepository.BackfillSourceNodeAsync</c>: the
/// <c>AuditLogRepository.BackfillSourceNodeAsync</c>: the
/// one sanctioned batched <c>UPDATE TOP (@batch) dbo.AuditLog SET SourceNode</c>,
/// running on the maintenance connection. The sentinel backfill is a
/// one-time ops procedure; the append-only invariant still applies to all
@@ -60,8 +60,8 @@ public class AuditLogAppendOnlyGuardTests
/// The exact trailing-comment marker that exempts a single sanctioned
/// maintenance-path DML line from the append-only guard. Carried at the END of
/// the SQL constant string in both <c>AuditLogRepository.PurgeChannelOlderThanAsync</c>
/// (M5.5 T3 batched DELETE) and <c>AuditLogRepository.BackfillSourceNodeAsync</c>
/// (M5.6 T5 batched UPDATE). Kept deliberately specific so it cannot be pasted
/// (batched DELETE) and <c>AuditLogRepository.BackfillSourceNodeAsync</c>
/// (batched UPDATE). Kept deliberately specific so it cannot be pasted
/// onto an unrelated mutation without a reviewer noticing.
/// </summary>
internal const string AuditPurgeAllowedMarker = "AUDIT-PURGE-ALLOWED";
@@ -166,7 +166,7 @@ public class AuditLogAppendOnlyGuardTests
// The DELETE branch tolerates an optional TOP (...) batch-size clause between
// DELETE and the (optional) FROM — e.g. "DELETE TOP (@batch) FROM dbo.AuditLog"
// (the M5.5 T3 batched purge shape). Without this the guard would silently miss a
// (the batched purge shape). Without this the guard would silently miss a
// batched row DELETE against AuditLog, which is exactly the kind of mutation it
// must catch. The TOP sub-pattern is (?:TOP\s*\(.*?\)\s+)? — optional, lazy inside
// the parens so it never swallows past the matching ')'.
@@ -174,7 +174,7 @@ public class AuditLogAppendOnlyGuardTests
// The UPDATE branch similarly tolerates an optional TOP (...) clause between
// UPDATE and (optional schema.) AuditLog — e.g.
// "UPDATE TOP (@batch) dbo.AuditLog SET SourceNode = @sentinel …"
// (the M5.6 T5 batched backfill shape).
// (the batched backfill shape).
private static readonly Regex AuditLogMutationPattern = new(
@"\bUPDATE\s+(?:TOP\s*\(.*?\)\s+)?(?:\[?dbo\]?\.)?(?:\[?AuditLog\]?)\b" +
@"|\bDELETE\s+(?:TOP\s*\(.*?\)\s+)?(?:FROM\s+)?(?:\[?dbo\]?\.)?(?:\[?AuditLog\]?)\b",
@@ -184,8 +184,8 @@ public class AuditLogAppendOnlyGuardTests
/// Returns <see langword="true"/> when <paramref name="line"/> carries the narrow
/// <see cref="AuditPurgeAllowedMarker"/> exemption. Sanctioned uses are:
/// <list type="bullet">
/// <item><description>M5.5 T3 — the per-channel maintenance-path batched DELETE.</description></item>
/// <item><description>M5.6 T5 — the SourceNode sentinel batched UPDATE.</description></item>
/// <item><description>The per-channel maintenance-path batched DELETE.</description></item>
/// <item><description>The SourceNode sentinel batched UPDATE.</description></item>
/// </list>
/// A flagged line that lacks the marker is NOT allow-listed. The mutation matcher
/// itself stays marker-blind; the allow-list is applied only by the file-scan test,
@@ -201,6 +201,7 @@ public class AuditLogAppendOnlyGuardTests
// Designer/Snapshot EF artefacts and the obj/ directory).
// ---------------------------------------------------------------------------
/// <summary>Verifies that no source file in the ConfigurationDatabase project contains an unsanctioned UPDATE or DELETE against the AuditLog table.</summary>
[Fact]
public void ConfigurationDatabase_ShouldNotContainAuditLogMutations()
{
@@ -245,6 +246,7 @@ public class AuditLogAppendOnlyGuardTests
// Self-verifying matcher unit tests — prove the helper does what it claims.
// ---------------------------------------------------------------------------
/// <summary>Verifies that the mutation matcher returns false for source lines that do not mutate AuditLog.</summary>
[Fact]
public void ContainsAuditLogMutation_ReturnsFalse_ForCleanSource()
{
@@ -296,6 +298,7 @@ public class AuditLogAppendOnlyGuardTests
"TRUNCATE TABLE dbo.AuditLog_Staging_abc123;"));
}
/// <summary>Verifies that the mutation matcher returns true for planted UPDATE and DELETE violations against AuditLog.</summary>
[Fact]
public void ContainsAuditLogMutation_ReturnsTrue_ForPlantedViolations()
{
@@ -344,7 +347,7 @@ public class AuditLogAppendOnlyGuardTests
Assert.True(ContainsAuditLogMutation(
"DELETE FROM [AuditLog] WHERE OccurredAtUtc < @threshold;"));
// ---- Batched DELETE TOP (...) forms (M5.5 T3 purge shape) ----
// ---- Batched DELETE TOP (...) forms (purge shape) ----
// The matcher must catch a batched DELETE against AuditLog regardless of the
// marker — the allow-list (IsAllowListed) is what forgives the ONE sanctioned
// line, not the matcher.
@@ -355,7 +358,7 @@ public class AuditLogAppendOnlyGuardTests
Assert.True(ContainsAuditLogMutation(
"DELETE TOP(100) FROM [dbo].[AuditLog] WHERE Status = 'Parked';"));
// ---- Batched UPDATE TOP (...) forms (M5.6 T5 backfill shape) ----
// ---- Batched UPDATE TOP (...) forms (backfill shape) ----
// The matcher must also catch a batched UPDATE against AuditLog, regardless of
// the marker — the allow-list is what forgives the ONE sanctioned backfill line.
Assert.True(ContainsAuditLogMutation(
@@ -366,6 +369,7 @@ public class AuditLogAppendOnlyGuardTests
"UPDATE TOP(100) [dbo].[AuditLog] SET SourceNode = @s WHERE SourceNode IS NULL;"));
}
/// <summary>Verifies that the mutation matcher returns false for DENY, GRANT and partition-switch statements.</summary>
[Fact]
public void ContainsAuditLogMutation_ReturnsFalse_ForDenyGrantAndPartitionSwitchSamples()
{
@@ -396,10 +400,11 @@ public class AuditLogAppendOnlyGuardTests
}
// ---------------------------------------------------------------------------
// Allow-list self-tests (M5.5 T3 / M5.6 T5) — prove the narrow exemption only
// Allow-list self-tests — prove the narrow exemption only
// forgives the marked maintenance-path DML and still blocks everything else.
// ---------------------------------------------------------------------------
/// <summary>Verifies that the allow-list forgives a marked purge DELETE while the raw matcher still flags it.</summary>
[Fact]
public void AllowList_ForgivesMarkedPurgeDelete_ButMatcherStillTrips()
{
@@ -415,6 +420,7 @@ public class AuditLogAppendOnlyGuardTests
Assert.True(IsAllowListed(sanctioned));
}
/// <summary>Verifies that the allow-list forgives a marked backfill UPDATE while the raw matcher still flags it.</summary>
[Fact]
public void AllowList_ForgivesMarkedBackfillUpdate_ButMatcherStillTrips()
{
@@ -430,6 +436,7 @@ public class AuditLogAppendOnlyGuardTests
Assert.True(IsAllowListed(sanctioned));
}
/// <summary>Verifies that the allow-list does not forgive a stray DELETE that lacks the marker.</summary>
[Fact]
public void AllowList_DoesNotForgive_UnmarkedStrayDelete()
{
@@ -443,6 +450,7 @@ public class AuditLogAppendOnlyGuardTests
"A DELETE against AuditLog without the AUDIT-PURGE-ALLOWED marker must NOT be allow-listed.");
}
/// <summary>Verifies that the allow-list does not forgive a stray UPDATE that lacks the marker.</summary>
[Fact]
public void AllowList_DoesNotForgive_UnmarkedStrayUpdate()
{
@@ -454,6 +462,7 @@ public class AuditLogAppendOnlyGuardTests
"An UPDATE against AuditLog without the AUDIT-PURGE-ALLOWED marker must NOT be allow-listed.");
}
/// <summary>Verifies that the allow-list does not forgive a batched UPDATE that lacks the marker.</summary>
[Fact]
public void AllowList_DoesNotForgive_BatchedUpdateWithoutMarker()
{