Skip to content

refactor: Replace magic numbers with named constants#1470

Merged
thomhurst merged 9 commits into
mainfrom
fix/issue-1457-magic-numbers
Dec 30, 2025
Merged

refactor: Replace magic numbers with named constants#1470
thomhurst merged 9 commits into
mainfrom
fix/issue-1457-magic-numbers

Conversation

@thomhurst
Copy link
Copy Markdown
Owner

Summary

  • Created LoggingConstants class with SecretMask, CommandMask, DefaultMaxBodySizeToLog, and FullLoggingMaxBodySize constants
  • Created ConcurrencyConstants class with ParallelismMultiplier constant
  • Added TestFramework constant to existing BuildConstants class
  • Updated all usages to reference the named constants instead of hardcoded values

Files Changed

Core Library (src/ModularPipelines/):

  • Constants/LoggingConstants.cs - New file with logging-related constants
  • Constants/ConcurrencyConstants.cs - New file with concurrency-related constants
  • Engine/SecretObfuscator.cs - Uses LoggingConstants.SecretMask
  • Logging/CommandLogger.cs - Uses LoggingConstants.CommandMask
  • Options/HttpLoggingOptions.cs - Uses LoggingConstants.DefaultMaxBodySizeToLog and FullLoggingMaxBodySize
  • Options/ConcurrencyOptions.cs - Uses ConcurrencyConstants.ParallelismMultiplier

Build Project (src/ModularPipelines.Build/):

  • BuildConstants.cs - Added TestFramework constant
  • Modules/RunUnitTestsModule.cs - Uses BuildConstants.TestFramework

Test plan

  • Core library builds successfully with named constants
  • All magic numbers replaced with descriptive constant names
  • Constants are appropriately scoped (internal for core library, public for build)

Fixes #1457

🤖 Generated with Claude Code

thomhurst and others added 9 commits December 29, 2025 18:39
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Create LoggingConstants with SecretMask, CommandMask, and body size constants
- Create ConcurrencyConstants with ParallelismMultiplier
- Add TestFramework constant to BuildConstants
- Update SecretObfuscator to use LoggingConstants.SecretMask
- Update CommandLogger to use LoggingConstants.CommandMask
- Update HttpLoggingOptions to use LoggingConstants for body size limits
- Update ConcurrencyOptions to use ConcurrencyConstants.ParallelismMultiplier
- Update RunUnitTestsModule to use BuildConstants.TestFramework

Fixes #1457

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

Summary

This PR replaces magic numbers with named constants across logging, concurrency, and test framework configuration.

Critical Issues

None found ✅

Suggestions

  1. String concatenation in logging (src/ModularPipelines/Logging/CommandLogger.cs:133)

    The change on line 133 uses string concatenation instead of structured logging:

    Logger.LogInformation("{Timestamp}Command: {WorkingDirectory}> " + LoggingConstants.CommandMask,

    This should use structured logging like the original to maintain consistency with the rest of the file:

    Logger.LogInformation("{Timestamp}Command: {WorkingDirectory}> {Mask}",
        timestamp,
        workingDirectory,
        LoggingConstants.CommandMask);

Verdict

⚠️ REQUEST CHANGES - The string concatenation in logging breaks the structured logging pattern used throughout the codebase. This should be fixed to maintain consistency and proper log structure.

@thomhurst thomhurst merged commit 1960bd4 into main Dec 30, 2025
10 of 12 checks passed
@thomhurst thomhurst deleted the fix/issue-1457-magic-numbers branch December 30, 2025 10:10
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.

MEDIUM: Hardcoded magic numbers scattered throughout codebase

1 participant