Files
poli0981andClaude Fable 5.2 1342979353 ci: Qodana - JetBrains' code analysis from a workflow of its own, and what its first run reported settled (D93) (#373)
* ci: Qodana - a workflow of its own from JetBrains' template, Qodana Community for .NET over FrameLedger.slnx (D93)

The first run: the linter in its Linux container, EnableWindowsTargeting passed
to it, no quality gate yet - what it builds and what it reports decides the rest.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

* ci: Qodana's gate is zero problems, and the inspections this project argues with are off in .editorconfig, each with its reason (D93)

Pushed before the fixes on purpose: the run this starts has the settings and
none of the fixes, so it shows the gate failing on what is left.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

* fix: what Qodana's first run reported, settled - about 400 fixes in 181 files, none changing behaviour; the documents (D93)

Redundant qualifiers, casts, using directives, nullable suppressions and unsafe
modifiers removed from the report's own positions; var for built-in types and
one-line block bodies brought to .editorconfig's style by dotnet format; every
XAML item template names its DataType and a binding that reached its page through
DataContext.ViewModel names the page's type; two unread fields, two overwritten
initialisers and an unused parameter removed; SpokenTextAutomationPeer no longer
assumes the base peer's name is a string.

docs/13_CI_CD.md §Qodana, CLAUDE.md, the wiki's workflow table, HANDOFF's
decisions index (D93) and the changelog entry.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-10 16:13:04 +00:00

88 lines
3.9 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// SPDX-License-Identifier: GPL-3.0-only
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
using FluentAssertions;
using FrameLedger.Domain.Metrics;
using static FrameLedger.Domain.Tests.Metrics.SampleFixtures;
namespace FrameLedger.Domain.Tests.Metrics;
/// <summary>
/// The stutter rule, and the golden <c>14_TESTING</c> names: a gap does not appear as a stutter.
/// </summary>
public sealed class StutterDetectorTests
{
[Fact]
public void AFrameMoreThanTwiceTheRollingMedianIsAStutter()
{
double[] series = [.. Enumerable.Repeat(10.0, 40)];
series[20] = 21; // > 2 × 10
series[30] = 20; // exactly 2 × 10 is NOT a stutter
StutterResult? r = StutterDetector.Detect(series);
r.Should().NotBeNull();
r.Count.Should().Be(1);
r.IsStutter[20].Should().BeTrue();
r.IsStutter[30].Should().BeFalse();
r.TimePct.Should().BeApproximately(21.0 / (38 * 10 + 21 + 20) * 100, 1e-9);
}
[Fact]
public void AGapDoesNotAppearAsAStutter()
{
// Twenty-one 10 ms frames with one missing record in the middle. Counted as one 20 ms interval the
// frame would sit at exactly 2× (not a stutter here, but a 30 ms hole would be); excluded, it is
// not in the series at all, so nothing can be flagged on the reader's own accounting.
List<FrameSample> stream = FromFrameTimes([.. Enumerable.Repeat(10.0, 10), 30, .. Enumerable.Repeat(10.0, 10)]);
FrameTimeSeries withGap = FrameTimeSeries.From(stream, new HashSet<int> { 11 }, Frequency);
FrameTimeSeries merged = FrameTimeSeries.From(stream, null, Frequency);
StutterDetector.Detect(withGap.FrameTimesMs)!.Count.Should().Be(0, "the interval spanning the gap is excluded");
StutterDetector.Detect(merged.FrameTimesMs)!.Count.Should().Be(1, "and this is the stutter the gap would have fabricated");
}
[Fact]
public void FewerThanNineteenFramesIsNotApplicable() => StutterDetector.Detect([.. Enumerable.Repeat(10.0, 18)]).Should().BeNull();
[Fact]
public void AnAllZeroSeriesHasNoStutterTime()
{
StutterResult? r = StutterDetector.Detect([.. Enumerable.Repeat(0.0, 20)]);
r!.Count.Should().Be(0);
r.TimePct.Should().Be(0);
}
[Fact]
public void PsoStutterIsTheShareOfStutterFramesThatCompiledSomething()
{
List<FrameSample> stream = FromFrameTimes([.. Enumerable.Repeat(10.0, 10), 30, .. Enumerable.Repeat(10.0, 10), 30, .. Enumerable.Repeat(10.0, 10)]);
for (int i = 0; i < stream.Count; i++)
{
stream[i] = stream[i] with { Measured = stream[i].Measured | MeasuredFields.Pso, PsoCreated = (ushort)(i == 11 ? 3 : 0) };
}
FrameTimeSeries series = FrameTimeSeries.From(stream, null, Frequency);
StutterResult r = StutterDetector.Detect(series.FrameTimesMs)!;
r.Count.Should().Be(2);
StutterDetector.PsoStutterPct(r, series, stream).Should().Be(50.0, "one of the two stutter frames compiled a pipeline");
}
[Fact]
public void PsoStutterIsNotApplicableWithoutStuttersOrWithoutThePsoHook()
{
List<FrameSample> quiet = FromFrameTimes(Enumerable.Repeat(10.0, 20));
FrameTimeSeries quietSeries = FrameTimeSeries.From(quiet, null, Frequency);
StutterDetector.PsoStutterPct(StutterDetector.Detect(quietSeries.FrameTimesMs)!, quietSeries, quiet)
.Should().BeNull("nothing stuttered");
List<FrameSample> unhooked = FromFrameTimes([.. Enumerable.Repeat(10.0, 10), 30, .. Enumerable.Repeat(10.0, 10)]);
FrameTimeSeries unhookedSeries = FrameTimeSeries.From(unhooked, null, Frequency);
StutterDetector.PsoStutterPct(StutterDetector.Detect(unhookedSeries.FrameTimesMs)!, unhookedSeries, unhooked)
.Should().BeNull("no sample claims the PSO measurement, so 0% would be a negative nobody measured");
}
}