Skip to content

Commit

Permalink
Fix #207 (#208)
Browse files Browse the repository at this point in the history
* Fix #207

* Update RulesEngine/RuleProcessor.cs

Co-authored-by: Gabe Stocco <98900+gfs@users.noreply.github.com>

Co-authored-by: Gabe Stocco <98900+gfs@users.noreply.github.com>
  • Loading branch information
guyacosta and gfs authored May 18, 2020
1 parent 7994e9a commit b18b78e
Showing 1 changed file with 22 additions and 26 deletions.
48 changes: 22 additions & 26 deletions RulesEngine/RuleProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -310,45 +310,37 @@ private IEnumerable<Rule> GetRulesForLanguages(string[] languages)
}

/// <summary>
/// Check if rule tags have already been seen or if exception exists
/// Check if rule has at least one unique tag not seen before or if exception exists
/// Assumes that _uniqueTagsOnly == true has been checked first for relevance
/// </summary>
/// <param name="ruleTags"></param>
/// <returns></returns>
private bool UniqueTagsCheck(string[] ruleTags)
{
bool approved = true;
bool approved = false;

foreach (string tag in ruleTags)
{
if (_uniqueTagHashes.Contains(tag))
if (!_uniqueTagHashes.Contains(tag))
{
approved = false;
if (UniqueTagExceptions != null)
approved = true;
break;
}
else if (UniqueTagExceptions != null)
{
foreach (string tagException in UniqueTagExceptions)
{
foreach (string tagException in UniqueTagExceptions)
if (tag.Contains(tagException))
{
approved = tag.Contains(tagException);
if (approved)
{
break;
}
approved = true;
break;
}
}

if (_logger != null && !approved)
{
_logger.Debug(string.Format("Duplicate tag {0} not added", tag));
}

break;
}
}
else

if (_logger != null && !approved)
{
if (_logger != null)
{
_logger.Debug(string.Format("Unique tag {0} added", tag));
}
_logger.Debug(string.Format("Duplicate tag {0} not approved for match", tag));
}
}

Expand All @@ -364,10 +356,14 @@ private void AddRuleTagHashes(string[] ruleTags)
{
foreach (string t in ruleTags)
{
_uniqueTagHashes.Add(t);
bool added = _uniqueTagHashes.Add(t);
if (_logger != null && added)
{
_logger.Debug(string.Format("Unique tag {0} added", t));
}
}
}

#endregion Private Methods
}
}
}

0 comments on commit b18b78e

Please sign in to comment.