Lints Against Unmanaged Local Defines (#74333)

# MAINTAINER - USE THE BUTTON THAT SAYS "MERGE MASTER" THEN SET THE PR
TO AUTO-MERGE! IT'S MUCH EASIER FOR ME TO FIX THINGS BEFORE THEY SKEW
RATHER THAN AFTER THE FACT.

## About The Pull Request

Hey there,

This took a while to do, but here's the gist:

Python file now regexes every file in `/code` except for those that have
some valid reason to be tacking on more global defines. Some of those
reasons are simply just that I don't have the time right now (doing what
you see in this PR took a few hours) to refactor and parse what should
belong and what should be thrown out. For the time being though, this PR
will at least _halt_ people making the mistake of not `#undef`ing any
files they `#define` "locally", or within the scope of a file.

Most people forget to do this and this leads to a lot of mess later on
due to how many variables can be unmanaged on the global level. I've
made this mistake, you've made this mistake, it's a common thing. Let's
automatically check for it so it can be fixed no-stress.

Scenarios this PR corrects:

* Forgetting to undef a define but undeffing others.
* Not undeffing any defines in your file.
* Earmarking a define as a "file local" define, but not defining it.
* Having a define be a "file local" define, but having it be used
elsewhere.
* Having a "local" define not even be in the file that it only shows up
in.
* Having a completely unused define*

(* I kept some of these because they seemed important... Others were
junked.)
## Why It's Good For The Game

If you wanna use it across multiple files, no reason to not make it a
global define (maybe there's a few reasons but let's assume that this is
the 95% case).

Let me know if you don't like how I re-arranged some of the defines and
how you'd rather see it be implemented, and I'd be happy to do that.
This was mostly just "eh does it need it or not" sorta stuff.

I used a pretty cool way to detect if we should use the standardized
GitHub "error" output, you can see the results of that here
https://github.com/san7890/bruhstation/actions/runs/4549766579/jobs/8022186846#step:7:792
## Changelog
Nothing that really concerns players.

(I fixed up all this stuff using vscode, no regexes beyond what you see
in the python script. sorry downstreams)
This commit is contained in:
san7890
2023-03-29 10:17:03 -07:00
committed by GitHub
parent 36396bb4c2
commit ccef887efe
242 changed files with 1034 additions and 319 deletions
+5
View File
@@ -280,3 +280,8 @@
/obj/machinery/power/floodlight/play_attack_sound(damage_amount, damage_type = BRUTE, damage_flag = 0)
playsound(src, 'sound/effects/glasshit.ogg', 75, TRUE)
#undef FLOODLIGHT_OFF
#undef FLOODLIGHT_LOW
#undef FLOODLIGHT_MED
#undef FLOODLIGHT_HIGH
+2
View File
@@ -228,3 +228,5 @@
if(cold_circ)
cold_circ.generator = null
cold_circ = null
#undef GENRATE
+9
View File
@@ -472,3 +472,12 @@ GLOBAL_LIST_EMPTY(gravity_generators)
<li>Mend the damaged framework with a welding tool.</li>
<li>Add additional plasteel plating.</li>
<li>Secure the additional plating with a wrench.</li></ol>"}
#undef POWER_IDLE
#undef POWER_UP
#undef POWER_DOWN
#undef GRAV_NEEDS_PLASTEEL
#undef GRAV_NEEDS_SCREWDRIVER
#undef GRAV_NEEDS_WELDING
#undef GRAV_NEEDS_WRENCH
@@ -15,6 +15,8 @@ GLOBAL_LIST_INIT(sm_delam_list, list(
/datum/sm_delam/proc/can_select(obj/machinery/power/supermatter_crystal/sm)
return FALSE
#define ROUNDCOUNT_ENGINE_JUST_EXPLODED 0
/// Called when the count down has been finished, do the nasty work.
/// [/obj/machinery/power/supermatter_crystal/proc/count_down]
/datum/sm_delam/proc/delaminate(obj/machinery/power/supermatter_crystal/sm)
@@ -24,6 +26,8 @@ GLOBAL_LIST_INIT(sm_delam_list, list(
sign.update_count(ROUNDCOUNT_ENGINE_JUST_EXPLODED)
qdel(sm)
#undef ROUNDCOUNT_ENGINE_JUST_EXPLODED
/// Whatever we're supposed to do when a delam is currently in progress.
/// Mostly just to tell people how useless engi is, and play some alarm sounds.
/// Returns TRUE if we just told people a delam is going on. FALSE if its healing or we didnt say anything.
+3
View File
@@ -365,3 +365,6 @@
#undef MACHINERY
#undef BLOB
#undef STRUCTURE
#undef TESLA_DEFAULT_POWER
#undef TESLA_MINI_POWER