Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MIRROR] Lint with OpenDream (#81892) #2726

Merged
merged 2 commits into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .github/workflows/ci_suite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,25 @@ jobs:
if: steps.linter-setup.conclusion == 'success' && !cancelled()
run: tools/build/build --ci lint tgui-test

odlint:
if: ( !contains(github.event.head_commit.message, '[ci skip]') )
name: "Lint with OpenDream"
runs-on: ubuntu-22.04
concurrency:
group: odlint-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
steps:
- uses: actions/checkout@v4
- uses: robinraju/[email protected]
with:
repository: "OpenDreamProject/OpenDream"
tag: "latest"
fileName: "DMCompiler_linux-x64.tar.gz"
extract: true
- name: Run OpenDream
run: |
./DMCompiler_linux-x64/DMCompiler tgstation.dme --suppress-unimplemented --define=CIBUILDING

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 @@ -247,3 +247,6 @@ define_sanity_output.txt
# ezdb
/db/
/config/ezdb.txt

# Running OpenDream locally
tgstation.json
10 changes: 10 additions & 0 deletions __odlint.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// 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

#if !defined(SPACEMAN_DMM) && defined(OPENDREAM)
// This is in a separate file as a hack to avoid SpacemanDMM
// evaluating the #pragma lines, even if its outside a block it cares about
// (Also so people can code-own it. Shoutout to AA)
#include "tools/ci/od_lints.dm"
#endif
4 changes: 4 additions & 0 deletions code/__DEFINES/_helpers.dm
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,7 @@
// Custom types that we define don't get a unique id, but this is useful for identifying
// types that don't normally have a way to run istype() on them.
#define TYPEID(thing) copytext(REF(thing), 4, 6)

/// A null statement to guard against EmptyBlock lint without necessitating the use of pass()
/// Used to avoid proc-call overhead. But use sparingly. Probably pointless in most places.
#define EMPTY_BLOCK_GUARD ;
8 changes: 4 additions & 4 deletions code/__HELPERS/type2type.dm
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
return "northwest"
if(SOUTHWEST)
return "southwest"
else
return

return NONE

//Turns text into proper directions
/proc/text2dir(direction)
Expand All @@ -58,8 +58,8 @@
return SOUTHEAST
if("SOUTHWEST")
return SOUTHWEST
else
return

return NONE

//Converts an angle (degrees) into a ss13 direction
GLOBAL_LIST_INIT(modulo_angle_to_dir, list(NORTH,NORTHEAST,EAST,SOUTHEAST,SOUTH,SOUTHWEST,WEST,NORTHWEST))
Expand Down
17 changes: 12 additions & 5 deletions code/_compile_options.dm
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
#warn compiling in TESTING mode. testing() debug messages will be visible.
#endif

#ifdef CIBUILDING
#if defined(CIBUILDING) && !defined(OPENDREAM)
#define UNIT_TESTS
#endif

Expand All @@ -137,10 +137,17 @@
#define CBT
#endif

#if !defined(CBT) && !defined(SPACEMAN_DMM)
#warn Building with Dream Maker is no longer supported and will result in errors.
#warn In order to build, run BUILD.bat in the root directory.
#warn Consider switching to VSCode editor instead, where you can press Ctrl+Shift+B to build.
#if defined(OPENDREAM)
#if !defined(CIBUILDING)
#warn You are building with OpenDream. Remember to build TGUI manually.
#warn You can do this by running tgui-build.cmd from the bin directory.
#endif
#else
#if !defined(CBT) && !defined(SPACEMAN_DMM)
#warn Building with Dream Maker is no longer supported and will result in errors.
#warn In order to build, run BUILD.cmd in the root directory.
#warn Consider switching to VSCode editor instead, where you can press Ctrl+Shift+B to build.
#endif
#endif

/// Runs the game in "map test mode"
Expand Down
4 changes: 2 additions & 2 deletions code/_onclick/item_attack.dm
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
if (SECONDARY_ATTACK_CANCEL_ATTACK_CHAIN)
return TRUE
if (SECONDARY_ATTACK_CONTINUE_CHAIN)
// Normal behavior
EMPTY_BLOCK_GUARD // Normal behavior
else
CRASH("pre_attack_secondary must return an SECONDARY_ATTACK_* define, please consult code/__DEFINES/combat.dm")
else
Expand All @@ -43,7 +43,7 @@
if (SECONDARY_ATTACK_CANCEL_ATTACK_CHAIN)
return TRUE
if (SECONDARY_ATTACK_CONTINUE_CHAIN)
// Normal behavior
EMPTY_BLOCK_GUARD // Normal behavior
else
CRASH("attackby_secondary must return an SECONDARY_ATTACK_* define, please consult code/__DEFINES/combat.dm")
else
Expand Down
2 changes: 1 addition & 1 deletion code/datums/components/food/edible.dm
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ Behavior that's still missing from this component that original food items had t
if(!(food_flags & FOOD_IN_CONTAINER))
switch(bitecount)
if(0)
// pass
pass()
if(1)
examine_list += span_notice("[owner] was bitten by someone!")
if(2, 3)
Expand Down
3 changes: 3 additions & 0 deletions code/datums/wounds/burns.dm
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,14 @@
infestation += infestation_rate * seconds_per_tick
switch(infestation)
if(0 to WOUND_INFECTION_MODERATE)
return

if(WOUND_INFECTION_MODERATE to WOUND_INFECTION_SEVERE)
if(SPT_PROB(15, seconds_per_tick))
victim.adjustToxLoss(0.2)
if(prob(6))
to_chat(victim, span_warning("The blisters on your [limb.plaintext_zone] ooze a strange pus..."))

if(WOUND_INFECTION_SEVERE to WOUND_INFECTION_CRITICAL)
if(!disabling)
if(SPT_PROB(1, seconds_per_tick))
Expand Down
9 changes: 3 additions & 6 deletions code/game/atom/atom_defense.dm
Original file line number Diff line number Diff line change
Expand Up @@ -94,17 +94,14 @@
CRASH("/atom/proc/run_atom_armor was called on [src] without being implemented as a type that uses integrity!")
if(damage_flag == MELEE && damage_amount < damage_deflection)
return 0
switch(damage_type)
if(BRUTE)
if(BURN)
else
return 0
if(damage_type != BRUTE && damage_type != BURN)
return 0
var/armor_protection = 0
if(damage_flag)
armor_protection = get_armor_rating(damage_flag)
if(armor_protection) //Only apply weak-against-armor/hollowpoint effects if there actually IS armor.
armor_protection = clamp(PENETRATE_ARMOUR(armor_protection, armour_penetration), min(armor_protection, 0), 100)
return round(damage_amount * (100 - armor_protection)*0.01, DAMAGE_PRECISION)
return round(damage_amount * (100 - armor_protection) * 0.01, DAMAGE_PRECISION)

///the sound played when the atom is damaged.
/atom/proc/play_attack_sound(damage_amount, damage_type = BRUTE, damage_flag = 0)
Expand Down
3 changes: 2 additions & 1 deletion code/game/atom/atoms_initializing_EXPENSIVE.dm
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/// Init this specific atom
/datum/controller/subsystem/atoms/proc/InitAtom(atom/A, from_template = FALSE, list/arguments)

var/the_type = A.type

if(QDELING(A))
Expand All @@ -24,7 +25,7 @@

switch(result)
if (INITIALIZE_HINT_NORMAL)
// pass
EMPTY_BLOCK_GUARD // Pass
if(INITIALIZE_HINT_LATELOAD)
if(arguments[1]) //mapload
late_loaders += A
Expand Down
5 changes: 2 additions & 3 deletions code/game/machinery/doors/airlock.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1538,9 +1538,8 @@

if(!disassembled)
A?.update_integrity(A.max_integrity * 0.5)
else if(obj_flags & EMAGGED)
//no electronics nothing
else

else if(!(obj_flags & EMAGGED))
var/obj/item/electronics/airlock/ae
if(!electronics)
ae = new/obj/item/electronics/airlock(loc)
Expand Down
6 changes: 6 additions & 0 deletions code/modules/admin/create_mob.dm
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,9 @@
// Snowflake for Ethereals
human.updatehealth()
human.updateappearance(mutcolor_update = TRUE)
// FLUFFY FRONTIER ADDITION START
human.set_blooper(pick(GLOB.blooper_list))
human.blooper_pitch = BLOOPER_PITCH_RAND(human.gender)
human.blooper_pitch_range = BLOOPER_VARIANCE_RAND
human.blooper_speed = rand(BLOOPER_DEFAULT_MINSPEED, BLOOPER_DEFAULT_MAXSPEED)
// FLUFFY FRONTIER ADDITION END
2 changes: 1 addition & 1 deletion code/modules/logging/log_holder.dm
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ GENERAL_PROTECT_DATUM(/datum/log_holder)
var/datum/data = data_list[key]

if(isnull(data))
// do nothing - nulls are allowed
pass() // nulls are allowed

else if(islist(data))
data = recursive_jsonify(data, semvers)
Expand Down
1 change: 1 addition & 0 deletions code/modules/projectiles/projectile.dm
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,7 @@
organ_hit_text = " in \the [parse_zone(hit_limb_zone)]"
if(suppressed == SUPPRESSED_VERY)
//playsound(loc, hitsound, 5, TRUE, -1) NOVA EDIT REMOVAL - IMPACT SOUNDS
organ_hit_text = organ_hit_text // NOVA EDIT ADDITION -- this is just so we don't have to nova edit the TG control statements. Otherwise will error in linters for being an empty block
else if(suppressed)
//playsound(loc, hitsound, 5, TRUE, -1) NOVA EDIT REMOVAL - IMPACT SOUNDS
to_chat(living_target, span_userdanger("You're shot by \a [src][organ_hit_text]!"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@
affected_mob.adjust_temp_blindness(-2 SECONDS * REM * seconds_per_tick)
var/need_mob_update
switch(current_cycle)
if(1 to 20)
//nothing
if(21 to 110)
if(SPT_PROB(100 * (1 - (sqrt(110 - current_cycle) / 10)), seconds_per_tick))
need_mob_update = affected_mob.adjustOrganLoss(ORGAN_SLOT_EYES, -2 * REM * seconds_per_tick)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@
var/narsian = FALSE

/obj/item/nullrod/cultdagger/attack_self(mob/user)
if(narsian)
else if(user.mind && (user.mind.holy_role))
if(!narsian && user.mind && (user.mind.holy_role))
to_chat(user, span_cult_large("\"Partake in the language of blood..\""))
user.grant_language(/datum/language/narsie, source = LANGUAGE_MIND)
special_desc_requirement = NONE // No point in keeping something that can't no longer be used
Expand All @@ -91,8 +90,7 @@
var/narsian = FALSE

/obj/item/nullrod/claymore/darkblade/attack_self(mob/user)
if(narsian)
else if(user.mind && (user.mind.holy_role))
if(!narsian && user.mind && (user.mind.holy_role))
to_chat(user, span_cult_large("\"Partake in the language of blood..\""))
user.grant_language(/datum/language/narsie, source = LANGUAGE_MIND)
special_desc_requirement = NONE // No point in keeping something that can't no longer be used
Expand Down
2 changes: 0 additions & 2 deletions modular_nova/modules/borgs/code/robot_model.dm
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
switch(cyborg_base_icon)
if("mekamine")
cyborg.AddComponent(/datum/component/robot_smoke)
else

else
cyborg.maptext_height = initial(cyborg.maptext_height)
cyborg.RemoveElement(/datum/element/footstep, FOOTSTEP_MOB_SHOE, 2, -6, sound_vary = TRUE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,12 @@
var/list/choices = list()
for(var/choice in available_selection)
var/datum/radial_menu_choice/option = new
var/image/part_image = image(icon = HIDING_RADIAL_DMI, icon_state = initial(choice))
var/image/part_image = image(icon = HIDING_RADIAL_DMI, icon_state = choice)

option.image = part_image
if(choice in try_hide_mutant_parts)
part_image.underlays += image(icon = HIDING_RADIAL_DMI, icon_state = "module_unable")
choices[initial(choice)] = option
choices[choice] = option
// Radial choices
sort_list(choices)
var/pick = show_radial_menu(usr, src, choices, custom_check = FALSE, tooltips = TRUE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@
for(var/choice in user.allowed_turfs)

var/datum/radial_menu_choice/option = new
option.image = image(icon = 'modular_nova/master_files/icons/effects/turf_effects_icons.dmi', icon_state = initial(choice))
option.image = image(icon = 'modular_nova/master_files/icons/effects/turf_effects_icons.dmi', icon_state = choice)

display_turf[initial(choice)] = option
display_turf[choice] = option

sort_list(display_turf)
var/chosen_turf = show_radial_menu(user, user, display_turf, custom_check = CALLBACK(src, PROC_REF(check_menu), user))
Expand Down
7 changes: 0 additions & 7 deletions tff_modular/modules/blooper/atoms_movable.dm
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,6 @@
blooper_pitch_range = BLOOPER_VARIANCE_RAND
blooper_speed = rand(BLOOPER_DEFAULT_MINSPEED, BLOOPER_DEFAULT_MAXSPEED)

/randomize_human(mob/living/carbon/human/human, randomize_mutations = FALSE)
. = ..()
human.set_blooper(pick(GLOB.blooper_list))
human.blooper_pitch = BLOOPER_PITCH_RAND(human.gender)
human.blooper_pitch_range = BLOOPER_VARIANCE_RAND
human.blooper_speed = rand(BLOOPER_DEFAULT_MINSPEED, BLOOPER_DEFAULT_MAXSPEED)

/mob/living/send_speech(message_raw, message_range = 6, obj/source = src, bubble_type = bubble_icon, list/spans, datum/language/message_language = null, list/message_mods = list(), forced = null, tts_message, list/tts_filter)
. = ..()
if(client)
Expand Down
1 change: 1 addition & 0 deletions tgstation.dme
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
// END_PREFERENCES

// BEGIN_INCLUDE
#include "__odlint.dm"
#include "_maps\_basemap.dm"
#include "code\__byond_version_compat.dm"
#include "code\_compile_options.dm"
Expand Down
33 changes: 33 additions & 0 deletions tools/ci/od_lints.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//1000-1999
#pragma FileAlreadyIncluded error
#pragma MissingIncludedFile error
#pragma MisplacedDirective error
#pragma UndefineMissingDirective error
#pragma DefinedMissingParen error
#pragma ErrorDirective error
#pragma WarningDirective warning
#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 FallbackBuiltinArgument error
#pragma MalformedRange error
#pragma InvalidRange error
#pragma InvalidSetStatement error
#pragma InvalidOverride error
#pragma DanglingVarType error
#pragma MissingInterpolatedExpression error
#pragma AmbiguousResourcePath error

//3000-3999
#pragma EmptyBlock error
#pragma EmptyProc disabled
#pragma UnsafeClientAccess disabled
#pragma SuspiciousSwitchCase error
#pragma AssignmentInConditional error
Loading