Beispiel #1
0
        /// <summary>
        /// Initialise the underlying Watchdog for C#.
        /// Register new error checks here by adding them to the appropriate delegate.
        /// </summary>
        public override void Init()
        {
            base.Init();

            parsingParameters = new ParsingParameters();

            errorCodeStrings = new Dictionary <int, string>();

            errorCodeStrings[(int)ErrorCodes.TabError]                 = "Tabs instead of spaces used for indentation";
            errorCodeStrings[(int)ErrorCodes.PascalCaseError]          = "Identifier is not in PascalCase";
            errorCodeStrings[(int)ErrorCodes.CamelCaseError]           = "Identifier is not in camelCase";
            errorCodeStrings[(int)ErrorCodes.SpecialCharacterError]    = "Disallowed character used in identifier";
            errorCodeStrings[(int)ErrorCodes.MissingBracesError]       = "Missing curly braces in if / while / foreach / for";
            errorCodeStrings[(int)ErrorCodes.MultipleStatementError]   = "Multiple statements on a single line";
            errorCodeStrings[(int)ErrorCodes.CommentOnSameLineError]   = "Comment not on a separate line";
            errorCodeStrings[(int)ErrorCodes.CommentNoSpaceError]      = "No space between comment delimiter and comment text";
            errorCodeStrings[(int)ErrorCodes.ClassNotDocumentedError]  = "Public class not documented";
            errorCodeStrings[(int)ErrorCodes.MethodNotDocumentedError] = "Public method not documented";
            errorCodeStrings[(int)ErrorCodes.InterfaceNamingError]     = "Interface name does not begin with an I";

            statementHandler += Checks.TabError.Check;
            statementHandler += Checks.MultipleStatements.Check;
            // NOTE: With braces missing, the token is being reported as a statement.
            statementHandler += Checks.MissingBraces.Check;
            statementHandler += Checks.SpecialCharacter.Check;
            statementHandler += Checks.IdentifierPascalCase.Check;
            statementHandler += Checks.CamelCase.Check;

            commentHandler += Checks.CommentOnSameLine.Check;
            commentHandler += Checks.CommentNoSpace.Check;

            startBlockHandler += Checks.ClassNotDocumented.Check;
            startBlockHandler += Checks.ClassPascalCase.Check;
            startBlockHandler += Checks.EnumPascalCase.Check;
            startBlockHandler += Checks.InterfaceNaming.Check;
            startBlockHandler += Checks.MethodNotDocumented.Check;
            startBlockHandler += Checks.MethodPascalCase.Check;
            startBlockHandler += Checks.PropertyPascalCase.Check;

            return;
        }
        /// <summary>
        /// Initialise the underlying Watchdog for C#.
        /// Register new error checks here by adding them to the appropriate delegate.
        /// </summary>
        public override void Init()
        {
            base.Init();

            parsingParameters = new ParsingParameters();

            errorCodeStrings = new Dictionary<int, string>();

            errorCodeStrings[(int)ErrorCodes.TabError] = "Tabs instead of spaces used for indentation";
            errorCodeStrings[(int)ErrorCodes.PascalCaseError] = "Identifier is not in PascalCase";
            errorCodeStrings[(int)ErrorCodes.CamelCaseError] = "Identifier is not in camelCase";
            errorCodeStrings[(int)ErrorCodes.SpecialCharacterError] = "Disallowed character used in identifier";
            errorCodeStrings[(int)ErrorCodes.MissingBracesError] = "Missing curly braces in if / while / foreach / for";
            errorCodeStrings[(int)ErrorCodes.MultipleStatementError] = "Multiple statements on a single line";
            errorCodeStrings[(int)ErrorCodes.CommentOnSameLineError] = "Comment not on a separate line";
            errorCodeStrings[(int)ErrorCodes.CommentNoSpaceError] = "No space between comment delimiter and comment text";
            errorCodeStrings[(int)ErrorCodes.ClassNotDocumentedError] = "Public class not documented";
            errorCodeStrings[(int)ErrorCodes.MethodNotDocumentedError] = "Public method not documented";
            errorCodeStrings[(int)ErrorCodes.InterfaceNamingError] = "Interface name does not begin with an I";

            statementHandler += Checks.TabError.Check;
            statementHandler += Checks.MultipleStatements.Check;
            // NOTE: With braces missing, the token is being reported as a statement.
            statementHandler += Checks.MissingBraces.Check;
            statementHandler += Checks.SpecialCharacter.Check;
            statementHandler += Checks.IdentifierPascalCase.Check;
            statementHandler += Checks.CamelCase.Check;

            commentHandler += Checks.CommentOnSameLine.Check;
            commentHandler += Checks.CommentNoSpace.Check;

            startBlockHandler += Checks.ClassNotDocumented.Check;
            startBlockHandler += Checks.ClassPascalCase.Check;
            startBlockHandler += Checks.EnumPascalCase.Check;
            startBlockHandler += Checks.InterfaceNaming.Check;
            startBlockHandler += Checks.MethodNotDocumented.Check;
            startBlockHandler += Checks.MethodPascalCase.Check;
            startBlockHandler += Checks.PropertyPascalCase.Check;

            return;
        }