Adds lint for assigning variables to themselves (#20744)

* Fixes some funny bugs, adds a lint to check for future

* Proven that the grep works, pushing this fix
This commit is contained in:
adamsong
2023-10-26 21:25:37 -04:00
committed by GitHub
parent bec4acab3e
commit 58f40a32f5
8 changed files with 12 additions and 10 deletions

View File

@@ -555,7 +555,6 @@
for(var/datum/antagonist/A in antag_datums) for(var/datum/antagonist/A in antag_datums)
objective = locate(href_list["obj_completed"]) in A.objectives objective = locate(href_list["obj_completed"]) in A.objectives
if(istype(objective)) if(istype(objective))
objective = objective
break break
if(!objective) if(!objective)
to_chat(usr,"Invalid objective.") to_chat(usr,"Invalid objective.")

View File

@@ -187,8 +187,6 @@
else if(limb.body_zone in list(BODY_ZONE_L_ARM, BODY_ZONE_R_ARM)) else if(limb.body_zone in list(BODY_ZONE_L_ARM, BODY_ZONE_R_ARM))
if(limb.current_gauze) if(limb.current_gauze)
interaction_efficiency_penalty = 1 + ((interaction_efficiency_penalty - 1) * limb.current_gauze.splint_factor) interaction_efficiency_penalty = 1 + ((interaction_efficiency_penalty - 1) * limb.current_gauze.splint_factor)
else
interaction_efficiency_penalty = interaction_efficiency_penalty
if(initial(disabling)) if(initial(disabling))
set_disabling(!limb.current_gauze) set_disabling(!limb.current_gauze)

View File

@@ -204,7 +204,7 @@ GLOBAL_LIST_EMPTY(objectives)
/datum/objective/proc/copy_target(datum/objective/old_obj) /datum/objective/proc/copy_target(datum/objective/old_obj)
target = old_obj.get_target() target = old_obj.get_target()
target_amount = old_obj.target_amount target_amount = old_obj.target_amount
explanation_text = explanation_text explanation_text = old_obj.explanation_text
/datum/objective/assassinate /datum/objective/assassinate
name = "assassinate" name = "assassinate"

View File

@@ -175,7 +175,7 @@ GLOBAL_LIST_INIT(freqtospan, list(
INITIALIZE_IMMEDIATE(/atom/movable/virtualspeaker) INITIALIZE_IMMEDIATE(/atom/movable/virtualspeaker)
/atom/movable/virtualspeaker/Initialize(mapload, atom/movable/M, radio) /atom/movable/virtualspeaker/Initialize(mapload, atom/movable/M, radio)
. = ..() . = ..()
radio = radio src.radio = radio
source = M source = M
if (istype(M)) if (istype(M))
name = M.GetVoice() name = M.GetVoice()

View File

@@ -310,7 +310,6 @@
if(!new_severity) if(!new_severity)
qdel(query_find_edit_note_severity) qdel(query_find_edit_note_severity)
return return
new_severity = new_severity
var/edit_text = "Note severity edited by [editor_key] on [SQLtime()] from [old_severity] to [new_severity]<hr>" var/edit_text = "Note severity edited by [editor_key] on [SQLtime()] from [old_severity] to [new_severity]<hr>"
var/datum/DBQuery/query_edit_note_severity = SSdbcore.NewQuery({" var/datum/DBQuery/query_edit_note_severity = SSdbcore.NewQuery({"
UPDATE [format_table_name("messages")] UPDATE [format_table_name("messages")]

View File

@@ -477,9 +477,11 @@
// And these 3 lines prevent it from happening while being quiet. // And these 3 lines prevent it from happening while being quiet.
// So.. it works. // So.. it works.
// Don't touch it. // Don't touch it.
var/whatthefuck = i // Looks like the bug got fixed, it works commented out now
whatthefuck = src.type // If it breaks again, try uncommenting
whatthefuck = whatthefuck // var/whatthefuck = i
// whatthefuck = src.type
// whatthefuck = whatthefuck
while(token(i) && token(i) != "]") while(token(i) && token(i) != "]")

View File

@@ -154,7 +154,7 @@
var/obj/effect/dummy/phased_mob/holder = new /obj/effect/dummy/phased_mob(loc) var/obj/effect/dummy/phased_mob/holder = new /obj/effect/dummy/phased_mob(loc)
extinguish_mob() extinguish_mob()
forceMove(holder) forceMove(holder)
holder = holder src.holder = holder
notransform = FALSE notransform = FALSE
fakefireextinguish() fakefireextinguish()

View File

@@ -63,6 +63,10 @@ if grep -P '^/(obj|mob|turf|area|atom)/.+/Initialize\((?!mapload).*\)' code/**/*
echo "ERROR: Initialize override without 'mapload' argument." echo "ERROR: Initialize override without 'mapload' argument."
st=1 st=1
fi; fi;
if grep -P '^\s*(\w+)\s*=\s*(\1)\b\s*$' code/**/*.dm; then
echo "ERROR: Variable is assigned to itself"
st=1
fi;
for json in _maps/*.json for json in _maps/*.json
do do
filename="_maps/$(jq -r '.map_path' $json)/$(jq -r '.map_file' $json)" filename="_maps/$(jq -r '.map_path' $json)/$(jq -r '.map_file' $json)"