From 2757cefab8a9b93150ec94f0153ec14358c1bb27 Mon Sep 17 00:00:00 2001
From: Kashargul <144968721+Kashargul@users.noreply.github.com>
Date: Fri, 14 Mar 2025 14:16:40 +0100
Subject: [PATCH] first few resolved greps (#17343)
* first few resolved greps
* .
---
code/__byond_version_compat.dm | 26 +-----
code/_onclick/hud/action/action.dm | 2 +-
code/controllers/subsystems/vote.dm | 2 +-
code/datums/callback.dm | 10 +--
code/modules/client/client procs.dm | 2 +-
.../mob/living/simple_mob/simple_mob.dm | 2 +-
.../simple_mob/subtypes/animal/space/worm.dm | 2 +-
.../simple_mob/subtypes/mechanical/golem.dm | 2 +-
code/modules/tgchat/_legacy.dm | 2 +-
code/modules/xenobio/items/slimepotions.dm | 6 +-
tools/ci/validate_files.sh | 82 +++++++++++++------
11 files changed, 71 insertions(+), 67 deletions(-)
diff --git a/code/__byond_version_compat.dm b/code/__byond_version_compat.dm
index 7bcdcaff89e..2957b00f30a 100644
--- a/code/__byond_version_compat.dm
+++ b/code/__byond_version_compat.dm
@@ -20,33 +20,11 @@
/savefile/byond_version = MIN_COMPILER_VERSION
#endif
-// 515 split call for external libraries into call_ext
-#if DM_VERSION < 515
-#define LIBCALL call
-#else
+// lib call for external libraries into call_ext
#define LIBCALL call_ext
-#endif
-// So we want to have compile time guarantees these methods exist on local type, unfortunately 515 killed the .proc/procname and .verb/verbname syntax so we have to use nameof()
// For the record: GLOBAL_VERB_REF would be useless as verbs can't be global.
-#if DM_VERSION < 515
-
-/// Call by name proc references, checks if the proc exists on either this type or as a global proc.
-#define PROC_REF(X) (.proc/##X)
-/// Call by name verb references, checks if the verb exists on either this type or as a global verb.
-#define VERB_REF(X) (.verb/##X)
-
-/// Call by name proc reference, checks if the proc exists on either the given type or as a global proc
-#define TYPE_PROC_REF(TYPE, X) (##TYPE.proc/##X)
-/// Call by name verb reference, checks if the verb exists on either the given type or as a global verb
-#define TYPE_VERB_REF(TYPE, X) (##TYPE.verb/##X)
-
-/// Call by name proc reference, checks if the proc is an existing global proc
-#define GLOBAL_PROC_REF(X) (/proc/##X)
-
-#else
-
/// Call by name proc references, checks if the proc exists on either this type or as a global proc.
#define PROC_REF(X) (nameof(.proc/##X))
/// Call by name verb references, checks if the verb exists on either this type or as a global verb.
@@ -59,5 +37,3 @@
/// Call by name proc reference, checks if the proc is an existing global proc
#define GLOBAL_PROC_REF(X) (/proc/##X)
-
-#endif
diff --git a/code/_onclick/hud/action/action.dm b/code/_onclick/hud/action/action.dm
index a5a512be689..77975659e4b 100644
--- a/code/_onclick/hud/action/action.dm
+++ b/code/_onclick/hud/action/action.dm
@@ -58,7 +58,7 @@
RegisterSignal(target, COMSIG_ATOM_UPDATED_ICON, PROC_REF(on_target_icon_update))
// if(istype(target, /datum/mind))
- // RegisterSignal(target, COMSIG_MIND_TRANSFERRED, .proc/on_target_mind_swapped)
+ // RegisterSignal(target, COMSIG_MIND_TRANSFERRED, PROC_REF(on_target_mind_swapped))
/datum/action/Destroy()
if(owner)
diff --git a/code/controllers/subsystems/vote.dm b/code/controllers/subsystems/vote.dm
index 112a2322c2b..aa762f190b8 100644
--- a/code/controllers/subsystems/vote.dm
+++ b/code/controllers/subsystems/vote.dm
@@ -271,7 +271,7 @@ SUBSYSTEM_DEF(vote)
return
var/admin = FALSE
if(C.holder)
- if(C.holder.rights & R_ADMIN|R_EVENT)
+ if(C.holder.rights & (R_ADMIN|R_EVENT))
admin = TRUE
. = "
Voting Panel"
diff --git a/code/datums/callback.dm b/code/datums/callback.dm
index 8a904b8b44b..68b53ca4151 100644
--- a/code/datums/callback.dm
+++ b/code/datums/callback.dm
@@ -22,20 +22,20 @@
global proc while in another global proc:
.procname
Example:
- CALLBACK(GLOBAL_PROC, .some_proc_here)
+ CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(some_proc_here))
proc defined on current(src) object (when in a /proc/ and not an override) OR overridden at src or any of it's parents:
.procname
Example:
- CALLBACK(src, .some_proc_here)
+ CALLBACK(src, PROC_REF(some_proc_here))
when the above doesn't apply:
- .proc/procname
+ PROC_REF(procname)
Example:
- CALLBACK(src, .proc/some_proc_here)
+ CALLBACK(src,
proc defined on a parent of a some type:
- Example: /some/type/.proc/some_proc_here
+ Example: TYPE_PROC_REF(/some/type, some_proc_here))
Other wise you will have to do the full typepath of the proc (/type/of/thing/proc/procname)
*/
diff --git a/code/modules/client/client procs.dm b/code/modules/client/client procs.dm
index 6468e6a4098..d51d19a160f 100644
--- a/code/modules/client/client procs.dm
+++ b/code/modules/client/client procs.dm
@@ -249,7 +249,7 @@
// Instantiate stat panel
stat_panel = new(src, "statbrowser")
- stat_panel.subscribe(src, .proc/on_stat_panel_message)
+ stat_panel.subscribe(src, PROC_REF(on_stat_panel_message))
// Instantiate tgui panel
tgui_say = new(src, "tgui_say")
diff --git a/code/modules/mob/living/simple_mob/simple_mob.dm b/code/modules/mob/living/simple_mob/simple_mob.dm
index 541f4bd579f..1fa6813ea19 100644
--- a/code/modules/mob/living/simple_mob/simple_mob.dm
+++ b/code/modules/mob/living/simple_mob/simple_mob.dm
@@ -318,7 +318,7 @@
return verb
/mob/living/simple_mob/is_sentient()
- return mob_class & MOB_CLASS_HUMANOID|MOB_CLASS_ANIMAL|MOB_CLASS_SLIME // Update this if needed.
+ return mob_class & (MOB_CLASS_HUMANOID|MOB_CLASS_ANIMAL|MOB_CLASS_SLIME) // Update this if needed.
/mob/living/simple_mob/get_nametag_desc(mob/user)
return span_italics("[tt_desc]")
diff --git a/code/modules/mob/living/simple_mob/subtypes/animal/space/worm.dm b/code/modules/mob/living/simple_mob/subtypes/animal/space/worm.dm
index de458f864a2..955d4504ed1 100644
--- a/code/modules/mob/living/simple_mob/subtypes/animal/space/worm.dm
+++ b/code/modules/mob/living/simple_mob/subtypes/animal/space/worm.dm
@@ -266,7 +266,7 @@
objectOrMob = null
break
- if(D && (D.stat & BROKEN|NOPOWER))
+ if(D && (D.stat & (BROKEN|NOPOWER)))
D.open(TRUE)
break
diff --git a/code/modules/mob/living/simple_mob/subtypes/mechanical/golem.dm b/code/modules/mob/living/simple_mob/subtypes/mechanical/golem.dm
index 9288734be4f..2164ad9bc48 100644
--- a/code/modules/mob/living/simple_mob/subtypes/mechanical/golem.dm
+++ b/code/modules/mob/living/simple_mob/subtypes/mechanical/golem.dm
@@ -115,7 +115,7 @@
return ..()
/mob/living/simple_mob/mechanical/technomancer_golem/melee_pre_animation(atom/A)
- if(active_spell && active_spell.cast_methods & CAST_MELEE|CAST_RANGED) // If they're trying to melee-cast a spell, use the special animation instead.
+ if(active_spell && active_spell.cast_methods & (CAST_MELEE|CAST_RANGED)) // If they're trying to melee-cast a spell, use the special animation instead.
special_pre_animation(A)
return
diff --git a/code/modules/tgchat/_legacy.dm b/code/modules/tgchat/_legacy.dm
index 2afc8ba4c8c..adfef863956 100644
--- a/code/modules/tgchat/_legacy.dm
+++ b/code/modules/tgchat/_legacy.dm
@@ -38,7 +38,7 @@ GLOBAL_LIST_EMPTY(bicon_cache) // Cache of the
tag results, not the icons
base64 = icon2base64(A.examine_icon(), key)
GLOB.bicon_cache[key] = base64
if(changes_often)
- addtimer(CALLBACK(GLOBAL_PROC, .proc/expire_bicon_cache, key), 50 SECONDS, TIMER_UNIQUE)
+ addtimer(CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(expire_bicon_cache), key), 50 SECONDS, TIMER_UNIQUE)
// May add a class to the img tag created by bicon
if(use_class)
diff --git a/code/modules/xenobio/items/slimepotions.dm b/code/modules/xenobio/items/slimepotions.dm
index d0af937114c..61fc102d40f 100644
--- a/code/modules/xenobio/items/slimepotions.dm
+++ b/code/modules/xenobio/items/slimepotions.dm
@@ -102,7 +102,7 @@
// Simple Mobs.
else if(isanimal(M))
var/mob/living/simple_mob/SM = M
- if(!(SM.mob_class & MOB_CLASS_SLIME|MOB_CLASS_ANIMAL)) // So you can't use this on Russians/syndies/hivebots/etc.
+ if(!(SM.mob_class & (MOB_CLASS_SLIME|MOB_CLASS_ANIMAL))) // So you can't use this on Russians/syndies/hivebots/etc.
to_chat(user, span_warning("\The [SM] only works on slimes and animals."))
return ..()
if(!AI.hostile)
@@ -189,7 +189,7 @@
if(!istype(M))
to_chat(user, span_warning("The agent only works on creatures!"))
return ..()
- if(!(M.mob_class & MOB_CLASS_SLIME|MOB_CLASS_ANIMAL)) // So you can't use this on Russians/syndies/hivebots/etc.
+ if(!(M.mob_class & (MOB_CLASS_SLIME|MOB_CLASS_ANIMAL))) // So you can't use this on Russians/syndies/hivebots/etc.
to_chat(user, span_warning("\The [M] only works on slimes and animals."))
return ..()
if(M.stat == DEAD)
@@ -224,7 +224,7 @@
if(!istype(M))
to_chat(user, span_warning("The agent only works on creatures!"))
return ..()
- if(!(M.mob_class & MOB_CLASS_SLIME|MOB_CLASS_ANIMAL)) // So you can't use this on Russians/syndies/hivebots/etc.
+ if(!(M.mob_class & (MOB_CLASS_SLIME|MOB_CLASS_ANIMAL))) // So you can't use this on Russians/syndies/hivebots/etc.
to_chat(user, span_warning("\The [M] only works on slimes and animals."))
return ..()
if(M.stat == DEAD)
diff --git a/tools/ci/validate_files.sh b/tools/ci/validate_files.sh
index 503985cd49e..ff14b828dee 100755
--- a/tools/ci/validate_files.sh
+++ b/tools/ci/validate_files.sh
@@ -24,14 +24,14 @@ if command -v rg >/dev/null 2>&1; then
code_files="code/**/**.dm"
map_files="maps/**/**.dmm"
# shuttle_map_files="_maps/shuttles/**.dmm"
- # code_x_515="code/**/!(__byond_version_compat).dm"
+ code_x_515="code/**/!(__byond_version_compat).dm"
else
pcre2_support=0
grep=grep
code_files="-r --include=code/**/**.dm"
map_files="-r --include=maps/**/**.dmm"
# shuttle_map_files="-r --include=_maps/shuttles/**.dmm"
- # code_x_515="-r --include=code/**/!(__byond_version_compat).dm"
+ code_x_515="-r --include=code/**/!(__byond_version_compat).dm"
fi
echo -e "${BLUE}Using grep provider at $(which $grep)${NC}"
@@ -55,17 +55,24 @@ part "step_[xy]"
(! $grep 'step_[xy]' $map_files)
retVal=$?
if [ $retVal -ne 0 ]; then
- echo -e "${RED}The variables 'step_x' and 'step_y' are present on a map, and they 'break' movement ingame.${NC}"
- FAILED=1
+ echo -e "${RED}The variables 'step_x' and 'step_y' are present on a map, and they 'break' movement ingame.${NC}"
+ FAILED=1
fi
+part "base /turf usage"
+if grep -P '\W\/turf\s*[,\){]' $map_files; then
+ echo
+ echo -e "${RED}ERROR: base /turf path use detected in maps, please replace with proper paths.${NC}"
+ FAILED=1
+fi;
+
part "test map included"
#Checking for any 'checked' maps that include 'test'
(! $grep 'maps\\.*test.*' *.dme)
retVal=$?
if [ $retVal -ne 0 ]; then
- echo -e "${RED}A map containing the word 'test' is included. This is not allowed to be committed.${NC}"
- FAILED=1
+ echo -e "${RED}A map containing the word 'test' is included. This is not allowed to be committed.${NC}"
+ FAILED=1
fi
section "code issues"
@@ -76,8 +83,8 @@ echo -e "${RED}DISABLED"
# awk -f tools/indentation.awk $code_files
# retVal=$?
# if [ $retVal -ne 0 ]; then
-# echo -e "${RED}Indention testing failed. Please see results and fix indentation.${NC}"
-# FAILED=1
+# echo -e "${RED}Indention testing failed. Please see results and fix indentation.${NC}"
+# FAILED=1
# fi
part "improperly pathed static lists"
@@ -92,8 +99,8 @@ part "changelog"
md5sum -c - <<< "0c56937110d88f750a32d9075ddaab8b *html/changelogs/example.yml"
retVal=$?
if [ $retVal -ne 0 ]; then
- echo -e "${RED}Do not modify the example.yml changelog file.${NC}"
- FAILED=1
+ echo -e "${RED}Do not modify the example.yml changelog file.${NC}"
+ FAILED=1
fi
part "color macros"
@@ -101,28 +108,49 @@ part "color macros"
(num=`$grep -n '\\\\(red|blue|green|black|b|i[^mnc])' $code_files | wc -l`; echo "$num escapes (expecting ${MACRO_COUNT} or less)"; [ $num -le ${MACRO_COUNT} ])
retVal=$?
if [ $retVal -ne 0 ]; then
- echo -e "${RED}Do not use any byond color macros (such as \blue), they are deprecated.${NC}"
- FAILED=1
+ echo -e "${RED}Do not use any byond color macros (such as \blue), they are deprecated.${NC}"
+ FAILED=1
fi
+part "typescript react files"
+if ls -1 tgui/**/*.jsx 2>/dev/null; then
+ echo
+ echo -e "${RED}ERROR: JSX file(s) detected, these must be converted to typescript (TSX).${NC}"
+ FAILED=1
+fi;
+
part "balloon_alert sanity"
if $grep 'balloon_alert\(".*"\)' $code_files; then
- echo
- echo -e "${RED}ERROR: Found a balloon alert with improper arguments.${NC}"
- FAILED=1
+ echo
+ echo -e "${RED}ERROR: Found a balloon alert with improper arguments.${NC}"
+ FAILED=1
fi;
if $grep 'balloon_alert(.*span_)' $code_files; then
- echo
- echo -e "${RED}ERROR: Balloon alerts should never contain spans.${NC}"
- FAILED=1
+ echo
+ echo -e "${RED}ERROR: Balloon alerts should never contain spans.${NC}"
+ FAILED=1
fi;
part "balloon_alert idiomatic usage"
if $grep 'balloon_alert\(.*?, ?"[A-Z]' $code_files; then
- echo
- echo -e "${RED}ERROR: Balloon alerts should not start with capital letters. This includes text like 'AI'. If this is a false positive, wrap the text in UNLINT().${NC}"
- FAILED=1
+ echo
+ echo -e "${RED}ERROR: Balloon alerts should not start with capital letters. This includes text like 'AI'. If this is a false positive, wrap the text in UNLINT().${NC}"
+ FAILED=1
+fi;
+
+part ".proc ref syntax"
+if $grep '\.proc/' $code_x_515 ; then
+ echo
+ echo -e "${RED}ERROR: Outdated proc reference use detected in code, please use proc reference helpers.${NC}"
+ FAILED=1
+fi;
+
+part "ambiguous bitwise or"
+if grep -P '^(?:[^\/\n]|\/[^\/\n])*(&[ \t]*\w+[ \t]*\|[ \t]*\w+)' $code_files; then
+ echo
+ echo -e "${RED}ERROR: Likely operator order mistake with bitwise OR. Use parentheses to specify intention.${NC}"
+ FAILED=1
fi;
part "html tag matching"
@@ -130,8 +158,8 @@ part "html tag matching"
python tools/TagMatcher/tag-matcher.py ../..
retVal=$?
if [ $retVal -ne 0 ]; then
- echo -e "${RED}Some HTML tags are missing their opening/closing partners. Please correct this.${NC}"
- FAILED=1
+ echo -e "${RED}Some HTML tags are missing their opening/closing partners. Please correct this.${NC}"
+ FAILED=1
fi
if [ "$pcre2_support" -eq 1 ]; then
@@ -204,11 +232,11 @@ else
fi
if [ $FAILED = 0 ]; then
- echo
- echo -e "${GREEN}No errors found using $grep!${NC}"
+ echo
+ echo -e "${GREEN}No errors found using $grep!${NC}"
else
- echo
- echo -e "${RED}Errors found, please fix them and try again.${NC}"
+ echo
+ echo -e "${RED}Errors found, please fix them and try again.${NC}"
fi
# Quit with our status code