refactor: eliminate magic numbers by introducing named constants#20
Merged
Conversation
Replace hardcoded numbers with descriptive constants for better maintainability: - Add +gif-fps-divider+ (2.0) for GIF frame rate calculation - Add +min-file-size+ (1024) for incomplete file detection threshold - Export new constants in package.lisp - Update ffmpeg.lisp to use named constants instead of magic numbers Benefits: - Improved code readability and self-documentation - Easier maintenance and configuration changes - Clear intent behind numeric values - Consistent with existing constant naming conventions 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Change +min-file-size+ from 1024 to 4096 bytes for more reliable detection of incomplete/corrupted video files. Rationale: - 1KB was too small for video files (even minimal video headers are larger) - 4KB provides better safety margin while still catching truly incomplete files - More conservative approach to avoid accidentally deleting valid small files 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.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.
Summary
Replace hardcoded magic numbers with descriptive named constants to improve code maintainability and readability.
Changes Made
New Constants Added (
src/const.lisp)Magic Numbers Eliminated
GIF Frame Rate Calculation (
src/ffmpeg.lisp:58)(/ fps 2.0)(/ fps +gif-fps-divider+)File Size Threshold (
src/ffmpeg.lisp:27)(< file-size 1024)(< file-size +min-file-size+)Package Export (
src/package.lisp)Benefits
const.lisp+constant-name+)Implementation Notes
These constants were identified in
docs/refactoring-tasks.mdas part of the code quality improvement initiative. The values preserve existing behavior while making the code more maintainable.Related Files
src/const.lisp- New constant definitionssrc/package.lisp- Export declarationssrc/ffmpeg.lisp- Magic number replacementsTest plan
visp --gif test.mp4make testros build visp.rosThis refactoring maintains identical functionality while improving code quality.
🤖 Generated with Claude Code