Skip to content

Conversation

@achedges
Copy link
Contributor

@achedges achedges commented Dec 31, 2025

This change refactors a handful of internal functionality to remove unreachable code, and adds a couple of new tests to bring up line coverage.

Comments added inline, I hope this helps!

@achedges achedges requested a review from kt3k as a code owner December 31, 2025 17:34
return cmp < 0;
case "!=":
return false;
return cmp >= 0;
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'll admit this one had me scratching my head a bit. It seems that, in the context of this internal utility function, simply inverting the outcome for the != operator (compared to the = operator) should suffice for producing the intended effect.

return cmp > 0;
case "!=":
return false;
return cmp <= 0;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

See comments on greater_than_range.ts


if (!groups) return null;

const { operator, prerelease, buildmetadata } =
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unless I'm missing something here, if the regex match succeeds at all, the resulting groups will contain elements for each semver component. This code was attempting to manually parse what this regex was already doing.

@codecov
Copy link

codecov bot commented Dec 31, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.22%. Comparing base (13e5527) to head (f81d0c8).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6924      +/-   ##
==========================================
+ Coverage   94.17%   94.22%   +0.04%     
==========================================
  Files         584      584              
  Lines       43087    43072      -15     
  Branches     6875     6870       -5     
==========================================
+ Hits        40578    40585       +7     
+ Misses       2457     2436      -21     
+ Partials       52       51       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

const prerelease = parsePrerelease(groups.prerelease ?? "");
const build = parseBuild(groups.build ?? "");
return [{ operator: undefined, major, minor, patch, prerelease, build }];

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can use the = string if we have it, the net-effect is the same.

throw new Error(
`Cannot parse version range: '${groups.operator}' is not a valid operator`,
);
return handleEqualOperator(groups);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The existing default case should not be possible, so we can use the equals/empty operator to exercise a switch default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant