Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Use inserted range when retracting range in toConnectedRanges #1056

Merged
merged 4 commits into from
Aug 27, 2024

Conversation

Christopher-Chianelli
Copy link
Contributor

The ConnectedRangesCalculator incorrectly assumes the range for each value is constant. The fix is to save the range on insert, and then pass the saved range on retract. The other calculators do not have this problem, because either:

  • Their input should be immutable (ex: number)
  • They used a map in their internal data structure that saved the original value

Fixes #953

Copy link
Contributor

@triceo triceo left a comment

Choose a reason for hiding this comment

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

We need a different test.
Otherwise LGTM.

Comment on lines +24 to +25
final var mapped = mapper.apply(a, b);
final var saved = calculator.insert(mapped);
Copy link
Contributor

Choose a reason for hiding this comment

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

final shouldn't be necessary here. The variable is effectively final without it too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I prefer final to explicitly mark it as final/as something that shouldn't be changed.

Comment on lines +26 to +27
final var mapped = mapper.apply(a, b, c, d);
final var saved = calculator.insert(mapped);
Copy link
Contributor

Choose a reason for hiding this comment

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

Dtto.

Comment on lines +24 to +25
final var mapped = mapper.apply(a, b, c);
final var saved = calculator.insert(mapped);
Copy link
Contributor

Choose a reason for hiding this comment

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

Dtto.

Comment on lines +24 to +25
final var mapped = mapper.apply(a);
final var saved = calculator.insert(mapped);
Copy link
Contributor

Choose a reason for hiding this comment

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

Dtto.

The `ConnectedRangesCalculator` incorrectly assumes the range for each
value is constant. The fix is to save the range on insert, and then
pass the saved range on retract. The other calculators do not have
this problem, because either:

- Their input should be immutable (ex: number)
- They used a map in their internal data structure that
  saved the original value
Copy link

sonarcloud bot commented Aug 27, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
5.7% Duplication on New Code (required ≤ 5%)

See analysis details on SonarCloud

@triceo triceo merged commit 274dadd into TimefoldAI:main Aug 27, 2024
26 of 27 checks passed
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.

ConstraintCollectors.toConnectedRanges: "this.splitPoint" is null
2 participants