Skip to content

Commit

Permalink
feat: add to check newline before braces on UserDefinedTypes (#452)
Browse files Browse the repository at this point in the history
  • Loading branch information
NiumXp authored Nov 13, 2023
1 parent 11cfe4a commit 0e28c3b
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 1 deletion.
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

0 comments on commit 0e28c3b

Please sign in to comment.