Fix version retrieval in getEnvironment method to use serverInfo#3732
Conversation
|
Caution Review failedThe pull request is closed. 📝 WalkthroughWalkthroughThe PR modifies Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes Possibly related PRs
Poem
✨ Finishing touches
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug in the SentryScopeConfigurer class where the getEnvironment() method was incorrectly using the getVersion() method, which returns a version string prefixed with "bsl-language-server@". This prefix caused the regex patterns used for environment classification to fail, preventing proper categorization of versions as production, pre-release, develop, or feature.
Key Changes:
- Changed
getEnvironment()to callserverInfo.getVersion()directly instead of the internalgetVersion()method, ensuring the raw version string is used for regex matching
Comments suppressed due to low confidence (1)
src/main/java/com/github/_1c_syntax/bsl/languageserver/aop/sentry/SentryScopeConfigurer.java:96
- The change to use
serverInfo.getVersion()directly is correct and fixes a bug where the environment classification logic would fail to match version patterns due to the "bsl-language-server@" prefix. However, this logic lacks test coverage. Consider adding unit tests for thegetEnvironment()method to verify it correctly classifies versions as "production", "pre-release", "develop", or "feature" based on version string patterns.
private String getEnvironment() {
String version = serverInfo.getVersion();
String environment;
if (version.matches("\\d+\\.\\d+\\.\\d+")) {
environment = "production";
} else if (version.matches("\\d+\\.\\d+\\.\\d+-r[ca]\\d+")) {
environment = "pre-release";
} else if (version.startsWith("develop-") && !version.contains("-DIRTY-")) {
environment = "develop";
} else {
environment = "feature";
}
return environment;
}
Описание
Связанные задачи
Closes
Чеклист
Общие
gradlew precommit)Для диагностик
Дополнительно
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.