From 1f00fc966f36a82bfeb5d77246cf5ef6faf7762a Mon Sep 17 00:00:00 2001 From: NiumXp Date: Sun, 21 Jan 2024 14:31:24 -0300 Subject: [PATCH 1/2] fix #477 --- norminette/rules/check_func_declaration.py | 1 + 1 file changed, 1 insertion(+) diff --git a/norminette/rules/check_func_declaration.py b/norminette/rules/check_func_declaration.py index f744c748..1fa62083 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: From 867e1a36d6043578ce8a1c4693332e3169a7f395 Mon Sep 17 00:00:00 2001 From: NiumXp Date: Tue, 23 Jan 2024 18:32:39 -0300 Subject: [PATCH 2/2] add test about #477 --- tests/rules/samples/ko_func_name2.c | 12 ++++++++++ tests/rules/samples/ko_func_name2.out | 33 +++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/tests/rules/samples/ko_func_name2.c b/tests/rules/samples/ko_func_name2.c index 7f758e3d..c0610acb 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 89fdd2b0..3bbe9b8c 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