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

feat: add to check newline before braces on UserDefinedTypes #452

Merged
merged 1 commit into from
Nov 13, 2023
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
8 changes: 7 additions & 1 deletion norminette/rules/check_func_declaration.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
class CheckFuncDeclaration(Rule):
def __init__(self):
super().__init__()
self.depends_on = ["IsFuncDeclaration", "IsFuncPrototype"]
self.depends_on = (
"IsFuncDeclaration",
"IsFuncPrototype",
"IsUserDefinedType",
)

def run(self, context):
"""
Expand All @@ -22,6 +26,8 @@ def run(self, context):
if context.check_token(tmp, "LBRACE") is True:
context.new_error("BRACE_NEWLINE", context.peek_token(tmp))
tmp += 1
if context.history[-1] == "IsUserDefinedType":
return
# if tmp < context.tkn_scope - 2:
# context.new_error("NEWLINE_IN_DECL", context.peek_token(tmp))
# this is a func declaration
Expand Down
1 change: 1 addition & 0 deletions tests/rules/samples/ko_struct_indent.out
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Error: MISALIGNED_VAR_DECL (line: 2, col: 29): Misaligned variable declarati
Notice: GLOBAL_VAR_DETECTED (line: 3, col: 1): Global variable present in file. Make sure it is a reasonable choice.
Error: MISALIGNED_VAR_DECL (line: 3, col: 29): Misaligned variable declaration
Error: MULT_DECL_LINE (line: 3, col: 34): Multiple declarations on a single line
Error: BRACE_NEWLINE (line: 5, col: 23): Expected newline before brace
Error: MISALIGNED_VAR_DECL (line: 7, col: 29): Misaligned variable declaration
Error: MISALIGNED_VAR_DECL (line: 8, col: 1): Misaligned variable declaration
Error: MISALIGNED_VAR_DECL (line: 9, col: 29): Misaligned variable declaration
1 change: 1 addition & 0 deletions tests/rules/samples/ko_struct_name.out
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,6 @@ Notice: GLOBAL_VAR_DETECTED (line: 2, col: 1): Global variable present in f
Error: GLOBAL_VAR_NAMING (line: 2, col: 25): Global variable must start with g_
Notice: GLOBAL_VAR_DETECTED (line: 3, col: 1): Global variable present in file. Make sure it is a reasonable choice.
Error: GLOBAL_VAR_NAMING (line: 3, col: 25): Global variable must start with g_
Error: BRACE_NEWLINE (line: 5, col: 21): Expected newline before brace
Error: USER_DEFINED_TYPEDEF (line: 8, col: 25): User defined typedef must start with t_
Error: USER_DEFINED_TYPEDEF (line: 10, col: 5): User defined typedef must start with t_
1 change: 1 addition & 0 deletions tests/rules/samples/long_test.out
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ Error: NO_SPC_AFR_PAR (line: 38, col: 17): Extra space after parenthesis
Error: SPACE_REPLACE_TAB (line: 39, col: 4): Found space when expecting tab
Error: EXP_PARENTHESIS (line: 39, col: 10): Expected parenthesis
Error: ENUM_TYPE_NAMING (line: 40, col: 6): Enum name must start with e_
Error: BRACE_NEWLINE (line: 40, col: 10): Expected newline before brace
Error: MISALIGNED_FUNC_DECL (line: 46, col: 21): Misaligned function declaration
Error: MISALIGNED_FUNC_DECL (line: 47, col: 21): Misaligned function declaration
Error: MISALIGNED_FUNC_DECL (line: 48, col: 21): Misaligned function declaration
Expand Down