Skip to content

refactor(alg.rightAnglePath): consolidate duplicate code into helpers - #3472

Merged
kumilingus merged 6 commits into
clientIO:masterfrom
zbynekstara:right-angle-path-refactor
Aug 20, 2026
Merged

refactor(alg.rightAnglePath): consolidate duplicate code into helpers#3472
kumilingus merged 6 commits into
clientIO:masterfrom
zbynekstara:right-angle-path-refactor

Conversation

@zbynekstara

@zbynekstara zbynekstara commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Description

Refactors duplicate logic inside alg.rightAnglePath by introducing helper functions.

Motivation and Context

Duplicate code is hard to maintain since it is easy to overlook places where a bugfix should be applied. This is a conservative refactor with a focus on readability which consolidates blocks of duplicate logic without trying to introduce additional abstractions.

That is why functions were introduced for pairs / fours of separate source-target direction combinations instead of trying to introduce more abstracted methods that would combine cases more aggressively at the cost of hurting reader comprehension (e.g. by designating a single combination like top->left as the "canonical" one and treating others as rotations of it.

@zbynekstara
zbynekstara requested a lite review from Copilot August 20, 2026 15:51

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Refactors alg.rightAnglePath in @joint/core to reduce duplication by extracting repeated route-construction logic into dedicated helper functions, aiming to improve readability and maintainability of the orthogonal routing algorithm.

Changes:

  • Introduced helper functions to build common route point patterns (S-shapes, same-side routes, side-to-side routes, and midpoint fallbacks).
  • Replaced multiple duplicated inline point-construction blocks in rightAnglePath() with calls to these helpers.
  • Centralized edge-case handling for intersecting source/target boxes into shared helpers.
Suppressed comments (1)

packages/joint-core/src/alg/rightAnglePath.mjs:259

  • The comment is incomplete (ends with “and”), which makes the intent of this edge-case handling unclear.
    // This is an edge case when the source and target intersect and

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread packages/joint-core/src/alg/rightAnglePath.mjs
@zbynekstara
zbynekstara requested a review from kumilingus August 20, 2026 17:10
@kumilingus
kumilingus merged commit 0a2991b into clientIO:master Aug 20, 2026
3 checks passed
@zbynekstara
zbynekstara deleted the right-angle-path-refactor branch August 20, 2026 18:08
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