Skip to content

Commit b18b78e

Browse files
guyacostagfs
andauthored
Fix #207 (#208)
* Fix #207 * Update RulesEngine/RuleProcessor.cs Co-authored-by: Gabe Stocco <[email protected]> Co-authored-by: Gabe Stocco <[email protected]>
1 parent 7994e9a commit b18b78e

File tree

1 file changed

+22
-26
lines changed

1 file changed

+22
-26
lines changed

RulesEngine/RuleProcessor.cs

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -310,45 +310,37 @@ private IEnumerable<Rule> GetRulesForLanguages(string[] languages)
310310
}
311311

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

322322
foreach (string tag in ruleTags)
323323
{
324-
if (_uniqueTagHashes.Contains(tag))
324+
if (!_uniqueTagHashes.Contains(tag))
325325
{
326-
approved = false;
327-
if (UniqueTagExceptions != null)
326+
approved = true;
327+
break;
328+
}
329+
else if (UniqueTagExceptions != null)
330+
{
331+
foreach (string tagException in UniqueTagExceptions)
328332
{
329-
foreach (string tagException in UniqueTagExceptions)
333+
if (tag.Contains(tagException))
330334
{
331-
approved = tag.Contains(tagException);
332-
if (approved)
333-
{
334-
break;
335-
}
335+
approved = true;
336+
break;
336337
}
337-
}
338-
339-
if (_logger != null && !approved)
340-
{
341-
_logger.Debug(string.Format("Duplicate tag {0} not added", tag));
342-
}
343-
344-
break;
338+
}
345339
}
346-
else
340+
341+
if (_logger != null && !approved)
347342
{
348-
if (_logger != null)
349-
{
350-
_logger.Debug(string.Format("Unique tag {0} added", tag));
351-
}
343+
_logger.Debug(string.Format("Duplicate tag {0} not approved for match", tag));
352344
}
353345
}
354346

@@ -364,10 +356,14 @@ private void AddRuleTagHashes(string[] ruleTags)
364356
{
365357
foreach (string t in ruleTags)
366358
{
367-
_uniqueTagHashes.Add(t);
359+
bool added = _uniqueTagHashes.Add(t);
360+
if (_logger != null && added)
361+
{
362+
_logger.Debug(string.Format("Unique tag {0} added", t));
363+
}
368364
}
369365
}
370366

371367
#endregion Private Methods
372368
}
373-
}
369+
}

0 commit comments

Comments
 (0)