Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for targeting rule evaluation with semver (FF-1562) #10

Merged
merged 5 commits into from
Feb 13, 2024

Conversation

leoromanovsky
Copy link
Member

No description provided.

@@ -18,13 +18,14 @@ let package = Package(
dependencies: [
// Dependencies declare other packages that this package depends on.
// .package(url: /* package url */, from: "1.0.0"),
.package(url: "https://github.com/ddddxxx/Semver", from: "0.2.1")
Copy link
Member Author

@leoromanovsky leoromanovsky Feb 8, 2024

Choose a reason for hiding this comment

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

I chose this package because it supported swift 5.0, which is a fairly old version that we are supporting. When we move forward can replace it with a more package; however the scope of "semver" functionality is not that complex so I decided this is fairly safe.

do {
let comparisonResult: Bool
switch condition.targetingOperator {
case .GreaterThanEqualTo, .GreaterThan, .LessThanEqualTo, .LessThan:
Copy link
Member Author

Choose a reason for hiding this comment

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

I really like this programming style! Makes a lot of sense to me to branch at this top level as the behavior is quite different from matches and oneof/notoneof

Copy link

Choose a reason for hiding this comment

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

💯

Tests/eppo/RuleEvaluatorTests.swift Outdated Show resolved Hide resolved
Copy link

@aarsilv aarsilv left a comment

Choose a reason for hiding this comment

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

Nice work! Approving but with some potential clean ups I'd love for you to quickly look at.

return false
}

do {
Copy link

Choose a reason for hiding this comment

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

Do we need this outer do now that we use a guard clause? Or can we just un-nest everything one level?

Copy link
Member Author

Choose a reason for hiding this comment

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

it's so that we can catch all errors:

} catch {
            // Handle or log the error
            return false
        }

do you think this is not good behavior?

Copy link

Choose a reason for hiding this comment

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

oh sorry didn't realize that! I thought it was tied to the removed if statement. Appologies for my lack of swift fluency. Carry on!

do {
let comparisonResult: Bool
switch condition.targetingOperator {
case .GreaterThanEqualTo, .GreaterThan, .LessThanEqualTo, .LessThan:
Copy link

Choose a reason for hiding this comment

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

💯

Tests/eppo/RuleEvaluatorTests.swift Outdated Show resolved Hide resolved
@leoromanovsky leoromanovsky merged commit 1bf0616 into main Feb 13, 2024
1 check passed
@leoromanovsky leoromanovsky deleted the lr/ff-1562/semver branch February 13, 2024 00:18
leoromanovsky added a commit that referenced this pull request Mar 28, 2024
* add support for targeting rule evaluation with semver (FF-1562)

* remove comparisonResult intermediate value

* add unit test when one semver is invalid; return nil

* typo and comment
leoromanovsky added a commit that referenced this pull request Mar 28, 2024
* add support for targeting rule evaluation with semver (FF-1562)

* remove comparisonResult intermediate value

* add unit test when one semver is invalid; return nil

* typo and comment
leoromanovsky added a commit that referenced this pull request Apr 17, 2024
* add support for targeting rule evaluation with semver (FF-1562)

* remove comparisonResult intermediate value

* add unit test when one semver is invalid; return nil

* typo and comment
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.

3 participants