Skip to content

Conversation

@ricokahler
Copy link
Contributor

@ricokahler ricokahler commented Jun 4, 2025

This PR performs a straightforward but important refactoring throughout the codebase: renaming the parameters itemA and itemB to source and target respectively.

This change applies to:

  • The public diffPatch function.
  • Internal functions like diffItem, diffObject, diffArray, diffArrayByIndex, and getDiffMatchPatch (where applicable, though some parts of getDiffMatchPatch already used source/target).
  • JSDoc comments and error messages.

Key Changes:

  • Parameter Renaming:
    • In diffPatch(itemA, itemB, ...) is now diffPatch(source, target, ...).
    • In diffItem(itemA, itemB, ...) is now diffItem(source, target, ...).
    • Similar renames in diffObject and diffArray.
    • The JSDoc for getDiffMatchPatch already used source/target, but internal variable names like itemA/itemB were updated where they existed.
  • Documentation and Error Message Updates:
    • JSDoc @param tags updated to reflect the new names (e.g., @param source - The first document/tree to compare).
    • Error messages updated, for example, the ID mismatch error now reads _id on source and target not present or differs....

Rationale:

  • Semantic Clarity: source and target are more descriptive and standard terms for diffing operations, clearly indicating the initial state and the desired final state.
  • Consistency: Aligns the parameter naming with common conventions in diffing libraries and algorithms.
  • Improved Readability: Makes the code easier to understand at a glance, as the role of each parameter is more immediately obvious.

This is primarily a cosmetic and semantic improvement that enhances code clarity and maintainability without altering the core diffing logic. All tests continue to pass.

@ricokahler ricokahler force-pushed the v6_rename-to-source-target branch from a6023b6 to ee95377 Compare June 4, 2025 15:32
@ricokahler ricokahler force-pushed the v6_simplify-diff-item branch from d022678 to 5c829d6 Compare June 4, 2025 15:32
@ricokahler ricokahler force-pushed the v6_rename-to-source-target branch from ee95377 to 30d5dc1 Compare June 4, 2025 15:35
@ricokahler ricokahler marked this pull request as ready for review June 4, 2025 22:08
@ricokahler ricokahler requested a review from rexxars June 4, 2025 22:24
@ricokahler ricokahler force-pushed the v6_simplify-diff-item branch from 5c829d6 to e8850b4 Compare June 6, 2025 21:57
@ricokahler ricokahler force-pushed the v6_rename-to-source-target branch from 30d5dc1 to 9a6d1b2 Compare June 6, 2025 21:57
@ricokahler ricokahler force-pushed the v6_simplify-diff-item branch from e8850b4 to e763f90 Compare June 6, 2025 22:00
@ricokahler ricokahler force-pushed the v6_rename-to-source-target branch from 9a6d1b2 to e226529 Compare June 6, 2025 22:00
@ricokahler ricokahler force-pushed the v6_simplify-diff-item branch from e763f90 to 3c0b6a7 Compare June 6, 2025 22:16
@ricokahler ricokahler force-pushed the v6_rename-to-source-target branch from e226529 to 5e84e17 Compare June 6, 2025 22:16
@ricokahler ricokahler force-pushed the v6_simplify-diff-item branch 2 times, most recently from 0c5fd70 to 5fe4030 Compare June 13, 2025 19:40
@ricokahler ricokahler force-pushed the v6_rename-to-source-target branch from 5e84e17 to 86994be Compare June 13, 2025 19:40
@ricokahler ricokahler changed the base branch from v6_simplify-diff-item to graphite-base/44 June 13, 2025 19:54
@ricokahler ricokahler force-pushed the v6_rename-to-source-target branch from 86994be to f825413 Compare June 13, 2025 19:54
@graphite-app graphite-app bot changed the base branch from graphite-base/44 to main June 13, 2025 19:55
Standardize parameter naming across all diff functions for better
semantic clarity and consistency.

- Update diffPatch, diffItem, diffObject, and diffArray functions
- Rename itemA/itemB to source/target throughout codebase
- Update error messages and comments to reflect new naming
- Improve code readability with more descriptive parameter names
@ricokahler ricokahler force-pushed the v6_rename-to-source-target branch from f825413 to 3749d93 Compare June 13, 2025 19:55
@ricokahler ricokahler merged commit befec5f into main Jun 13, 2025
7 checks passed
Copy link
Contributor Author

Merge activity

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