Replace magic number with named constant in format_time bounds check#30
Merged
Replace magic number with named constant in format_time bounds check#30
Conversation
Co-authored-by: Nikoro <12560977+Nikoro@users.noreply.github.com>
Co-authored-by: Nikoro <12560977+Nikoro@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Address feedback on AM/PM pattern conversion
Replace magic number with named constant in format_time bounds check
Nov 24, 2025
There was a problem hiding this comment.
Pull request overview
This PR addresses code review feedback by replacing a magic number with a named constant to improve code clarity in the format_time() function's bounds checking logic.
- Introduced
MAX_REPLACEMENT_LENGTHconstant to replace the magic number15 - Added documentation explaining that
"hh:mm:ss a"is the longest replacement string - Updated the bounds check calculation to use the new constant
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| linux/system_date_time_format_plugin.cc | Replaced magic number 15 with MAX_REPLACEMENT_LENGTH = 10 constant and updated bounds check logic |
| _codeql_detected_source_root | Added CodeQL configuration file (metadata change) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses code review feedback on PR #29 regarding unclear magic number
15in bounds checking logic.Changes:
15withMAX_REPLACEMENT_LENGTH = 10constant informat_time()"hh:mm:ss a"is the longest replacement (10 chars)BUFFER_LENGTH - MAX_REPLACEMENT_LENGTH - 1for clarityThe new constant is less conservative (11 vs 15) but correctly sized for the actual longest replacement string.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.