refactor: extract helpers, constants, and idiomatic patterns#25
Merged
lostmygithubaccount merged 3 commits intomainfrom Apr 5, 2026
Merged
refactor: extract helpers, constants, and idiomatic patterns#25lostmygithubaccount merged 3 commits intomainfrom
lostmygithubaccount merged 3 commits intomainfrom
Conversation
Replace repeated magic strings/numbers with named constants: - DEFAULT_HOST, DEFAULT_PORT, DEFAULT_SERVER_URL in dkdc-db-core (shared) - IN_MEMORY_PATH in manager.rs (crate-local) - DEFAULT_LOG_LINES in cli.rs (crate-local) - Reuse api::MAX_BODY_SIZE in server lib.rs instead of duplicating 16*1024*1024 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Quote table names in SQL queries to prevent SQL injection - Validate table names against actual table list before use in SQL - Add single-quote escaping to escape_html to prevent XSS - Validate database exists in onboarding_create_table before rendering Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Extract handle_response/handle_response_unit in client (~100 lines saved) - Extract db_not_found() helper in manager (6 call sites) - Extract enable_wal() helper and WAL constants in db.rs - Extract DEFAULT_SCHEMA constant in catalog.rs - Use IN_MEMORY_PATH constant in db.rs (manager.rs already had it) - Fix indexed loop to iterator pattern in benchmark Co-Authored-By: Claude Opus 4.6 (1M context) <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
handle_response<T>/handle_response_unithelpers in dkdc-db-client, eliminating 8 repeated success/error check blocksdb_not_found()helper in manager.rs replacing 5 identicalError::Schema(format!(...))callsenable_wal()helper andWAL_MODE_PRAGMA/WAL_MODE_VALUEconstants in db.rs, deduplicating WAL init inopen_with_configandopen_in_memoryDEFAULT_SCHEMAconstant in catalog.rs for the "public" schema nameIN_MEMORY_PATHconstant in db.rs (manager.rs already had one)for i in 0..10 { REGIONS[i] }to idiomaticfor (i, name) in REGIONS.iter().enumerate()in benchmarkNo functional changes. All 167 tests pass, clippy clean, fmt clean.
🤖 Generated with Claude Code