Skip to content

Commit

Permalink
Fix typos & minor code style improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
adams85 committed Oct 26, 2023
1 parent 7306e00 commit 537a906
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
3 changes: 1 addition & 2 deletions src/ConfigCatClient/Evaluation/EvaluateLogHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -203,11 +203,10 @@ private static IndentedTextBuilder AppendPercentageOptions(this IndentedTextBuil

private static IndentedTextBuilder AppendTargetingRuleThenPart(this IndentedTextBuilder builder, TargetingRule targetingRule, bool newLine, bool appendPercentageOptions = false, string? percentageOptionsAttribute = null)
{
var percentageOptions = targetingRule.PercentageOptions;

(newLine ? builder.NewLine() : builder.Append(" "))
.Append("THEN");

var percentageOptions = targetingRule.PercentageOptions;
if (percentageOptions is not { Length: > 0 })
{
return builder.Append($" '{targetingRule.SimpleValue?.Value ?? default}'");
Expand Down
17 changes: 7 additions & 10 deletions src/ConfigCatClient/Evaluation/RolloutEvaluator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public EvaluateResult Evaluate<T>(T defaultValue, ref EvaluateContext context, [
if (context.Setting.SettingType != Setting.UnknownType && context.Setting.SettingType != expectedSettingType)
{
throw new InvalidOperationException(
"The type of a setting must match the type of the specified default value "
"The type of a setting must match the type of the specified default value. "
+ $"Setting's type was {context.Setting.SettingType} but the default value's type was {typeof(T)}. "
+ $"Please use a default value which corresponds to the setting type {context.Setting.SettingType}.");
}
Expand Down Expand Up @@ -158,13 +158,10 @@ private bool TryEvaluateTargetingRules(TargetingRule[] targetingRules, ref Evalu
logBuilder?.DecreaseIndent();
return true;
}
else
{
logBuilder?
.NewLine(TargetingRuleIgnoredMessage)
.DecreaseIndent();
continue;
}

logBuilder?
.NewLine(TargetingRuleIgnoredMessage)
.DecreaseIndent();
}

result = default;
Expand Down Expand Up @@ -236,14 +233,14 @@ private bool TryEvaluatePercentageOptions(PercentageOption[] percentageOptions,
continue;
}

var percentageOptionValue = percentageOption.Value.GetValue(context.Setting.SettingType, throwIfInvalid: false);
var percentageOptionValue = percentageOption.Value.GetValue(throwIfInvalid: false);
logBuilder?.NewLine().Append($"- Hash value {hashValue} selects % option {i + 1} ({percentageOption.Percentage}%), '{percentageOptionValue ?? EvaluateLogHelper.InvalidValuePlaceholder}'.");

result = new EvaluateResult(percentageOption, matchedTargetingRule: targetingRule, matchedPercentageOption: percentageOption);
return true;
}

throw new InvalidOperationException("Sum of percentage option percentages are less than 100).");
throw new InvalidOperationException("Sum of percentage option percentages are less than 100.");
}

private bool TryEvaluateConditions<TCondition>(TCondition[] conditions, TargetingRule? targetingRule, string contextSalt, ref EvaluateContext context, out bool result)
Expand Down

0 comments on commit 537a906

Please sign in to comment.