Skip to content

Commit

Permalink
Merge pull request #20 from alippo-com/fix/pub_analysis
Browse files Browse the repository at this point in the history
chore: code formation & updated description
  • Loading branch information
DK070202 authored Aug 28, 2022
2 parents 3708b0c + 97264c9 commit bb675f5
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 12 deletions.
6 changes: 4 additions & 2 deletions lib/src/Evaluator/condition_evaluator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,8 @@ class GBConditionEvaluator {
for (var key in conditionValue.keys) {
// If evalOperatorCondition(key, attributeValue, value)
// is false, return false
if (!evalOperatorCondition(key, attributeValue, conditionValue[key])) {
if (!evalOperatorCondition(
key, attributeValue, conditionValue[key])) {
return false;
}
}
Expand Down Expand Up @@ -284,7 +285,8 @@ class GBConditionEvaluator {
if (operator == "\$exists") {
if (conditionValue.toString() == 'false' && attributeValue == null) {
return true;
} else if (conditionValue.toString() == 'true' && attributeValue != null) {
} else if (conditionValue.toString() == 'true' &&
attributeValue != null) {
return true;
}
}
Expand Down
6 changes: 4 additions & 2 deletions lib/src/Evaluator/feature_evaluator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ class GBFeatureEvaluator {
if (rule.condition != null) {
final attr = context.attributes ?? {};
if (!GBConditionEvaluator().evaluateCondition(attr, rule.condition!)) {
if (!GBConditionEvaluator()
.evaluateCondition(attr, rule.condition!)) {
continue;
}
}
Expand Down Expand Up @@ -83,7 +84,8 @@ class GBFeatureEvaluator {
}
// Return (value = defaultValue or null, source = defaultValue)
return _prepareResult(
value: targetFeature.defaultValue, source: GBFeatureSource.defaultValue);
value: targetFeature.defaultValue,
source: GBFeatureSource.defaultValue);
}

/// This is a helper method to create a FeatureResult object.
Expand Down
3 changes: 2 additions & 1 deletion lib/src/Model/features.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ class GBFeature {
/// The default value (should use null if not specified)
dynamic defaultValue;

factory GBFeature.fromJson(Map<String, dynamic> value) => _$GBFeatureFromJson(value);
factory GBFeature.fromJson(Map<String, dynamic> value) =>
_$GBFeatureFromJson(value);
}

/// Rule object consists of various definitions to apply to calculate feature value
Expand Down
6 changes: 4 additions & 2 deletions lib/src/Utils/extension.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,11 @@ extension StringComparison on String {

bool operator >(String other) => calculateWeight() > other.calculateWeight();

bool operator >=(String other) => calculateWeight() >= other.calculateWeight();
bool operator >=(String other) =>
calculateWeight() >= other.calculateWeight();

bool operator <=(String other) => calculateWeight() <= other.calculateWeight();
bool operator <=(String other) =>
calculateWeight() <= other.calculateWeight();

int calculateWeight() {
final List<int> data = codeUnits;
Expand Down
9 changes: 6 additions & 3 deletions lib/src/Utils/gb_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ class GBUtils {

///This converts and experiment's coverage and variation weights into an array
/// of bucket ranges.
List<GBBucketRange> getBucketRanges(int numVariations, double coverage, List<double> weights) {
List<GBBucketRange> getBucketRanges(
int numVariations, double coverage, List<double> weights) {
List<GBBucketRange> bucketRange;

// Clamp the value of coverage to between 0 and 1 inclusive.
Expand All @@ -71,7 +72,8 @@ class GBUtils {
}
// Default to equal weights if the sum is not equal 1 (or close enough when
// rounding errors are factored in):
final weightsSum = targetWeights.fold<double>(0, (previousValue, element) => previousValue + element);
final weightsSum = targetWeights.fold<double>(
0, (previousValue, element) => previousValue + element);
if (weightsSum < 0.99 || weightsSum > 1.01) {
targetWeights = getEqualWeights(numVariations);
}
Expand Down Expand Up @@ -109,7 +111,8 @@ class GBUtils {
final end = namespace[2];

if (start != null && end != null) {
return GBNameSpace(title, double.parse(start.toString()), double.parse(end.toString()));
return GBNameSpace(title, double.parse(start.toString()),
double.parse(end.toString()));
}
}

Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: growthbook_sdk_flutter
description: GrowthBook SDK for flutter.
description: An open-source feature flagging and experimentation platform that makes it simple to alter features and execute A/B testing.
version: 1.1.0+2
homepage: https://github.com/alippo-com/GrowthBook-SDK-Flutter

Expand Down
3 changes: 2 additions & 1 deletion test/common_test/gb_condition_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ void main() {
if (item is List) {
final localItem = item;
final evaluator = GBConditionEvaluator();
final result = evaluator.evaluateCondition(localItem[2], localItem[1]);
final result =
evaluator.evaluateCondition(localItem[2], localItem[1]);
final status = localItem[0].toString() +
"\nExpected Result - " +
localItem[3].toString() +
Expand Down

0 comments on commit bb675f5

Please sign in to comment.