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 11:17:03 -06:00
committed by GitHub
parent 36396bb4c2
commit ccef887efe
242 changed files with 1034 additions and 319 deletions
@@ -1,10 +1,3 @@
#define VALUE_MODE_NUM 0
#define VALUE_MODE_TEXT 1
#define VALUE_MODE_FLAG 2
#define KEY_MODE_TEXT 0
#define KEY_MODE_TYPE 1
/datum/config_entry
/// Read-only, this is determined by the last portion of the derived entry type
var/name
@@ -53,3 +53,5 @@ SUBSYSTEM_DEF(area_contents)
clear.turfs_to_uncontain = list()
marked_for_clearing.len--
#undef ALLOWED_LOOSE_TURFS
-13
View File
@@ -1,8 +1,3 @@
#define BAD_INIT_QDEL_BEFORE 1
#define BAD_INIT_DIDNT_INIT 2
#define BAD_INIT_SLEPT 4
#define BAD_INIT_NO_HINT 8
SUBSYSTEM_DEF(atoms)
name = "Atoms"
init_order = INIT_ORDER_ATOMS
@@ -40,14 +35,6 @@ SUBSYSTEM_DEF(atoms)
return SS_INIT_SUCCESS
#ifdef PROFILE_MAPLOAD_INIT_ATOM
#define PROFILE_INIT_ATOM_BEGIN(...) var/__profile_stat_time = TICK_USAGE
#define PROFILE_INIT_ATOM_END(atom) mapload_init_times[##atom.type] += TICK_USAGE_TO_MS(__profile_stat_time)
#else
#define PROFILE_INIT_ATOM_BEGIN(...)
#define PROFILE_INIT_ATOM_END(...)
#endif
/datum/controller/subsystem/atoms/proc/InitializeAtoms(list/atoms, list/atoms_to_return)
if(initialized == INITIALIZATION_INSSATOMS)
return
@@ -90,3 +90,4 @@ SUBSYSTEM_DEF(communications)
#undef COMMUNICATION_COOLDOWN
#undef COMMUNICATION_COOLDOWN_AI
#undef COMMUNICATION_COOLDOWN_MEETING
+4
View File
@@ -227,3 +227,7 @@ SUBSYSTEM_DEF(economy)
"cost" = price_to_use,
"vendor" = vendor,
))
#undef ECON_DEPARTMENT_STEP
#undef ECON_ACCOUNT_STEP
#undef ECON_PRICE_UPDATE_STEP
+2 -4
View File
@@ -67,10 +67,6 @@ SUBSYSTEM_DEF(explosions)
msg += "} "
return ..()
#define SSEX_TURF "turf"
#define SSEX_OBJ "obj"
/datum/controller/subsystem/explosions/proc/is_exploding()
return (lowturf.len || medturf.len || highturf.len || flameturf.len || throwturf.len || low_mov_atom.len || med_mov_atom.len || high_mov_atom.len)
@@ -716,3 +712,5 @@ SUBSYSTEM_DEF(explosions)
cost_throwturf = MC_AVERAGE(cost_throwturf, TICK_DELTA_TO_MS(TICK_USAGE_REAL - timer))
currentpart = SSEXPLOSIONS_TURFS
#undef EXPLOSION_THROW_SPEED
@@ -24,3 +24,5 @@ SUBSYSTEM_DEF(init_profiler)
fdel(prof_file)
WRITE_FILE(prof_file, current_profile_data)
world.Profile(PROFILE_CLEAR) //Now that we're written this data out, dump it. We don't want it getting mixed up with our current round data
#undef INIT_PROFILE_NAME
+4 -3
View File
@@ -1,7 +1,6 @@
#define FILE_RECENT_MAPS "data/RecentMaps.json"
#define KEEP_ROUNDS_MAP 3
#define ROUNDCOUNT_ENGINE_JUST_EXPLODED 0
SUBSYSTEM_DEF(persistence)
name = "Persistence"
@@ -162,7 +161,7 @@ SUBSYSTEM_DEF(persistence)
log_world("Loaded [prison_tattoos_to_use.len] prison tattoos")
///Saves all tattoos, so they can appear on prisoners in future rounds
///Saves all tattoos, so they can appear on prisoners in future rounds
/datum/controller/subsystem/persistence/proc/save_prisoner_tattoos()
var/json_file = file(PRISONER_TATTOO_SAVE_FILE)
var/list/saved_data = list()
@@ -295,7 +294,7 @@ SUBSYSTEM_DEF(persistence)
for(var/obj/structure/displaycase/trophy/trophy_case in GLOB.trophy_cases)
if(!valid_trophies.len)
break
if(trophy_case.showpiece)
continue
@@ -546,3 +545,5 @@ SUBSYSTEM_DEF(persistence)
rustg_file_write("[rounds_since_engine_exploded + 1]", DELAMINATION_COUNT_FILEPATH)
#undef DELAMINATION_COUNT_FILEPATH
#undef FILE_RECENT_MAPS
#undef KEEP_ROUNDS_MAP
@@ -305,6 +305,7 @@ SUBSYSTEM_DEF(persistent_paintings)
fdel(json_file)
WRITE_FILE(json_file, payload)
#undef PAINTINGS_DATA_FORMAT_VERSION
#undef PATRONAGE_OK_FRAME
#undef PATRONAGE_NICE_FRAME
#undef PATRONAGE_GREAT_FRAME
@@ -202,5 +202,6 @@ PROCESSING_SUBSYSTEM_DEF(quirks)
return new_quirks
#undef EXP_ASSIGN_WAYFINDER
#undef RANDOM_QUIRK_BONUS
#undef MINIMUM_RANDOM_QUIRKS
+3
View File
@@ -64,3 +64,6 @@ SUBSYSTEM_DEF(profiler)
WRITE_FILE(prof_file, current_profile_data)
WRITE_FILE(sendmaps_file, current_sendmaps_data)
write_cost = MC_AVERAGE(write_cost, TICK_DELTA_TO_MS(TICK_USAGE_REAL - timer))
#undef PROFILER_FILENAME
#undef SENDMAPS_FILENAME
+4
View File
@@ -1096,3 +1096,7 @@ SUBSYSTEM_DEF(shuttle)
has_purchase_shuttle_access |= shuttle_template.who_can_purchase
return has_purchase_shuttle_access
#undef MAX_TRANSIT_REQUEST_RETRIES
#undef MAX_TRANSIT_TILE_COUNT
#undef SOFT_TRANSIT_RESERVATION_THRESHOLD
@@ -756,6 +756,9 @@ SUBSYSTEM_DEF(spatial_grid)
the average client distance is: [average_client_distance], the average hearable_distance is [average_hearable_distance], \
and the average atmos distance is [average_atmos_distance] ")
#undef BOUNDING_BOX_MAX
#undef BOUNDING_BOX_MIN
#undef GRID_CELL_ADD
#undef GRID_CELL_REMOVE
#undef GRID_CELL_SET
#undef NUMBER_OF_PREGENERATED_ORANGES_EARS
+3
View File
@@ -227,3 +227,6 @@ SUBSYSTEM_DEF(throwing)
SEND_SIGNAL(thrownthing, COMSIG_MOVABLE_THROW_LANDED, src)
qdel(src)
#undef MAX_THROWING_DIST
#undef MAX_TICKS_TO_MAKE_UP
+2
View File
@@ -732,3 +732,5 @@ SUBSYSTEM_DEF(ticker)
possible_themes += themes
if(possible_themes.len)
return "[global.config.directory]/reboot_themes/[pick(possible_themes)]"
#undef ROUND_START_MUSIC_LIST
+1 -6
View File
@@ -1,9 +1,4 @@
#define STARTUP_STAGE 1
#define MAIN_STAGE 2
#define WIND_DOWN_STAGE 3
#define END_STAGE 4
//Used for all kinds of weather, ex. lavaland ash storms.
/// Used for all kinds of weather, ex. lavaland ash storms.
SUBSYSTEM_DEF(weather)
name = "Weather"
flags = SS_BACKGROUND