Initing empty lists with GLOBAL_LIST_INIT(X, list()) is now prohibited by CI (#23247)

* moreglobals

* comment
This commit is contained in:
Contrabang
2023-11-29 12:41:01 -05:00
committed by GitHub
parent a4c0c2f40d
commit b6601ebd29
10 changed files with 75 additions and 66 deletions

View File

@@ -118,6 +118,15 @@ def check_conditional_spacing(lines):
if CONDITIONAL_INFIX_NOT_SPACE.search(line):
return Failure(idx + 1, "Found a conditional statement matching the format \"if(! thing)\", please use \"if(!thing)\" instead.")
# makes sure that no global list inits have an empty list in them without using the helper
GLOBAL_LIST_EMPTY = re.compile(r"(?<!#define GLOBAL_LIST_EMPTY\(X\) )GLOBAL_LIST_INIT([^,]+),.{0,5}list\(\)")
# This uses a negative look behind to make sure its not the global list definition
# An easy regex replacement for this is GLOBAL_LIST_EMPTY$1
def check_global_list_empty(lines):
for idx, line in enumerate(lines):
if GLOBAL_LIST_EMPTY.search(line):
return Failure(idx + 1, "Found a GLOBAL_LIST_INIT(_, list()), please use GLOBAL_LIST_EMPTY(_) instead.")
CODE_CHECKS = [
check_space_indentation,
check_mixed_indentation,