Skip to content

Commit

Permalink
fix: lints & copyright dates
Browse files Browse the repository at this point in the history
  • Loading branch information
mikechu-optimizely committed Oct 23, 2024
1 parent 5d0584f commit 99d59c1
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 34 deletions.
2 changes: 1 addition & 1 deletion OptimizelySDK.Tests/DecisionServiceTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public void SetUp()
ErrorHandlerMock.Object, null, LoggerMock.Object);
DecisionServiceMock = new Mock<DecisionService>(BucketerMock.Object,
ErrorHandlerMock.Object, null, LoggerMock.Object)
{ CallBase = true };
{ CallBase = true };
DecisionReasons = new DecisionReasons();

VariationWithKeyControl =
Expand Down
15 changes: 5 additions & 10 deletions OptimizelySDK/Bucketing/DecisionService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,7 @@ ProjectConfig config
if (experimentToVariationMap.ContainsKey(experimentId) == false)
{
Logger.Log(LogLevel.DEBUG,
$@"No experiment ""{experimentKey}"" mapped to user ""{userId
}"" in the forced variation map.");
$@"No experiment ""{experimentKey}"" mapped to user ""{userId}"" in the forced variation map.");
return Result<Variation>.NullResult(reasons);
}

Expand All @@ -274,8 +273,7 @@ ProjectConfig config
if (string.IsNullOrEmpty(variationId))
{
Logger.Log(LogLevel.DEBUG,
$@"No variation mapped to experiment ""{experimentKey
}"" in the forced variation map.");
$@"No variation mapped to experiment ""{experimentKey}"" in the forced variation map.");
return Result<Variation>.NullResult(reasons);
}

Expand All @@ -288,8 +286,7 @@ ProjectConfig config
}

Logger.Log(LogLevel.DEBUG,
reasons.AddInfo($@"Variation ""{variationKey}"" is mapped to experiment ""{
experimentKey}"" and user ""{userId}"" in the forced variation map"));
reasons.AddInfo($@"Variation ""{variationKey}"" is mapped to experiment ""{experimentKey}"" and user ""{userId}"" in the forced variation map"));

var variation = config.GetVariationFromKey(experimentKey, variationKey);

Expand Down Expand Up @@ -333,8 +330,7 @@ ProjectConfig config
}

Logger.Log(LogLevel.DEBUG,
$@"Variation mapped to experiment ""{experimentKey
}"" has been removed for user ""{userId}"".");
$@"Variation mapped to experiment ""{experimentKey}"" has been removed for user ""{userId}"".");
return true;
}

Expand All @@ -356,8 +352,7 @@ ProjectConfig config
ForcedVariationMap[userId][experimentId] = variationId;

Logger.Log(LogLevel.DEBUG,
$@"Set variation ""{variationId}"" for experiment ""{experimentId}"" and user ""{
userId}"" in the forced variation map.");
$@"Set variation ""{variationId}"" for experiment ""{experimentId}"" and user ""{userId}"" in the forced variation map.");
return true;
}

Expand Down
38 changes: 15 additions & 23 deletions OptimizelySDK/Optimizely.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2017-2023, Optimizely
* Copyright 2017-2024, Optimizely
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use file except in compliance with the License.
Expand Down Expand Up @@ -573,8 +573,7 @@ public virtual bool IsFeatureEnabled(string featureKey, string userId,
else
{
Logger.Log(LogLevel.INFO,
$@"The user ""{userId}"" is not being experimented on feature ""{featureKey
}"".");
$@"The user ""{userId}"" is not being experimented on feature ""{featureKey}"".");
}
}

Expand Down Expand Up @@ -624,8 +623,7 @@ public virtual T GetFeatureVariableValueForType<T>(string featureKey, string var
if (config == null)
{
Logger.Log(LogLevel.ERROR,
$@"Datafile has invalid format. Failing '{
FeatureVariable.GetFeatureVariableTypeName(variableType)}'.");
$@"Datafile has invalid format. Failing '{FeatureVariable.GetFeatureVariableTypeName(variableType)}'.");
return default;
}

Expand All @@ -649,15 +647,13 @@ public virtual T GetFeatureVariableValueForType<T>(string featureKey, string var
if (featureVariable == null)
{
Logger.Log(LogLevel.ERROR,
$@"No feature variable was found for key ""{variableKey}"" in feature flag ""{
featureKey}"".");
$@"No feature variable was found for key ""{variableKey}"" in feature flag ""{featureKey}"".");
return default;
}
else if (featureVariable.Type != variableType)
{
Logger.Log(LogLevel.ERROR,
$@"Variable is of type ""{featureVariable.Type
}"", but you requested it as type ""{variableType}"".");
$@"Variable is of type ""{featureVariable.Type}"", but you requested it as type ""{variableType}"".");
return default;
}

Expand All @@ -681,28 +677,24 @@ public virtual T GetFeatureVariableValueForType<T>(string featureKey, string var
{
variableValue = featureVariableUsageInstance.Value;
Logger.Log(LogLevel.INFO,
$@"Got variable value ""{variableValue}"" for variable ""{variableKey
}"" of feature flag ""{featureKey}"".");
$@"Got variable value ""{variableValue}"" for variable ""{variableKey}"" of feature flag ""{featureKey}"".");
}
else
{
Logger.Log(LogLevel.INFO,
$@"Feature ""{featureKey}"" is not enabled for user {userId
}. Returning the default variable value ""{variableValue}"".");
$@"Feature ""{featureKey}"" is not enabled for user {userId}. Returning the default variable value ""{variableValue}"".");
}
}
else
{
Logger.Log(LogLevel.INFO,
$@"Variable ""{variableKey}"" is not used in variation ""{variation.Key
}"", returning default value ""{variableValue}"".");
$@"Variable ""{variableKey}"" is not used in variation ""{variation.Key}"", returning default value ""{variableValue}"".");
}
}
else
{
Logger.Log(LogLevel.INFO,
$@"User ""{userId}"" is not in any variation for feature flag ""{featureKey
}"", returning default value ""{variableValue}"".");
$@"User ""{userId}"" is not in any variation for feature flag ""{featureKey}"", returning default value ""{variableValue}"".");
}

var sourceInfo = new Dictionary<string, string>();
Expand Down Expand Up @@ -951,12 +943,12 @@ internal Dictionary<string, OptimizelyDecision> DecideForKeys(OptimizelyUserCont

var decisionReasons = new DecisionReasons();
decisionReasonsMap.Add(key, decisionReasons);

var optimizelyDecisionContext = new OptimizelyDecisionContext(key);
var forcedDecisionVariation =
DecisionService.ValidatedForcedDecision(optimizelyDecisionContext, projectConfig, user);
decisionReasons += forcedDecisionVariation.DecisionReasons;

if (forcedDecisionVariation.ResultObject != null)
{
flagDecisions.Add(key, new FeatureDecision(null,
Expand Down Expand Up @@ -1040,7 +1032,7 @@ ProjectConfig projectConfig
decisionSource = flagDecision.Source;
}

var includeReasons= allOptions.Contains(OptimizelyDecideOption.INCLUDE_REASONS);
var includeReasons = allOptions.Contains(OptimizelyDecideOption.INCLUDE_REASONS);
var reasonsToReport = decisionReasons.ToReport(includeReasons).ToArray();
var variationKey = flagDecision.Variation?.Key;
// TODO: add ruleKey values when available later. use a copy of experimentKey until then.
Expand Down Expand Up @@ -1071,8 +1063,8 @@ ProjectConfig projectConfig
{ "reasons", reasonsToReport },
{ "decisionEventDispatched", decisionEventDispatched },
};
NotificationCenter.SendNotifications(NotificationCenter.NotificationType.Decision,

NotificationCenter.SendNotifications(NotificationCenter.NotificationType.Decision,
DecisionNotificationTypes.FLAG, userId, user.GetAttributes(), decisionInfo);

return new OptimizelyDecision(
Expand Down Expand Up @@ -1114,7 +1106,7 @@ private Result<Dictionary<string, object>> GetDecisionVariableMap(FeatureFlag fl

valuesMap[variable.Key] = convertedValue;
}

return Result<Dictionary<string, object>>.NewResult(valuesMap, reasons);
}

Expand Down

0 comments on commit 99d59c1

Please sign in to comment.