Skip to content

Conversation

@z4o4z
Copy link
Member

@z4o4z z4o4z commented Jan 29, 2026

No description provided.

@linear
Copy link

linear bot commented Jan 29, 2026

Copy link
Member Author

z4o4z commented Jan 29, 2026

This stack of pull requests is managed by Graphite. Learn more about stacking.

@z4o4z z4o4z marked this pull request as ready for review January 29, 2026 12:58
Copilot AI review requested due to automatic review settings January 29, 2026 12:58
@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
57.6% Coverage on New Code (required ≥ 80%)
33.3% Condition Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the variable utilities to improve the API design by consolidating parameters into an options object and simplifying internal logic.

Changes:

  • Consolidated modifier parameter into options object for replaceVariables function
  • Added default value for modifier parameter in variableReplacer to eliminate runtime type checks
  • Extended deepVariableSubstitution to accept an options parameter for better configurability
  • Introduced formattedPhrase variable to improve code clarity in replaceVariables
  • Updated test to use the new API signature with { modifier: JSON.stringify }

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
packages/common/src/utils/variables.ts Refactored function signatures to use options object pattern, simplified modifier handling with default parameters, and improved code readability with extracted variables
packages/common/src/utils/variables.test.ts Updated test case to use new API signature with modifier inside options object

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


if (typeof subCollection === 'string') {
return replaceVariables(subCollection, variableMap, modifier);
return replaceVariables(subCollection, variableMap, options as any);
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The use of as any bypasses TypeScript's type checking. This could hide type incompatibilities between the options passed to deepVariableSubstitution and those expected by replaceVariables. Consider using a more specific type assertion or refactoring the type definitions to ensure type safety. The main concern is that keepTypeIfOnlyVariable: true in options would change the return type of replaceVariables to unknown, but this function is being used in a context where a string is expected, which could cause runtime issues.

Copilot uses AI. Check for mistakes.
Comment on lines 68 to +71
export function replaceVariables(
phrase: string | undefined | null,
variables: Record<string, unknown>,
modifier?: (variable: unknown) => unknown,
options?: { trim?: boolean; keepTypeIfOnlyVariable?: false }
options?: { modifier?: (variable: unknown) => unknown; trim?: boolean; keepTypeIfOnlyVariable?: false }
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change modifies the public API signature by moving the modifier parameter from being a separate third parameter to being part of the options object. This is a breaking change that will affect any external code calling replaceVariables with the old signature (e.g., replaceVariables(phrase, vars, modifierFn)). Consider providing backward compatibility or ensuring all call sites across the codebase and dependent packages have been updated. A deprecation path or migration guide may be helpful.

Copilot uses AI. Check for mistakes.
Copy link
Member Author

z4o4z commented Jan 29, 2026

bors r+

bors-vf bot pushed a commit that referenced this pull request Jan 29, 2026
@bors-vf
Copy link

bors-vf bot commented Jan 29, 2026

Pull request successfully merged into master.

Build succeeded:

@bors-vf bors-vf bot changed the title feat: improve variables utils (COR-9708) [Merged by Bors] - feat: improve variables utils (COR-9708) Jan 29, 2026
@bors-vf bors-vf bot closed this Jan 29, 2026
@bors-vf bors-vf bot deleted the evgeny/improve-variables-utils/COR-9708 branch January 29, 2026 14:23
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.

3 participants