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

Aggressive OD linting #11464

Merged
merged 12 commits into from
Sep 10, 2024
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(CIBUILDING) && 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
1 change: 1 addition & 0 deletions beestation.dme
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,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
2 changes: 1 addition & 1 deletion code/datums/elements/mechanical_repair.dm
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
return COMPONENT_NO_AFTERATTACK

/datum/element/mechanical_repair/proc/complete_repairs(mob/living/carbon/human/target, obj/item/I, mob/user, selected_zone)
if(target in user.do_afters || !user.can_interact_with(target, TRUE) || !user.can_interact_with(I, TRUE))
if((target in user.do_afters) || !user.can_interact_with(target, TRUE) || !user.can_interact_with(I, TRUE))
return COMPONENT_NO_AFTERATTACK

var/obj/item/bodypart/affecting = target.get_bodypart(check_zone(selected_zone))
Expand Down
2 changes: 1 addition & 1 deletion code/game/machinery/computer/card.dm
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,7 @@ GLOBAL_VAR_INIT(time_last_changed_position, 0)
update_modify_manifest()

if ("demote")
if(inserted_modify_id.assignment in head_subordinates || inserted_modify_id.assignment == "Assistant")
if((inserted_modify_id.assignment in head_subordinates) || inserted_modify_id.assignment == "Assistant")
inserted_modify_id.assignment = "Demoted"
log_id("[key_name(usr)] demoted [inserted_modify_id], unassigning the card without affecting access, using [inserted_scan_id] at [AREACOORD(usr)].")
playsound(src, 'sound/machines/terminal_prompt_confirm.ogg', 50, FALSE)
Expand Down
4 changes: 2 additions & 2 deletions code/game/objects/items/crayons.dm
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@
. = TRUE
if("select_stencil")
var/stencil = params["item"]
if(stencil in all_drawables + randoms)
if(stencil in (all_drawables + randoms))
drawtype = stencil
. = TRUE
text_buffer = ""
Expand Down Expand Up @@ -316,7 +316,7 @@
temp = "symbol"
else if(drawing in drawings)
temp = "drawing"
else if(drawing in graffiti|oriented)
else if(drawing in (graffiti | oriented))
temp = "graffiti"
var/gang_check = hippie_gang_check(user,target) // hippie start -- gang check and temp setting
if(!gang_check) return // hippie end
Expand Down
4 changes: 2 additions & 2 deletions code/game/objects/items/pet_carrier.dm
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
occupant_weight -= L.mob_size

/obj/item/pet_carrier/handle_atom_del(atom/A)
if(A in occupants && isliving(A))
if((A in occupants) && isliving(A))
var/mob/living/L = A
occupants -= L
occupant_weight -= L.mob_size
Expand Down Expand Up @@ -184,7 +184,7 @@
add_occupant(target)

/obj/item/pet_carrier/proc/add_occupant(mob/living/occupant)
if(occupant in occupants || !istype(occupant))
if((occupant in occupants) || !istype(occupant))
return
occupant.forceMove(src)
occupants += occupant
Expand Down
2 changes: 1 addition & 1 deletion code/modules/admin/permissionedit.dm
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@
. = ckey(admin_key)
if(!.)
return FALSE
if(!admin_ckey && (. in GLOB.admin_datums+GLOB.deadmins))
if(!admin_ckey && (. in (GLOB.admin_datums+GLOB.deadmins)))
to_chat(usr, "<span class='danger'>[admin_key] is already an admin.</span>")
return FALSE
if(use_db)
Expand Down
2 changes: 1 addition & 1 deletion code/modules/antagonists/blob/overmind.dm
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ CREATION_TEST_IGNORE_SUBTYPES(/mob/camera/blob)
if(!T || !is_station_level(T.z))
continue

if(L in GLOB.overminds || (L.pass_flags & PASSBLOB))
if((L in GLOB.overminds) || (L.pass_flags & PASSBLOB))
continue

var/area/Ablob = get_area(T)
Expand Down
2 changes: 1 addition & 1 deletion code/modules/antagonists/heretic/knowledge/rust_lore.dm
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@
max_dist = max(max_dist, get_dist(found_turf, centre) + 1)

for(var/turf/nearby_turf as anything in spiral_range_turfs(max_dist, centre, FALSE))
if(nearby_turf in rusted_turfs || is_type_in_typecache(nearby_turf, blacklisted_turfs))
if((nearby_turf in rusted_turfs) || is_type_in_typecache(nearby_turf, blacklisted_turfs))
continue

for(var/turf/line_turf as anything in getline(nearby_turf, centre))
Expand Down
2 changes: 1 addition & 1 deletion code/modules/antagonists/heretic/magic/ash_ascension.dm
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
if(L.anti_magic_check())
L.visible_message("<span class='danger'>The spell bounces off of [L]!</span>","<span class='danger'>The spell bounces off of you!</span>")
continue
if(L in hit_list || L == source)
if((L in hit_list) || L == source)
continue
hit_list += L
L.adjustFireLoss(20)
Expand Down
2 changes: 1 addition & 1 deletion code/modules/mob/living/simple_animal/bot/atmosbot.dm
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ CREATION_TEST_IGNORE_SUBTYPES(/mob/living/simple_animal/bot/atmosbot)
//Add adjacent turfs
for(var/direction in list(NORTH, SOUTH, EAST, WEST))
var/turf/adjacent_turf = get_step(checking_turf, direction)
if(adjacent_turf in checked_turfs || !adjacent_turf.CanAtmosPass(adjacent_turf))
if((adjacent_turf in checked_turfs) || !adjacent_turf.CanAtmosPass(adjacent_turf))
continue
var/datum/gas_mixture/checking_air = checking_turf.return_air()
if (!checking_air)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ Difficulty: Medium
new /obj/effect/hotspot(T)
T.hotspot_expose(700,50,1)
for(var/mob/living/L in T.contents)
if(L in hit_list || L == source)
if((L in hit_list) || L == source)
continue
hit_list += L
L.adjustFireLoss(20)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ CREATION_TEST_IGNORE_SUBTYPES(/obj/structure/light_prism)
user.remove_movespeed_modifier(/datum/movespeed_modifier/admantine_armor)

/obj/item/clothing/suit/armor/heavy/adamantine/IsReflect(def_zone)
if(def_zone in list(BODY_ZONE_CHEST, BODY_ZONE_R_ARM, BODY_ZONE_L_ARM, BODY_ZONE_R_LEG, BODY_ZONE_L_LEG) && prob(hit_reflect_chance))
if((def_zone in list(BODY_ZONE_CHEST, BODY_ZONE_R_ARM, BODY_ZONE_L_ARM, BODY_ZONE_R_LEG, BODY_ZONE_L_LEG)) && prob(hit_reflect_chance))
return TRUE
else
return FALSE
58 changes: 58 additions & 0 deletions tools/ci/od_lints.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/**
* Beestation OpenDream linting config:
* See https://github.com/OpenDreamProject/OpenDream/blob/master/DMCompiler/DMStandard/DefaultPragmaConfig.dm
*/

// This is the default error/warning/notice/disable setup when the user does not mandate a different file or configuration.
// If you add a new named error with a code greater than 999, please mark it here.

//1000-1999
#pragma FileAlreadyIncluded error
#pragma MissingIncludedFile error
#pragma InvalidWarningCode error
#pragma MisplacedDirective error
#pragma UndefineMissingDirective error
#pragma DefinedMissingParen error
#pragma ErrorDirective error
// Beestation: Explicitly kept at warning as this is the #warn define.
#pragma WarningDirective warning
#pragma MiscapitalizedDirective error

//2000-2999
#pragma SoftReservedKeyword error
#pragma DuplicateVariable error
#pragma DuplicateProcDefinition error
#pragma PointlessParentCall error
#pragma PointlessBuiltinCall error
#pragma SuspiciousMatrixCall error
#pragma FallbackBuiltinArgument error
#pragma PointlessScopeOperator error
#pragma MalformedRange error
#pragma InvalidRange error
#pragma InvalidSetStatement error
#pragma InvalidOverride error
#pragma InvalidIndexOperation error
#pragma DanglingVarType error
#pragma MissingInterpolatedExpression error
#pragma AmbiguousResourcePath error
#pragma SuspiciousSwitchCase error
#pragma PointlessPositionalArgument error
// NOTE: The next few pragmas are for OpenDream's experimental type checker
// This feature is still in development, elevating these pragmas outside of local testing is discouraged
// An RFC to finalize this feature is coming soon(TM)
// BEGIN TYPEMAKER
#pragma UnsupportedTypeCheck notice
#pragma InvalidReturnType notice
#pragma InvalidVarType notice
#pragma ImplicitNullType notice
#pragma LostTypeInfo notice
// END TYPEMAKER
#pragma UnimplementedAccess error

//3000-3999
#pragma EmptyBlock notice
#pragma EmptyProc disabled // NOTE: If you enable this in OD's default pragma config file, it will emit for OD's DMStandard. Put it in your codebase's pragma config file.
#pragma UnsafeClientAccess disabled // NOTE: Only checks for unsafe accesses like "client.foobar" and doesn't consider if the client was already null-checked earlier in the proc
#pragma AssignmentInConditional error
#pragma PickWeightedSyntax disabled
#pragma AmbiguousInOrder error
Loading