Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 15, 2026

The dependencyAnalyzer tool used fragile .startsWith('^') checks that only detected caret-prefixed versions, missing ~4.0.0, >=4.0.0, 4.46.0, and other valid semver formats.

Changes

  • Version detection: Replaced string prefix checks with regex-based getMajorVersion() helper that extracts major version from any semver format (^, ~, >=, >, <, exact, wildcards)
  • Cleanup: Removed unused content variable in go.mod detection block
  • Test coverage: Added 6 comprehensive tests for getMajorVersion() function to verify extraction from all semver formats and edge cases
// Before: Only matches ^4.x.x
if (deps['webpack'] && deps['webpack'].startsWith('^4')) {
  findings.push('Webpack 4 detected - consider upgrading to Webpack 5');
}

// After: Matches ^4.0.0, ~4.0.0, >=4.0.0, 4.46.0, 4.x, etc.
const getMajorVersion = (version) => {
  if (!version) return null;
  const match = version.match(/^[~^>=<]*(\d+)/);
  return match ? parseInt(match[1], 10) : null;
};

const webpackMajor = getMajorVersion(deps['webpack']);
if (webpackMajor === 4) {
  findings.push('Webpack 4 detected - consider upgrading to Webpack 5');
}

Testing

  • ✅ All 31 functional tests pass (6 new version detection tests added)
  • ✅ Tests verify correct extraction from caret ranges, tilde ranges, comparison operators, exact versions, and wildcards
  • ✅ Tests verify null returns for invalid inputs
  • ✅ All unit tests pass
  • ✅ Validation scripts pass

The changes are minimal and focused, improving the robustness of version detection while ensuring comprehensive test coverage.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 4 commits January 15, 2026 03:52
Co-authored-by: mdaashir <85205726+mdaashir@users.noreply.github.com>
Co-authored-by: mdaashir <85205726+mdaashir@users.noreply.github.com>
Co-authored-by: mdaashir <85205726+mdaashir@users.noreply.github.com>
Co-authored-by: mdaashir <85205726+mdaashir@users.noreply.github.com>
Copilot AI changed the title [WIP] Add analytics and industry-specific agents for version 2.3 Fix version detection to support all semver formats and remove unused variable Jan 15, 2026
Copilot AI requested a review from mdaashir January 15, 2026 03:57
@mdaashir mdaashir marked this pull request as ready for review January 15, 2026 03:58
Copilot AI review requested due to automatic review settings January 15, 2026 03:58
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR improves version detection in the dependencyAnalyzer tool to support all valid semver formats instead of only caret-prefixed versions. It also removes an unused variable.

Changes:

  • Introduced a getMajorVersion() helper function using regex to extract major versions from any semver format (^, ~, >=, >, <, exact versions, wildcards)
  • Refactored webpack and React version detection to use the new helper instead of .startsWith('^') checks
  • Removed unused content variable in go.mod detection block

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@mdaashir
Copy link
Owner

@copilot apply changes based on the comments in this thread

Copilot AI and others added 2 commits January 15, 2026 04:03
…verage

Co-authored-by: mdaashir <85205726+mdaashir@users.noreply.github.com>
Co-authored-by: mdaashir <85205726+mdaashir@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 15, 2026

@copilot apply changes based on the comments in this thread

Applied all changes from the review thread:

  1. Fixed regex (caa6777): Removed unnecessary escape for caret character
  2. Added test coverage (caa6777, ed3eee5): Created 6 comprehensive tests for getMajorVersion() covering all semver formats and edge cases

All 31 functional tests now passing.

…e I/O

Co-authored-by: mdaashir <85205726+mdaashir@users.noreply.github.com>
Copilot AI requested a review from mdaashir January 15, 2026 04:07
@mdaashir mdaashir merged commit 9eea858 into feature/production-enhancements-v2.3 Jan 15, 2026
@mdaashir mdaashir deleted the copilot/sub-pr-1 branch January 15, 2026 04:09
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.

2 participants