Skip to content

prefer-sequence-overloads

Replaces simple two-keypoint ColorSequence and NumberSequence arrays with the shorter constructor overloads.

This rule only reports new ColorSequence([...]) and new NumberSequence([...]) when all of these are true:

  • the constructor gets exactly one argument, and that argument is an array
  • the array has exactly two elements
  • both elements are new ColorSequenceKeypoint(...) or new NumberSequenceKeypoint(...)
  • the keypoint times are exactly 0 and 1
  • each keypoint has exactly two arguments, so envelope keypoints are skipped

If both endpoint values are the same, the fixer uses the single-argument overload. Otherwise it uses the two-argument overload.

Incorrect
new ColorSequence([
new ColorSequenceKeypoint(0, Color3.fromRGB(255, 0, 0)),
new ColorSequenceKeypoint(1, Color3.fromRGB(0, 0, 255)),
]);
new NumberSequence([
new NumberSequenceKeypoint(0, 0),
new NumberSequenceKeypoint(1, 1),
]);
Correct
new ColorSequence(Color3.fromRGB(255, 0, 0), Color3.fromRGB(0, 0, 255));
new NumberSequence(0, 1);
new NumberSequence(42);
new NumberSequence([
new NumberSequenceKeypoint(0, 10, 0.2),
new NumberSequenceKeypoint(1, 90, 0.8),
]);