Repository: microsoft/ApplicationInspector
File: RulesEngine/RuleProcessor.cs (C#)

Code before:
        /// </summary>
        /// <param name="ruleTags"></param>
        /// <returns></returns>
        private bool UniqueTagsCheck(string[] ruleTags)
        {
            bool approved = false;

            foreach (string tag in ruleTags)
            {
                if (!_uniqueTagHashes.Contains(tag))
                {
                    approved = true;
                    break;
                }
                else if (UniqueTagExceptions != null)
                {
                    foreach (string tagException in UniqueTagExceptions)
                    {
                        if (tag.Contains(tagException))
                        {
                            approved = true;
                            break;
                        }
                    }                   
                }
                else if (_logger != null && !approved)
                {
                    _logger.Debug(string.Format("Duplicate tag {0} not approved for match", tag));
                }
            }

            return approved;
        }

        /// <summary>
        /// Supports unique tags option to not process if seen before
        /// No harm in being called again for same value; will not be added...
        /// </summary>
        /// <param name="ruleTags"></param>
        private void AddRuleTagHashes(string[] ruleTags)
        {
            foreach (string t in ruleTags)
            {
                bool added = _uniqueTagHashes.Add(t);
                if (_logger != null && added)
                {
                    _logger.Debug(string.Format("Unique tag {0} added", t));
                }
            }
        }


Review comment (refactor):
You don't know if its a duplicate until you've checked everything and determined if its approved or not. Which might occur inside of one of if branches this was attached to.

```suggestion
                
                if (_logger != null && !approved)
```

Code after:
        /// </summary>
        /// <param name="ruleTags"></param>
        /// <returns></returns>
        private bool UniqueTagsCheck(string[] ruleTags)
        {
            bool approved = false;

            foreach (string tag in ruleTags)
            {
                if (!_uniqueTagHashes.Contains(tag))
                {
                    approved = true;
                    break;
                }
                else if (UniqueTagExceptions != null)
                {
                    foreach (string tagException in UniqueTagExceptions)
                    {
                        if (tag.Contains(tagException))
                        {
                            approved = true;
                            break;
                        }
                    }                   
                }
                
                if (_logger != null && !approved)
                {
                    _logger.Debug(string.Format("Duplicate tag {0} not approved for match", tag));
                }
            }

            return approved;
        }

        /// <summary>
        /// Supports unique tags option to not process if seen before
        /// No harm in being called again for same value; will not be added...
        /// </summary>
        /// <param name="ruleTags"></param>
        private void AddRuleTagHashes(string[] ruleTags)
        {
            foreach (string t in ruleTags)
            {
                bool added = _uniqueTagHashes.Add(t);
                if (_logger != null && added)
                {
                    _logger.Debug(string.Format("Unique tag {0} added", t));
                }
            }
        }