refactor: extract credential loading helpers from test/record.sh#1348
Merged
refactor: extract credential loading helpers from test/record.sh#1348
Conversation
…test/record.sh Split credential loading logic into focused helper functions: - _export_env_vars_from_fields: Extract array export logic (16 lines) - _load_single_token_config: Extract single-token loading (14 lines) Changes: - try_load_config reduced from 39 to 28 lines (28% reduction) - _load_multi_config_from_file reduced from 38 to 26 lines (32% reduction) - Eliminated duplicate env var validation logic - Improved readability with clear separation of concerns All 80 tests passing. No functional changes. Agent: complexity-hunter Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
4 tasks
louisgv
approved these changes
Feb 17, 2026
Member
louisgv
left a comment
There was a problem hiding this comment.
Security Review
Verdict: APPROVED
Findings
No security issues found. This is a clean refactoring that:
- Extracts duplicate credential-loading logic into focused helper functions
- Maintains all existing security validation (env var name regex checks)
- Reduces complexity without changing behavior
- Improves code maintainability
New helper functions:
_export_env_vars_from_fields(lines 89-105): Centralizes env var export with validation_load_single_token_config(lines 174-191): Extracts single-token loading logic
Security validations preserved:
- All env var names validated against
^[A-Z_][A-Z0-9_]*$regex before export - All error handling and return codes maintained
- No changes to privilege boundaries or data flow
Tests
- bash -n: PASS (syntax valid)
- bun test: N/A (no TypeScript changes)
- curl|bash: N/A (test-only file, not executed remotely)
- macOS compat: OK (no bash 4.x features used)
- Test suite: PASS (80/80 tests passing)
Code Quality
- Line count reduction: 28-32% in refactored functions
- DRY principle applied correctly
- No functional changes (refactor only)
-- security/pr-reviewer-1348
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
Extracted credential-loading logic into focused helper functions to reduce complexity and improve maintainability.
Functions refactored:
try_load_config: 39 → 28 lines (28% reduction)_load_multi_config_from_file: 38 → 26 lines (32% reduction)New helpers:
_export_env_vars_from_fields(16 lines): Centralizes env var export logic with security validation_load_single_token_config(14 lines): Extracts single-token loading from config filesChanges
Test plan
-- refactor/complexity-hunter