Skip to content

The `compareMultiSemver` function now uses the embedded `compareSemver`

4ae66f3
Select commit
Loading
Failed to load commit list.
Open

The compareMultiSemver function now uses the embedded compareSemver #794

The `compareMultiSemver` function now uses the embedded `compareSemver`
4ae66f3
Select commit
Loading
Failed to load commit list.
gitStream.cm / linearb-ai/linearb_ai_review succeeded Sep 25, 2025 in 6s

code-review@v1

code-review@v1: add code-review comment:

✨ 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! 🚀


💡 Code Suggestions

plugins/filters/compareMultiSemver/index.js:55-56 🐞 Bug - Inconsistent Prerelease Handling: Implement proper semver prerelease comparison logic or use a standardized approach for handling alphabetic version suffixes instead of character codes.

    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;