OpenDreamProject / OpenDream

A project for running games made in the DM programming language
MIT License
187 stars 102 forks source link

Lint for pointless/bad positional arguments. #1768

Open moonheart08 opened 2 months ago

moonheart08 commented 2 months ago

In cases like https://github.com/Citadel-Station-13/Citadel-Station-13-RP/blob/69ce25bd79b41b7800e33c45ccb9a094a280c5ff/code/modules/gamemaster/actions/atmos_leak.dm#L20-L23

...
severity = pickweight(EVENT_LEVEL_MUNDANE = 8,
EVENT_LEVEL_MODERATE = 5,
EVENT_LEVEL_MAJOR = 3
)
...
// Event defines.
#define EVENT_LEVEL_MUNDANE        1
#define EVENT_LEVEL_MODERATE    2
#define EVENT_LEVEL_MAJOR        3
...

After preprocessing, this is

// This runtimes if the argument order is different.
severity = pickweight(1 = 8,
2 = 5,
3 = 3
)

which is equivalent to

severity = pickweight(8, 5, 3)

this is almost certainly unintentional, undoubtably does not do what the programmer intended (a BYOND classic frankly), and should probably be linted for.

ike709 commented 2 months ago

Added context I haven't verified for myself: image