diff --git a/norminette/rules/check_func_declaration.py b/norminette/rules/check_func_declaration.py index f744c74..1fa6208 100644 --- a/norminette/rules/check_func_declaration.py +++ b/norminette/rules/check_func_declaration.py @@ -48,6 +48,7 @@ def run(self, context): i += 1 if context.check_token(i, "LPARENTHESIS") is False: context.new_error("EXP_PARENTHESIS", context.peek_token(i)) + i = context.skip_ws(i) i += 1 deep = 1 while deep > 0 and context.peek_token(i) is not None: diff --git a/tests/rules/samples/ko_func_name2.c b/tests/rules/samples/ko_func_name2.c index 7f758e3..c0610ac 100644 --- a/tests/rules/samples/ko_func_name2.c +++ b/tests/rules/samples/ko_func_name2.c @@ -7,3 +7,15 @@ int main (void) { return (21); } + +int main (void) +{ + int array[] = {1, 2, 3, 4, 5}; + + return (0); +} + +int _1 a b c(void) +{ + return ; +} diff --git a/tests/rules/samples/ko_func_name2.out b/tests/rules/samples/ko_func_name2.out index 89fdd2b..3bbe9b8 100644 --- a/tests/rules/samples/ko_func_name2.out +++ b/tests/rules/samples/ko_func_name2.out @@ -16,7 +16,40 @@ ko_func_name2.c - IsBlockEnd In "Function" from "GlobalScope" line 9": +ko_func_name2.c - IsEmptyLine In "GlobalScope" from "None" line 10": + +ko_func_name2.c - IsFuncDeclaration In "GlobalScope" from "None" line 11": + +ko_func_name2.c - IsBlockStart In "Function" from "GlobalScope" line 12": + +ko_func_name2.c - IsVarDeclaration In "Function" from "GlobalScope" line 13": + +ko_func_name2.c - IsEmptyLine In "Function" from "GlobalScope" line 14": + +ko_func_name2.c - IsExpressionStatement In "Function" from "GlobalScope" line 15": + +ko_func_name2.c - IsBlockEnd In "Function" from "GlobalScope" line 16": + +ko_func_name2.c - IsEmptyLine In "GlobalScope" from "None" line 17": + +ko_func_name2.c - IsFuncDeclaration In "GlobalScope" from "None" line 18": + +ko_func_name2.c - IsBlockStart In "Function" from "GlobalScope" line 19": + +ko_func_name2.c - IsExpressionStatement In "Function" from "GlobalScope" line 20": + +ko_func_name2.c - IsBlockEnd In "Function" from "GlobalScope" line 21": + ko_func_name2.c: Error! Error: INVALID_HEADER (line: 1, col: 1): Missing or invalid 42 header Error: EXP_PARENTHESIS (line: 1, col: 9): Expected parenthesis Error: EXP_PARENTHESIS (line: 6, col: 9): Expected parenthesis +Error: SPACE_BEFORE_FUNC (line: 11, col: 4): space before function name +Error: EXP_PARENTHESIS (line: 11, col: 9): Expected parenthesis +Error: TOO_FEW_TAB (line: 13, col: 1): Missing tabs for indent level +Error: SPACE_REPLACE_TAB (line: 13, col: 5): Found space when expecting tab +Error: SPACE_REPLACE_TAB (line: 13, col: 8): Found space when expecting tab +Error: DECL_ASSIGN_LINE (line: 13, col: 17): Declaration and assignation on a single line +Error: TOO_FEW_TAB (line: 15, col: 1): Missing tabs for indent level +Error: SPACE_REPLACE_TAB (line: 15, col: 5): Found space when expecting tab +Error: SPACE_BEFORE_FUNC (line: 18, col: 11): space before function name