Skip to content

Conversation

vim-zz
Copy link
Collaborator

@vim-zz vim-zz commented Sep 25, 2025

function instead of importing it from an external file.

… compareMultiSemver git:(embed-compare-semver-in-multi-plugin  node index.js
✓ Test 1 passed: compareMultiSemver([["1.2.3", "1.2.1"], ["1.3.1", "1.2.3"]]) === "minor"
✓ Test 2 passed: compareMultiSemver([["1.2.3", "0.2.1"], ["1.3.1", "1.2.3"]]) === "major"
✓ Test 3 passed: compareMultiSemver([["2.2.3", "0.2.1"], ["1.3.1", "1.2.3"]]) === "major"
✓ Test 4 passed: compareMultiSemver([["1.2.3", "1.2.1"], ["1.2.4", "1.2.3"]]) === "patch"

🎉 All tests passed!

✨ PR Description

Purpose: Embed compareSemver functionality directly into compareMultiSemver plugin to eliminate external dependency and improve maintainability.
Main changes:

  • Integrated compareSemver function code directly into compareMultiSemver module
  • Removed external dependency on compareSemver module
  • Enhanced test cases with better error messages and success confirmation output

Generated by LinearB AI and added by gitStream.
AI-generated content may contain inaccuracies. Please verify before using. We'd love your feedback! 🚀

function instead of importing it from an external file
Copy link

@orca-security-us orca-security-us bot left a comment

Choose a reason for hiding this comment

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

Orca Security Scan Summary

Status Check Issues by priority
Passed Passed Infrastructure as Code high 0   medium 0   low 0   info 0 View in Orca
Passed Passed SAST high 0   medium 0   low 0   info 0 View in Orca
Passed Passed Secrets high 0   medium 0   low 0   info 0 View in Orca
Passed Passed Vulnerabilities high 0   medium 0   low 0   info 0 View in Orca

Copy link
Contributor

@gitstream-cm gitstream-cm bot left a comment

Choose a reason for hiding this comment

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

✨ PR Review

The PR successfully embeds the compareSemver function to eliminate external dependency, but introduces test code in the production file and has potential issues with semver comparison logic.

2 issues detected:

🧹 Maintainability - Test code should not be part of production modules as it creates unnecessary coupling and potential runtime overhead.

Details: The file now contains test cases and console output statements that are executed as part of the main module. This makes the production code noisy and couples testing logic with business logic.
File: plugins/filters/compareMultiSemver/index.js

🐞 Bug - Using character codes for version comparison can lead to incorrect semantic version ordering.

Details: The convertPart function uses charCodeAt() to convert alphabetic characters to numeric values, which can create inconsistent ordering for prerelease versions. Character codes vary significantly (a=97, z=122) leading to unexpected comparison results.
File: plugins/filters/compareMultiSemver/index.js (55-56)

Generated by LinearB AI and added by gitStream.
AI-generated content may contain inaccuracies. Please verify before using. We'd love your feedback! 🚀

Comment on lines +55 to +56
const match = /[A-Za-zαß]/.exec(x);
return Number(match ? x.replace(match[0], "." + x.charCodeAt(match.index)) : x);
Copy link
Contributor

Choose a reason for hiding this comment

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

🐞 Bug - Inconsistent Prerelease Handling: Implement proper semver prerelease comparison logic or use a standardized approach for handling alphabetic version suffixes instead of character codes.

Suggested change
const match = /[A-Za-zαß]/.exec(x);
return Number(match ? x.replace(match[0], "." + x.charCodeAt(match.index)) : x);
const match = /^(\d+)([A-Za-zαß]*)$/.exec(x);
if (!match) return Number(x);
const numeric = Number(match[1]);
const alpha = match[2];
if (!alpha) return numeric;
// Convert alphabetic suffix to a small decimal increment for proper ordering
// Each character contributes progressively smaller values to maintain order
let alphaValue = 0;
for (let i = 0; i < alpha.length; i++) {
const charValue = alpha.charCodeAt(i) - 96; // normalize a=1, b=2, etc.
alphaValue += charValue / Math.pow(100, i + 1); // decimal fractions
}
return numeric + alphaValue;

@gitstream-cm gitstream-cm bot requested a review from a team September 25, 2025 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant