Skip to content

[code-simplifier] Simplify validation and flush logic for improved clarity - #8538

Merged
Amaury Levé (Evangelink) merged 1 commit into
mainfrom
code-simplifier/2026-05-24-f5d5dcff8343b3b6
May 25, 2026
Merged

Amaury Levé (Evangelink) merged 1 commit into
mainfrom
code-simplifier/2026-05-24-f5d5dcff8343b3b6

Conversation

@Evangelink

Copy link
Copy Markdown
Member

Code Simplification - 2026-05-24

This PR simplifies recently modified code to improve clarity, consistency, and maintainability while preserving all functionality.

Files Simplified

  • src/Platform/Microsoft.Testing.Platform/CommandLine/PlatformCommandLineProvider.cs - Simplified timeout parsing with modern C# syntax
  • src/Platform/Microsoft.Testing.Extensions.AzureDevOpsReport/AzureDevOpsTestResultsPublisher.cs - Improved flush condition ordering for clarity

Improvements Made

  1. Modern C# Syntax

    • Replaced arg[arg.Length - 1] with arg[^1] (index-from-end operator)
    • Replaced arg[..(arg.Length - 1)] with arg[..^1] (range-from-end operator)
    • Changed is not 'h' and not 'm' and not 's' to is not ('h' or 'm' or 's') (nested pattern matching)
  2. Enhanced Clarity

    • Reordered ShouldFlushUnsafe conditions to check empty state first, making the logic flow more intuitive
    • Simplified force-flag check by eliminating redundant condition after empty-state check
    • Removed unnecessary comment that merely restated obvious logic
  3. Applied Project Standards

    • Used modern C# features consistently with codebase conventions
    • Maintained all existing comments that explain non-obvious design decisions
    • Preserved exact functional behavior

Changes Based On

Recent changes from:

Testing

  • ✅ All tests pass (55 tests in PlatformCommandLineProviderTests, 22 tests in AzureDevOpsLivePublishingTests)
  • ✅ Build succeeds with no warnings or errors
  • ✅ No functional changes - behavior is identical

Review Focus

Please verify:

  • Functionality is preserved
  • Simplifications improve code quality
  • Changes align with project conventions
  • No unintended side effects

Automated by Code Simplifier Agent

Note

🔒 Integrity filter blocked 1 item

The following item was blocked because it doesn't meet the GitHub integrity level.

  • #8529 search_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".

To allow these resources, lower min-integrity in your GitHub frontmatter:

tools:
  github:
    min-integrity: approved  # merged | approved | unapproved | none

Generated by Code Simplifier · ● 1.2M · ◷

Add this agentic workflows to your repo

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/code-simplifier.md@main
  • expires on May 25, 2026, 1:48 PM UTC

- Use C# index-from-end operators (^1, ..^1) in TryParseTimeoutArgument
- Use nested pattern matching ('h' or 'm' or 's') for clearer unit validation
- Reorder ShouldFlushUnsafe conditions to check empty state first, then force flag
- All tests pass - no functional changes

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

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.

Pull request overview

This PR performs small, behavior-preserving simplifications in Microsoft.Testing.Platform command-line parsing and the Azure DevOps live publishing flush decision logic, aiming to improve readability and consistency with modern C# syntax.

Changes:

  • Simplifies --timeout parsing by using index/range-from-end operators and an or pattern for unit validation.
  • Reorders ShouldFlushUnsafe checks to short-circuit on “no pending results” before evaluating force and interval conditions.
Show a summary per file
File Description
src/Platform/Microsoft.Testing.Platform/CommandLine/PlatformCommandLineProvider.cs Uses arg[^1], arg[..^1], and is not ('h' or 'm' or 's') to simplify timeout unit/value parsing without changing validation behavior.
src/Platform/Microsoft.Testing.Extensions.AzureDevOpsReport/AzureDevOpsTestResultsPublisher.cs Reorders ShouldFlushUnsafe conditions to check for empty pending state first, then force, keeping logic equivalent but clearer.

Copilot's findings

  • Files reviewed: 2/2 changed files
  • Comments generated: 0

@Evangelink
Amaury Levé (Evangelink) marked this pull request as ready for review May 25, 2026 10:40
@Evangelink
Amaury Levé (Evangelink) merged commit 63ea449 into main May 25, 2026
48 checks passed
@Evangelink
Amaury Levé (Evangelink) deleted the code-simplifier/2026-05-24-f5d5dcff8343b3b6 branch May 25, 2026 11:26
@Evangelink Amaury Levé (Evangelink) added type/automation Created or maintained by an agentic workflow. type/tech-debt Code health, refactoring, simplification. and removed automation labels May 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type/automation Created or maintained by an agentic workflow. type/tech-debt Code health, refactoring, simplification.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants