Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #477 #480

Merged
merged 2 commits into from
Feb 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions norminette/rules/check_func_declaration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
12 changes: 12 additions & 0 deletions tests/rules/samples/ko_func_name2.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 ;
}
33 changes: 33 additions & 0 deletions tests/rules/samples/ko_func_name2.out
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,40 @@
<TAB> <RETURN> <SPACE> <LPARENTHESIS> <CONSTANT=21> <RPARENTHESIS> <SEMI_COLON> <NEWLINE>
ko_func_name2.c - IsBlockEnd In "Function" from "GlobalScope" line 9":
<RBRACE> <NEWLINE>
ko_func_name2.c - IsEmptyLine In "GlobalScope" from "None" line 10":
<NEWLINE>
ko_func_name2.c - IsFuncDeclaration In "GlobalScope" from "None" line 11":
<INT> <SPACE> <IDENTIFIER=main> <SPACE> <LPARENTHESIS> <VOID> <RPARENTHESIS> <NEWLINE>
ko_func_name2.c - IsBlockStart In "Function" from "GlobalScope" line 12":
<LBRACE> <NEWLINE>
ko_func_name2.c - IsVarDeclaration In "Function" from "GlobalScope" line 13":
<SPACE> <SPACE> <SPACE> <SPACE> <INT> <SPACE> <IDENTIFIER=array> <LBRACKET> <RBRACKET> <SPACE> <ASSIGN> <SPACE> <LBRACE> <CONSTANT=1> <COMMA> <SPACE> <CONSTANT=2> <COMMA> <SPACE> <CONSTANT=3> <COMMA> <SPACE> <CONSTANT=4> <COMMA> <SPACE> <CONSTANT=5> <RBRACE> <SEMI_COLON> <NEWLINE>
ko_func_name2.c - IsEmptyLine In "Function" from "GlobalScope" line 14":
<NEWLINE>
ko_func_name2.c - IsExpressionStatement In "Function" from "GlobalScope" line 15":
<SPACE> <SPACE> <SPACE> <SPACE> <RETURN> <SPACE> <LPARENTHESIS> <CONSTANT=0> <RPARENTHESIS> <SEMI_COLON> <NEWLINE>
ko_func_name2.c - IsBlockEnd In "Function" from "GlobalScope" line 16":
<RBRACE> <NEWLINE>
ko_func_name2.c - IsEmptyLine In "GlobalScope" from "None" line 17":
<NEWLINE>
ko_func_name2.c - IsFuncDeclaration In "GlobalScope" from "None" line 18":
<INT> <SPACE> <IDENTIFIER=_1> <SPACE> <IDENTIFIER=a> <SPACE> <IDENTIFIER=b> <SPACE> <IDENTIFIER=c> <LPARENTHESIS> <VOID> <RPARENTHESIS> <NEWLINE>
ko_func_name2.c - IsBlockStart In "Function" from "GlobalScope" line 19":
<LBRACE> <NEWLINE>
ko_func_name2.c - IsExpressionStatement In "Function" from "GlobalScope" line 20":
<TAB> <RETURN> <SPACE> <SEMI_COLON> <NEWLINE>
ko_func_name2.c - IsBlockEnd In "Function" from "GlobalScope" line 21":
<RBRACE> <NEWLINE>
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
Loading