protected override bool IsResultDeclaration(Declaration declaration, DeclarationFinder finder, string[] whitelistedNames)
 {
     return(!string.IsNullOrEmpty(declaration.IdentifierName) &&
            !IgnoreDeclarationTypes.Contains(declaration.DeclarationType) &&
            !(declaration.Context is VBAParser.LineNumberLabelContext) &&
            (declaration.ParentDeclaration == null ||
             !IgnoreDeclarationTypes.Contains(declaration.ParentDeclaration.DeclarationType) &&
             !finder.FindEventHandlers().Contains(declaration.ParentDeclaration)) &&
            !whitelistedNames.Contains(declaration.IdentifierName) &&
            !VBAIdentifierValidator.IsMeaningfulIdentifier(declaration.IdentifierName));
 }
        protected override IEnumerable <IInspectionResult> DoGetInspectionResults()
        {
            var settings         = _settings.Read();
            var whitelistedNames = settings.WhitelistedIdentifiers.Select(s => s.Identifier).ToArray();

            var handlers = State.DeclarationFinder.FindEventHandlers();

            var issues = UserDeclarations
                         .Where(declaration => !string.IsNullOrEmpty(declaration.IdentifierName) &&
                                !IgnoreDeclarationTypes.Contains(declaration.DeclarationType) &&
                                !(declaration.Context is LineNumberLabelContext) &&
                                (declaration.ParentDeclaration == null ||
                                 !IgnoreDeclarationTypes.Contains(declaration.ParentDeclaration.DeclarationType) &&
                                 !handlers.Contains(declaration.ParentDeclaration)) &&
                                !whitelistedNames.Contains(declaration.IdentifierName) &&
                                !VBAIdentifierValidator.IsMeaningfulIdentifier(declaration.IdentifierName));

            return((from issue in issues select CreateInspectionResult(this, issue))
                   .ToList());
        }
 public void VBAIdentifierValidator_IsMeaningfulName(string identifier, bool expected)
 {
     Assert.AreEqual(expected, VBAIdentifierValidator.IsMeaningfulIdentifier(identifier));
 }