Skip to content

Extract magic numbers to named constants#32

Merged
angelo-hub merged 3 commits into
feat/better_api_callsfrom
copilot/sub-pr-31
Dec 21, 2025
Merged

Extract magic numbers to named constants#32
angelo-hub merged 3 commits into
feat/better_api_callsfrom
copilot/sub-pr-31

Conversation

Copilot AI commented Dec 21, 2025

Copy link
Copy Markdown
Contributor

Addresses code review feedback to extract hardcoded magic numbers to named constants for improved maintainability.

Changes

1. Tree View Debounce Delay

  • Added TREE_VIEW_REFRESH_DEBOUNCE_MS constant at module level in src/activation/treeView.ts
  • Replaced inline 500 with the constant in debounce() call

Before:

const debouncedVisibilityRefresh = debounce(() => {
  // ...
}, 500);

After:

const TREE_VIEW_REFRESH_DEBOUNCE_MS = 500;

const debouncedVisibilityRefresh = debounce(() => {
  // ...
}, TREE_VIEW_REFRESH_DEBOUNCE_MS);

2. Rate Limit Retry Delay

  • Added MIN_RATE_LIMIT_DELAY_MS constant in src/shared/http/RetryableHttpClient.ts
  • Replaced inline 30000 with the constant for minimum rate limit retry delay
  • Added comprehensive documentation explaining this is the minimum delay when no Retry-After header is present

Before:

delay = Math.max(delay, 30000); // At least 30 seconds

After:

const MIN_RATE_LIMIT_DELAY_MS = 30000; // 30 seconds

delay = Math.max(delay, MIN_RATE_LIMIT_DELAY_MS);

Improves maintainability by making delay values self-documenting and centralized.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: angelo-hub <12058178+angelo-hub@users.noreply.github.com>
Copilot AI changed the title [WIP] Update to address feedback on caching and API retry Extract debounce delay magic number to named constant Dec 21, 2025
Copilot AI requested a review from angelo-hub December 21, 2025 18:06
@angelo-hub

Copy link
Copy Markdown
Owner

@copilot there was another magic number you found in this comment but i believe it's a max not min?

The magic number 30000 (30 seconds) for rate limit delay lacks explanation. Consider extracting this to a named constant like DEFAULT_RATE_LIMIT_DELAY or adding a more detailed comment explaining why 30 seconds is the minimum for rate limiting without a Retry-After header.

Co-authored-by: angelo-hub <12058178+angelo-hub@users.noreply.github.com>

Copilot AI commented Dec 21, 2025

Copy link
Copy Markdown
Contributor Author

@copilot there was another magic number you found in this comment but i believe it's a max not min?

The magic number 30000 (30 seconds) for rate limit delay lacks explanation. Consider extracting thi...

You're correct - it's a minimum (using Math.max), not a maximum. Extracted to MIN_RATE_LIMIT_DELAY_MS constant with detailed documentation explaining it's the minimum delay when no Retry-After header is present. Changes in commit 9faaf68.

Copilot AI changed the title Extract debounce delay magic number to named constant Extract magic numbers to named constants Dec 21, 2025
@angelo-hub
angelo-hub marked this pull request as ready for review December 21, 2025 18:11
@angelo-hub
angelo-hub merged commit 7b86f2b into feat/better_api_calls Dec 21, 2025
@angelo-hub
angelo-hub deleted the copilot/sub-pr-31 branch December 21, 2025 18:12
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.

2 participants