From 6ef35992546b8b3dffbc39544a640686e14b7b6a Mon Sep 17 00:00:00 2001 From: ShizCalev Date: Mon, 5 Sep 2022 05:55:22 -0400 Subject: [PATCH] adds grep check for improperly used timer flags. (#69668) --- code/controllers/subsystem/timer.dm | 2 +- tools/ci/check_grep.sh | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/code/controllers/subsystem/timer.dm b/code/controllers/subsystem/timer.dm index 7fbc146f89e..89596a5720b 100644 --- a/code/controllers/subsystem/timer.dm +++ b/code/controllers/subsystem/timer.dm @@ -610,7 +610,7 @@ SUBSYSTEM_DEF(timer) . = hash_timer.id return else if(flags & TIMER_OVERRIDE) - stack_trace("TIMER_OVERRIDE used without TIMER_UNIQUE") + stack_trace("TIMER_OVERRIDE used without TIMER_UNIQUE") //this is also caught by grep. var/datum/timedevent/timer = new(callback, wait, flags, timer_subsystem, hash, file && "[file]:[line]") return timer.id diff --git a/tools/ci/check_grep.sh b/tools/ci/check_grep.sh index 31140fa33b5..548e44ad7f5 100644 --- a/tools/ci/check_grep.sh +++ b/tools/ci/check_grep.sh @@ -244,6 +244,11 @@ done < <(find . -type f -name '*.dm') echo -e "${BLUE}Checking for common mistakes...${NC}" +if grep -P 'addtimer\((?=.*TIMER_OVERRIDE)(?!.*TIMER_UNIQUE).*\)' code/**/*.dm; then + echo + echo -e "${RED}ERROR: TIMER_OVERRIDE used without TIMER_UNIQUE.${NC}" + st=1 +fi; if grep -P '^/*var/' code/**/*.dm; then echo echo -e "${RED}ERROR: Unmanaged global var use detected in code, please use the helpers.${NC}"