Skip to content

Commit

Permalink
od linter (#4645)
Browse files Browse the repository at this point in the history
uses opendream's compiler for a bit of extended linting, i guess we'll
see how many extra errors this'll pick up

heavy lifting down by aa07 on
ParadiseSS13/Paradise#21099 so far as wrestling
OD into CI and the #include tricks

---------

Co-authored-by: Zonespace <[email protected]>
  • Loading branch information
harryob and Zonespace27 committed Oct 21, 2023
1 parent ca47702 commit 23e0d1d
Show file tree
Hide file tree
Showing 52 changed files with 161 additions and 199 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/ci_suite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,34 @@ jobs:
with:
outputFile: output-annotations.txt


odlint:
name: Lint with OpenDream
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: Get OpenDream Version
run: |
source dependencies.sh
echo "OPENDREAM_VERSION=$OPENDREAM_VERSION" >> $GITHUB_ENV
- name: Restore OpenDream cache
uses: actions/cache@v3
id: cache-od
with:
path: ~/OpenDream
key: ${{ runner.os }}-opendream-${{ env.OPENDREAM_VERSION }}
- name: Download OpenDream
if: steps.cache-od.outputs.cache-hit != 'true'
run: |
bash tools/ci/download_od.sh
- name: Setup OpenDream
if: steps.cache-od.outputs.cache-hit != 'true'
run: |
bash tools/ci/setup_od.sh
- name: Run OpenDream
run: |
bash tools/ci/run_od.sh
compile_all_maps:
if: "!contains(github.event.head_commit.message, '[ci skip]')"
name: Compile Maps
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,6 @@ test_environment.txt
# byond-tracy backend, not shipped with the codebase so it shouldn't be maintained
prof.dll
libprof.so

# OpenDream compatibility stuff
colonialmarines.json
2 changes: 1 addition & 1 deletion code/__DEFINES/bullet_traits.dm
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// list of args if there are any args
/// An entry to a list for giving projectiles bullet traits
/// Must be placed inside of a list
#define BULLET_TRAIT_ENTRY(trait, args...) trait = #args ? list(##args) : null
#define BULLET_TRAIT_ENTRY(trait, args...) trait = list(##args)
/// An entry to a list for giving projectiles bullet traits with a unique ID
/// Must be placed inside of a list
#define BULLET_TRAIT_ENTRY_ID(id, trait, args...) id = list(trait, ##args)
Expand Down
5 changes: 1 addition & 4 deletions code/__HELPERS/type2type.dm
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
var/char = copytext(hex, i, i + 1)
switch(char)
if("0")
//Apparently, switch works with empty statements, yay! If that doesn't work, blame me, though. -- Urist
pass()
if("9", "8", "7", "6", "5", "4", "3", "2", "1")
num += text2num(char) * 16 ** power
if("a", "A")
Expand Down Expand Up @@ -77,7 +77,6 @@
hex += "E"
if(15.0)
hex += "F"
else
power--
while(length(hex) < placeholder)
hex = text("0[]", hex)
Expand Down Expand Up @@ -165,8 +164,6 @@
return 6
if("SOUTHWEST")
return 10
else
return

//Converts an angle (degrees) into an ss13 direction
/proc/angle2dir(degree)
Expand Down
11 changes: 11 additions & 0 deletions code/__odlint.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// This file is included right at the start of the DME.
// Its purpose is to enable multiple lints (pragmas) that are supported by OpenDream to better validate the codebase
// These are essentially nitpicks the DM compiler should pick up on but doesnt

#ifndef SPACEMAN_DMM
#ifdef OPENDREAM
// These are in their own file as you need to do it with an include as a hack to avoid
// SpacemanDMM evaluating the #pragma lines, even if its outside a block it cares about
#include "__pragmas.dm"
#endif
#endif
27 changes: 27 additions & 0 deletions code/__pragmas.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//1000-1999
#pragma FileAlreadyIncluded error
#pragma MissingIncludedFile error
#pragma MisplacedDirective error
#pragma UndefineMissingDirective error
#pragma DefinedMissingParen error
#pragma ErrorDirective error
#pragma WarningDirective error
#pragma MiscapitalizedDirective error

//2000-2999
#pragma SoftReservedKeyword error
#pragma DuplicateVariable error
#pragma DuplicateProcDefinition error
#pragma TooManyArguments error
#pragma PointlessParentCall error
#pragma PointlessBuiltinCall error
#pragma SuspiciousMatrixCall error
#pragma MalformedRange error
#pragma InvalidRange error
#pragma InvalidSetStatement error
#pragma InvalidOverride error
#pragma DanglingVarType error
#pragma MissingInterpolatedExpression error

//3000-3999
#pragma EmptyBlock error
2 changes: 1 addition & 1 deletion code/_byond_version_compat.dm
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//Update this whenever you need to take advantage of more recent byond features
#define MIN_COMPILER_VERSION 514
#define MIN_COMPILER_BUILD 1588
#if (DM_VERSION < MIN_COMPILER_VERSION || DM_BUILD < MIN_COMPILER_BUILD) && !defined(SPACEMAN_DMM)
#if (DM_VERSION < MIN_COMPILER_VERSION || DM_BUILD < MIN_COMPILER_BUILD) && !defined(SPACEMAN_DMM) && !defined(OPENDREAM)
//Don't forget to update this part
#error Your version of BYOND is too out-of-date to compile this project. Go to https://secure.byond.com/download and update.
#error You need version 514.1588 or higher
Expand Down
2 changes: 1 addition & 1 deletion code/_compile_options.dm
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#define CBT
#endif

#if !defined(CBT) && !defined(SPACEMAN_DMM)
#if !defined(CBT) && !defined(SPACEMAN_DMM) && !defined(OPENDREAM)
#warn Building with Dream Maker is no longer supported and will result in errors.
#warn In order to build, run BUILD.bat in the bin directory.
#warn Consider switching to VSCode editor instead, where you can press Ctrl+Shift+B to build.
Expand Down
2 changes: 1 addition & 1 deletion code/controllers/subsystem/atoms.dm
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ SUBSYSTEM_DEF(atoms)

switch(result)
if (INITIALIZE_HINT_NORMAL)
// pass
pass()
if(INITIALIZE_HINT_LATELOAD)
if(arguments[1]) //mapload
late_loaders += A
Expand Down
2 changes: 1 addition & 1 deletion code/controllers/subsystem/vote.dm
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ SUBSYSTEM_DEF(vote)
question = "Gamemode vote"
randomize_entries = TRUE
for(var/mode_type in config.gamemode_cache)
var/datum/game_mode/M = initial(mode_type)
var/datum/game_mode/M = mode_type
if(initial(M.config_tag))
var/vote_cycle_met = !initial(M.vote_cycle) || (text2num(SSperf_logging?.round?.id) % initial(M.vote_cycle) == 0)
if(initial(M.votable) && vote_cycle_met)
Expand Down
4 changes: 2 additions & 2 deletions code/datums/_ndatabase/code/brsql_adapter.dm
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@
SSdatabase.create_parametric_query(query_updatetable, qpars, CB)

/datum/db/adapter/brsql_adapter/insert_table(table_name, list/values, datum/callback/CB, sync = FALSE)
if(!sync)
set waitfor = 0
set waitfor = FALSE

var/length = values.len
var/list/qpars = list()
var/query_inserttable = getquery_insert_table(table_name, values, qpars)
Expand Down
3 changes: 1 addition & 2 deletions code/datums/_ndatabase/code/native_adapter.dm
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,7 @@
SSdatabase.create_query(query_gettable, CB)

/datum/db/adapter/native_adapter/update_table(table_name, list/values, datum/callback/CB, sync = FALSE)
if(!sync)
set waitfor = 0
set waitfor = FALSE

for(var/list/vals in values)
var/list/qpars = list()
Expand Down
2 changes: 0 additions & 2 deletions code/game/machinery/OpTable.dm
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@
if(EXPLOSION_THRESHOLD_MEDIUM to INFINITY)
deconstruct(FALSE)
return
else
return

/obj/structure/machinery/optable/get_examine_text(mob/user)
. = ..()
Expand Down
2 changes: 0 additions & 2 deletions code/game/machinery/air_alarm.dm
Original file line number Diff line number Diff line change
Expand Up @@ -431,8 +431,6 @@
var/wireIndex = AAlarmWireColorToIndex[wireColor] //not used in this function
AAlarmwires |= wireFlag
switch(wireIndex)
if(AALARM_WIRE_IDSCAN)

if(AALARM_WIRE_POWER)
shorted = 0
shock(usr, 50)
Expand Down
2 changes: 1 addition & 1 deletion code/game/machinery/bots/mulebot.dm
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@
var/speed = ((wires & WIRE_MOTOR1) ? 1:0) + ((wires & WIRE_MOTOR2) ? 2:0)
switch(speed)
if(0)
// do nothing
pass()
if(1)
process_bot()
spawn(2)
Expand Down
2 changes: 0 additions & 2 deletions code/game/machinery/computer/computer.dm
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@
if(EXPLOSION_THRESHOLD_MEDIUM to INFINITY)
deconstruct(FALSE)
return
else
return

/obj/structure/machinery/computer/bullet_act(obj/projectile/Proj)
if(exproof)
Expand Down
7 changes: 0 additions & 7 deletions code/game/machinery/computer/medical.dm
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@
else
dat += "<br>[bdat]"

else
else
dat += text("<A href='?src=\ref[];login=1'>{Log In}</A>", src)
show_browser(user, dat, "Medical Records", "med_rec")
Expand Down Expand Up @@ -365,8 +364,6 @@
for(var/datum/data/record/E in GLOB.data_core.medical)
if ((E.fields["ref"] == R.fields["ref"] || E.fields["id"] == R.fields["id"]))
M = E
else
//Foreach continue //goto(2540)
src.active1 = R
src.active2 = M
src.screen = 4
Expand Down Expand Up @@ -417,16 +414,12 @@
for(var/datum/data/record/R as anything in GLOB.data_core.medical)
if ((lowertext(R.fields["name"]) == t1 || t1 == lowertext(R.fields["id"])))
src.active2 = R
else
//Foreach continue //goto(3229)
if (!active2)
temp = "Could not locate record [t1]."
else
for(var/datum/data/record/E in GLOB.data_core.general)
if ((E.fields["name"] == src.active2.fields["name"] || E.fields["id"] == src.active2.fields["id"]))
src.active1 = E
else
//Foreach continue //goto(3334)
src.screen = 4

if (href_list["print_p"])
Expand Down
1 change: 0 additions & 1 deletion code/game/machinery/computer/pod.dm
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
for(var/obj/structure/machinery/mass_driver/M in machines)
if(M.id == id)
connected = M
else
return
return

Expand Down
3 changes: 1 addition & 2 deletions code/game/machinery/computer/robot.dm
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@
dat += " Locked Down |"
else
dat += " Operating Normally |"
if (!R.canmove)
else if(R.cell)
if(R.canmove && R.cell)
dat += " Battery Installed ([R.cell.charge]/[R.cell.maxcharge]) |"
else
dat += " No Cell Installed |"
Expand Down
45 changes: 20 additions & 25 deletions code/game/machinery/computer/skills.dm
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,16 @@
var/dat

if (temp)
dat = text("<TT>[]</TT><BR><BR><A href='?src=\ref[];choice=Clear Screen'>Clear Screen</A>", temp, src)
dat = "<TT>[temp]</TT><BR><BR><A href='?src=\ref[src];choice=Clear Screen'>Clear Screen</A>"
else
dat = text("Confirm Identity: <A href='?src=\ref[];choice=Confirm Identity'>[]</A><HR>", src, (scan ? text("[]", scan.name) : "----------"))
dat = "Confirm Identity: <A href='?src=\ref[src];choice=Confirm Identity'>[scan ? scan.name : "----------"]</A><HR>"
if (authenticated)
switch(screen)
if(1.0)
dat += {"
<p style='text-align:center;'>"}
dat += text("<A href='?src=\ref[];choice=Search Records'>Search Records</A><BR>", src)
dat += text("<A href='?src=\ref[];choice=New Record (General)'>New Record</A><BR>", src)
dat += "<A href='?src=\ref[src];choice=Search Records'>Search Records</A><BR>"
dat += "<A href='?src=\ref[src];choice=New Record (General)'>New Record</A><BR>"
dat += {"
</p>
<table style="text-align:center;" cellspacing="0" width="100%">
Expand All @@ -70,20 +70,19 @@
if(!isnull(GLOB.data_core.general))
for(var/datum/data/record/R in sortRecord(GLOB.data_core.general, sortBy, order))
for(var/datum/data/record/E in GLOB.data_core.security)
var/background
dat += text("<tr style=[]><td><A href='?src=\ref[];choice=Browse Record;d_rec=\ref[]'>[]</a></td>", background, src, R, R.fields["name"])
dat += text("<td>[]</td>", R.fields["id"])
dat += text("<td>[]</td>", R.fields["rank"])
dat += "<tr><td><A href='?src=\ref[src];choice=Browse Record;d_rec=\ref[R]'>[R.fields["name"]]</a></td>"
dat += "<td>[R.fields["id"]]</td>"
dat += "<td>[R.fields["rank"]]</td>"
dat += "</table><hr width='75%' />"
dat += text("<A href='?src=\ref[];choice=Record Maintenance'>Record Maintenance</A><br><br>", src)
dat += text("<A href='?src=\ref[];choice=Log Out'>{Log Out}</A>",src)
dat += "<A href='?src=\ref[src];choice=Record Maintenance'>Record Maintenance</A><br><br>"
dat += "<A href='?src=\ref[src];choice=Log Out'>{Log Out}</A>"
if(2.0)
dat += "<B>Records Maintenance</B><HR>"
dat += "<BR><A href='?src=\ref[src];choice=Delete All Records'>Delete All Records</A><BR><BR><A href='?src=\ref[src];choice=Return'>Back</A>"
if(3.0)
dat += "<CENTER><B>Employment Record</B></CENTER><BR>"
if ((istype(active1, /datum/data/record) && GLOB.data_core.general.Find(active1)))
dat += text("<table><tr><td> \
dat += "<table><tr><td> \
Name: <A href='?src=\ref[src];choice=Edit Field;field=name'>[active1.fields["name"]]</A><BR> \
ID: <A href='?src=\ref[src];choice=Edit Field;field=id'>[active1.fields["id"]]</A><BR>\n \
Sex: <A href='?src=\ref[src];choice=Edit Field;field=sex'>[active1.fields["sex"]]</A><BR>\n \
Expand All @@ -93,18 +92,18 @@
Mental Status: [active1.fields["m_stat"]]<BR><BR>\n \
Employment/skills summary:<BR> [decode(active1.fields["notes"])]<BR></td> \
<td align = center valign = top>Photo:<br><img src=front.png height=80 width=80 border=4> \
<img src=side.png height=80 width=80 border=4></td></tr></table>")
<img src=side.png height=80 width=80 border=4></td></tr></table>"
else
dat += "<B>General Record Lost!</B><BR>"
dat += text("\n<A href='?src=\ref[];choice=Delete Record (ALL)'>Delete Record (ALL)</A><BR><BR>\n<A href='?src=\ref[];choice=Print Record'>Print Record</A><BR>\n<A href='?src=\ref[];choice=Return'>Back</A><BR>", src, src, src)
dat += "\n<A href='?src=\ref[src];choice=Delete Record (ALL)'>Delete Record (ALL)</A><BR><BR>\n<A href='?src=\ref[src];choice=Print Record'>Print Record</A><BR>\n<A href='?src=\ref[src];choice=Return'>Back</A><BR>"
if(4.0)
if(!Perp.len)
dat += text("ERROR. String could not be located.<br><br><A href='?src=\ref[];choice=Return'>Back</A>", src)
dat += "ERROR. String could not be located.<br><br><A href='?src=\ref[src];choice=Return'>Back</A>"
else
dat += {"
<table style="text-align:center;" cellspacing="0" width="100%">
<tr> "}
dat += text("<th>Search Results for '[]':</th>", tempname)
dat += "<th>Search Results for '[tempname]':</th>"
dat += {"
</tr>
</table>
Expand All @@ -121,17 +120,14 @@
if(istype(Perp[i+1],/datum/data/record/))
var/datum/data/record/E = Perp[i+1]
crimstat = E.fields["criminal"]
var/background
background = "'background-color:#00FF7F;'"
dat += text("<tr style=[]><td><A href='?src=\ref[];choice=Browse Record;d_rec=\ref[]'>[]</a></td>", background, src, R, R.fields["name"])
dat += text("<td>[]</td>", R.fields["id"])
dat += text("<td>[]</td>", R.fields["rank"])
dat += text("<td>[]</td></tr>", crimstat)
dat += "<tr style=background-color:#00FF7F><td><A href='?src=\ref[src];choice=Browse Record;d_rec=\ref[R]'>[R.fields["name"]]</a></td>"
dat += "<td>[R.fields["id"]]</td>"
dat += "<td>[R.fields["rank"]]</td>"
dat += "<td>[crimstat]</td></tr>"
dat += "</table><hr width='75%' />"
dat += text("<br><A href='?src=\ref[];choice=Return'>Return to index.</A>", src)
else
dat += "<br><A href='?src=\ref[src];choice=Return'>Return to index.</A>"
else
dat += text("<A href='?src=\ref[];choice=Log In'>{Log In}</A>", src)
dat += "<A href='?src=\ref[src];choice=Log In'>{Log In}</A>"
show_browser(user, dat, "Employment Records", "secure_rec", "size=600x400")
onclose(user, "secure_rec")
return
Expand Down Expand Up @@ -342,7 +338,6 @@ What a mess.*/
if ((R.fields["name"] == active1.fields["name"] || R.fields["id"] == active1.fields["id"]))
GLOB.data_core.medical -= R
qdel(R)
else
QDEL_NULL(active1)
else
temp = "This function does not appear to be working at the moment. Our apologies."
Expand Down
1 change: 0 additions & 1 deletion code/game/machinery/deployable.dm
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
src.health -= W.force * 0.75
if("brute")
src.health -= W.force * 0.5
else
if (src.health <= 0)
src.explode()
..()
Expand Down
4 changes: 0 additions & 4 deletions code/game/machinery/medical_pod/bodyscanner.dm
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@
if(EXPLOSION_THRESHOLD_MEDIUM to INFINITY)
deconstruct(FALSE)
return
else
return

#ifdef OBJECTS_PROXY_SPEECH
// Transfers speech to occupant
Expand Down Expand Up @@ -124,8 +122,6 @@
if(EXPLOSION_THRESHOLD_MEDIUM to INFINITY)
deconstruct(FALSE)
return
else
return

/obj/structure/machinery/body_scanconsole/power_change()
..()
Expand Down
1 change: 0 additions & 1 deletion code/game/machinery/medical_pod/sleeper.dm
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,6 @@
t1 = "Unconscious"
if(2)
t1 = "*dead*"
else
to_chat(user, "[]\t Health %: [] ([])", (occupant.health > 50 ? SPAN_NOTICE("") : SPAN_DANGER("")), occupant.health, t1)
to_chat(user, "[]\t -Core Temperature: []&deg;C ([]&deg;F)</FONT><BR>", (occupant.bodytemperature > 50 ? "<font color='blue'>" : "<font color='red'>"), occupant.bodytemperature-T0C, occupant.bodytemperature*1.8-459.67)
to_chat(user, "[]\t -Brute Damage %: []", (occupant.getBruteLoss() < 60 ? SPAN_NOTICE("") : SPAN_DANGER("")), occupant.getBruteLoss())
Expand Down
Loading

0 comments on commit 23e0d1d

Please sign in to comment.