Skip to content

[code-simplifier] Simplify nested ternary in CtrfReportEngine.ResolveRunId - #11836

Merged
Amaury Levé (Evangelink) merged 1 commit into
mainfrom
code-simplifier/ctrf-report-engine-ternary-be6630676a55f1e6
Oct 8, 2026
Merged

Amaury Levé (Evangelink) merged 1 commit into
mainfrom
code-simplifier/ctrf-report-engine-ternary-be6630676a55f1e6

Conversation

@Evangelink

Copy link
Copy Markdown
Member

Replace the nested ternary expression with an explicit if/else chain for improved readability, per project guidance to avoid nested ternary operators. No behavioral change.

Fixes #11833

Replace the nested ternary expression with an explicit if/else chain
for improved readability, per project guidance to avoid nested
ternary operators. No behavioral change.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 8, 2026 13:47
@Evangelink
Amaury Levé (Evangelink) enabled auto-merge (squash) October 8, 2026 13:47
@github-actions github-actions Bot added the state/needs-review Awaiting review from the team. label Oct 8, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

🤖 Automated review by GitHub Copilot. Generated by the Expert Code Review workflow. To request a follow-up action, reply by tagging @copilot directly.

Review outcome: No actionable findings — this is a clean, behavior-preserving refactor.

Change classification

  • Microsoft.Testing.Extensions.CtrfReport: CtrfReportEngine.ResolveRunId() unrolls a nested ternary into an early-return if plus an extracted executionId local. No functional change.

Confidence at a glance

🟢 Correctness & design — verified equivalent across all branches
  • Why it applies: The only change is control-flow restructuring of a private helper; must confirm no behavior drift.
  • Evidence: Traced all three reachable paths against the original nested ternary: (1) runId non-empty → returns runId in both versions; (2) runId empty, TESTINGPLATFORM_DOTNETTEST_EXECUTIONID non-empty → both return null; (3) both empty → both return Guid.NewGuid().ToString("D"). The new executionId local is read exactly once, matching the original single-evaluation semantics (no risk of the env var being read twice with a different value).
  • Gap or disposition: None. The method is private, so no PublicAPI.Unshipped.txt entry is needed, and no caller contract changes.
  • Action: None.

⚪ Not applicable: Concurrency & lifecycle, Security & protocol, API & compatibility, Performance, Localization, Tests, Analyzers, Build/dependencies/scripts (no behavioral, API, security, performance, localization, test, analyzer, or build-file changes in this diff).

@microsoft-github-policy-service microsoft-github-policy-service Bot added state/needs-review Awaiting review from the team. and removed state/needs-review Awaiting review from the team. labels Oct 8, 2026
@github-actions github-actions Bot added state/needs-review Awaiting review from the team. and removed state/needs-review Awaiting review from the team. labels Oct 8, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The refactor is behaviorally equivalent, covered by existing tests, and retains the required file encoding.

0 open findings

What changed in this PR

Simplifies ResolveRunId while preserving environment-variable precedence and GUID generation behavior.

Changes:

  • Replaces the nested ternary with an early return and named execution ID.
  • Preserves existing run ID behavior.
File Description
CtrfReportEngine.JsonSerializer.cs Simplifies ResolveRunId control flow.

🧠 Review effort: Balanced


Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.

@microsoft-github-policy-service microsoft-github-policy-service Bot added state/needs-review Awaiting review from the team. and removed state/needs-review Awaiting review from the team. labels Oct 8, 2026
@github-actions github-actions Bot added state/approved Proposal approved; ready for implementation. and removed state/needs-review Awaiting review from the team. labels Oct 8, 2026
@Evangelink
Amaury Levé (Evangelink) merged commit 9746ce7 into main Oct 8, 2026
27 of 29 checks passed
@Evangelink
Amaury Levé (Evangelink) deleted the code-simplifier/ctrf-report-engine-ternary-be6630676a55f1e6 branch October 8, 2026 15:44
@github-actions github-actions Bot removed the state/approved Proposal approved; ready for implementation. label Oct 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[code-simplifier] Simplify nested ternary in CtrfReportEngine.ResolveRunId

3 participants