Skip to content

Commit ed2aa1d

Browse files
thomhurstclaude
andauthored
refactor: Remove redundant code and extract magic numbers (#1659)
* refactor: Remove redundant case-sensitive string comparisons Remove redundant Ordinal string comparisons that are already covered by OrdinalIgnoreCase checks in ShouldSkipBasedOnHelpText method: - helpText.Contains("deprecated", StringComparison.Ordinal) - helpText.Contains("experimental", StringComparison.Ordinal) Closes #1622 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * refactor: Extract magic number to named constant Replace magic number 5000 with named constant ProgressPrinterGracePeriodMs in PrintProgressExecutor.DisposeAsync to improve code readability and maintainability. Closes #1618 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 0812a77 commit ed2aa1d

2 files changed

Lines changed: 8 additions & 5 deletions

File tree

src/ModularPipelines/Engine/Executors/PrintProgressExecutor.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ namespace ModularPipelines.Engine.Executors;
77
[StackTraceHidden]
88
internal class PrintProgressExecutor : IPrintProgressExecutor
99
{
10+
/// <summary>
11+
/// Grace period in milliseconds for progress printer to complete before forced cancellation.
12+
/// </summary>
13+
private const int ProgressPrinterGracePeriodMs = 5000;
14+
1015
private readonly EngineCancellationToken _engineCancellationToken;
1116
private readonly IConsolePrinter _consolePrinter;
1217
private readonly IModuleRetriever _moduleRetriever;
@@ -41,7 +46,7 @@ public async Task<IPrintProgressExecutor> InitializeAsync()
4146

4247
public async ValueTask DisposeAsync()
4348
{
44-
_printProgressCancellationTokenSource?.CancelAfter(5000);
49+
_printProgressCancellationTokenSource?.CancelAfter(ProgressPrinterGracePeriodMs);
4550

4651
await SafelyAwaitProgressPrinter().ConfigureAwait(false);
4752
}
@@ -60,4 +65,4 @@ private async Task SafelyAwaitProgressPrinter()
6065
_logger.LogWarning(e, "Error while waiting for progress to update");
6166
}
6267
}
63-
}
68+
}

tools/ModularPipelines.OptionsGenerator/src/ModularPipelines.OptionsGenerator/Scrapers/Cli/CliScraperBase.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -448,8 +448,7 @@ protected virtual bool ShouldSkipBasedOnHelpText(string helpText)
448448
// Check for deprecated commands
449449
if (SkipDeprecatedCommands)
450450
{
451-
if (helpText.Contains("DEPRECATED", StringComparison.OrdinalIgnoreCase) ||
452-
helpText.Contains("deprecated", StringComparison.Ordinal))
451+
if (helpText.Contains("DEPRECATED", StringComparison.OrdinalIgnoreCase))
453452
{
454453
return true;
455454
}
@@ -460,7 +459,6 @@ protected virtual bool ShouldSkipBasedOnHelpText(string helpText)
460459
{
461460
if (helpText.Contains("EXPERIMENTAL", StringComparison.OrdinalIgnoreCase) ||
462461
helpText.Contains("BETA", StringComparison.OrdinalIgnoreCase) ||
463-
helpText.Contains("experimental", StringComparison.Ordinal) ||
464462
helpText.Contains("(beta)", StringComparison.OrdinalIgnoreCase))
465463
{
466464
return true;

0 commit comments

Comments
 (0)