[MIRROR] Changes check_grep to use ripgrep and reformats/cleans up the check_grep file (#17631)

Changes check_grep to use ripgrep and reformats/cleans up the check_grep file (#71324)

## About The Pull Request

I fucked up the check_grep entry for docking ports.
default grep doesn't support newlines and so I need to use `pcregrep -M`

## Why It's Good For The Game

linters working good
## Changelog

Co-authored-by: Mothblocks <35135081+Mothblocks@users.noreply.github.com>
Co-authored-by: san7890 <the@san7890.com>

Co-authored-by: Zephyr <12817816+ZephyrTFA@users.noreply.github.com>
Co-authored-by: Mothblocks <35135081+Mothblocks@users.noreply.github.com>
Co-authored-by: san7890 <the@san7890.com>
This commit is contained in:
Zonespace
2022-11-23 13:08:20 -05:00
committed by GitHub
co-authored by Mothblocks san7890 Zephyr
parent f4335e5184
commit 8db803e724
8 changed files with 211 additions and 139 deletions
+1
View File
@@ -35,6 +35,7 @@ jobs:
pip3 install setuptools
bash tools/ci/install_node.sh
bash tools/ci/install_spaceman_dmm.sh dreamchecker
cargo install ripgrep --features pcre2
tools/bootstrap/python -c ''
- name: Run Linters
run: |
-3
View File
@@ -886,13 +886,10 @@
callTime = 250;
can_move_docking_ports = 1;
dir = 2;
dwidth = 6;
height = 15;
shuttle_id = "whiteship";
launch_status = 0;
movement_force = list("KNOCKDOWN"=0,"THROW"=0);
name = "White Ship";
width = 16;
preferred_direction = 8;
port_direction = 4
},
+1 -4
View File
@@ -368,15 +368,12 @@
callTime = 250;
can_move_docking_ports = 1;
dir = 2;
dwidth = 5;
height = 13;
shuttle_id = "whiteship";
launch_status = 0;
movement_force = list("KNOCKDOWN"=0,"THROW"=0);
name = "White Ship";
port_direction = 2;
preferred_direction = 2;
width = 11
preferred_direction = 2
},
/turf/open/floor/plating,
/area/shuttle/abandoned/engine)
+1 -5
View File
@@ -550,14 +550,10 @@
},
/obj/docking_port/mobile{
dir = 8;
dwidth = 1;
height = 18;
shuttle_id = "whiteship";
launch_status = 0;
name = "White Ship";
port_direction = 2;
width = 17;
dheight = 5
port_direction = 2
},
/turf/open/floor/plating,
/area/shuttle/abandoned)
@@ -362,7 +362,7 @@
/obj/machinery/coffeemaker/proc/take_cup(mob/user)
if(!coffee_cups) //shouldn't happen, but we all know how stuff manages to break
balloon_alert("no cups left!")
balloon_alert(user, "no cups left!")
return
var/obj/item/reagent_containers/cup/glass/coffee_cup/new_cup = new(get_turf(src))
user.put_in_hands(new_cup)
@@ -371,7 +371,7 @@
/obj/machinery/coffeemaker/proc/take_sugar(mob/user)
if(!sugar_packs)
balloon_alert("no sugar left!")
balloon_alert(user, "no sugar left!")
return
var/obj/item/reagent_containers/condiment/pack/sugar/new_pack = new(get_turf(src))
user.put_in_hands(new_pack)
@@ -380,7 +380,7 @@
/obj/machinery/coffeemaker/proc/take_sweetener(mob/user)
if(!sweetener_packs)
balloon_alert("no sweetener left!")
balloon_alert(user, "no sweetener left!")
return
var/obj/item/reagent_containers/condiment/pack/astrotame/new_pack = new(get_turf(src))
user.put_in_hands(new_pack)
@@ -389,7 +389,7 @@
/obj/machinery/coffeemaker/proc/take_creamer(mob/user)
if(!creamer_packs)
balloon_alert("no creamer left!")
balloon_alert(user, "no creamer left!")
return
var/obj/item/reagent_containers/condiment/creamer/new_pack = new(drop_location())
user.put_in_hands(new_pack)
@@ -160,7 +160,7 @@
if(istype(A, /obj/item/dnainjector))
var/obj/item/dnainjector/D = A
if(D.used)
balloon_alert("[D.name] is used up!")
balloon_alert(user, "[D.name] is used up!")
return
if(syringes.len < max_syringes)
if(!user.transferItemToLoc(D, src))
+1 -1
View File
@@ -82,7 +82,7 @@
return FALSE //so we can refill them via their afterattack.
if(istype(W, /obj/item/assembly_holder) && accepts_rig)
if(rig)
user.balloon_alert("another device is in the way!")
balloon_alert(user, "another device is in the way!")
return ..()
var/obj/item/assembly_holder/holder = W
if(!(locate(/obj/item/assembly/igniter) in holder.assemblies))
+202 -121
View File
@@ -12,288 +12,282 @@ NC="\033[0m" # No Color
st=0
echo -e "${BLUE}Checking for map issues...${NC}"
# check for ripgrep
if command -v rg >/dev/null 2>&1; then
grep=rg
pcre2_support=1
if [ ! rg -P '' >/dev/null 2>&1 ] ; then
pcre2_support=0
fi
code_files="-g *.dm"
map_files="-g *.dmm"
ignore_515_proc_marker='-g !__byond_version_compat.dm'
else
pcre2_support=0
grep=grep
code_files="-r --include=*.dm"
map_files="-r --include=*.dmm"
ignore_515_proc_marker="--exclude=__byond_version_compat.dm"
fi
if grep -El '^\".+\" = \(.+\)' _maps/**/*.dmm; then
echo -e "${BLUE}Using grep provider at $(which $grep)${NC}"
part=0
section() {
echo -e "${BLUE}Checking for $1${NC}..."
part=0
}
part() {
part=$((part+1))
padded=$(printf "%02d" $part)
echo -e "${GREEN} $padded- $1${NC}"
}
section "map issues"
part "TGM"
if $grep -U '^".+" = \(.+\)' $map_files; then
echo
echo -e "${RED}ERROR: Non-TGM formatted map detected. Please convert it using Map Merger!${NC}"
st=1
fi;
if grep -P '//' _maps/**/*.dmm | grep -v '//MAP CONVERTED BY dmm2tgm.py THIS HEADER COMMENT PREVENTS RECONVERSION, DO NOT REMOVE' | grep -Ev 'name|desc'; then
part "comments"
if $grep '//' $map_files | $grep -v '//MAP CONVERTED BY dmm2tgm.py THIS HEADER COMMENT PREVENTS RECONVERSION, DO NOT REMOVE' | $grep -v 'name|desc'; then
echo
echo -e "${RED}ERROR: Unexpected commented out line detected in this map file. Please remove it.${NC}"
st=1
fi;
if grep -P 'Merge Conflict Marker' _maps/**/*.dmm; then
part "conflict markers"
if $grep 'Merge Conflict Marker' $map_files; then
echo
echo -e "${RED}ERROR: Merge conflict markers detected in map, please resolve all merge failures!${NC}"
st=1
fi;
# We check for this as well to ensure people aren't actually using this mapping effect in their maps.
if grep -P '/obj/merge_conflict_marker' _maps/**/*.dmm; then
part "conflict marker object"
if $grep '/obj/merge_conflict_marker' $map_files; then
echo
echo -e "${RED}ERROR: Merge conflict markers detected in map, please resolve all merge failures!${NC}"
st=1
fi;
if grep -P '^\ttag = \"icon' _maps/**/*.dmm; then
part "iconstate tags"
if $grep '^\ttag = "icon' $map_files; then
echo
echo -e "${RED}ERROR: Tag vars from icon state generation detected in maps, please remove them.${NC}"
st=1
fi;
if grep -P 'step_[xy]' _maps/**/*.dmm; then
part "step varedits"
if $grep 'step_[xy]' $map_files; then
echo
echo -e "${RED}ERROR: step_x/step_y variables detected in maps, please remove them.${NC}"
st=1
fi;
if grep -P 'pixel_[^xy]' _maps/**/*.dmm; then
part "pixel varedits"
if $grep 'pixel_[^xy]' $map_files; then
echo
echo -e "${RED}ERROR: incorrect pixel offset variables detected in maps, please remove them.${NC}"
st=1
fi;
if grep -P '/obj/structure/cable(/\w+)+\{' _maps/**/*.dmm; then
part "varedited cables"
if $grep '/obj/structure/cable(/\w+)+[{]' $map_files; then
echo
echo -e "${RED}ERROR: Variable editted cables detected, please remove them.${NC}"
st=1
fi;
if grep -P '\td[1-2] =' _maps/**/*.dmm; then
part "invalid cables"
if $grep '\td[1-2] =' $map_files; then
echo
echo -e "${RED}ERROR: d1/d2 cable variables detected in maps, please remove them.${NC}"
st=1
fi;
if grep -Pzo '"\w+" = \(\n[^)]*?/obj/structure/cable,\n[^)]*?/obj/structure/cable,\n[^)]*?/area/.+?\)' _maps/**/*.dmm; then
part "multiple cables"
if $grep -U '"\w+" = \(\n[^)]*?/obj/structure/cable,\n[^)]*?/obj/structure/cable,\n[^)]*?/area/.+?\)' $map_files; then
echo
echo -e "${RED}ERROR: Found multiple cables on the same tile, please remove them.${NC}"
st=1
fi;
if grep -Pzo '"\w+" = \(\n[^)]*?/obj/structure/lattice[/\w]*?,\n[^)]*?/obj/structure/lattice[/\w]*?,\n[^)]*?/area/.+?\)' _maps/**/*.dmm; then
part "multiple lattices"
if $grep -U '"\w+" = \(\n[^)]*?/obj/structure/lattice[/\w]*?,\n[^)]*?/obj/structure/lattice[/\w]*?,\n[^)]*?/area/.+?\)' $map_files; then
echo
echo -e "${RED}ERROR: Found multiple lattices on the same tile, please remove them.${NC}"
st=1
fi;
if grep -Pzo '"\w+" = \(\n[^)]*?/obj/machinery/atmospherics/pipe/(?<type>[/\w]*),\n[^)]*?/obj/machinery/atmospherics/pipe/\g{type},\n[^)]*?/area/.+\)' _maps/**/*.dmm; then
echo
echo -e "${RED}ERROR: Found multiple identical pipes on the same tile, please remove them.${NC}"
st=1
fi;
if grep -Pzo '"\w+" = \(\n[^)]*?/obj/structure/barricade(?<type>[/\w]*),\n[^)]*?/obj/structure/barricade\g{type},\n[^)]*?/area/.+\)' _maps/**/*.dmm; then
echo
echo -e "${RED}ERROR: Found multiple identical barricades on the same tile, please remove them.${NC}"
st=1
fi;
if grep -Pzo '"\w+" = \(\n[^)]*?/obj/structure/table(?<type>[/\w]*),\n[^)]*?/obj/structure/table\g{type},\n[^)]*?/area/.+\)' _maps/**/*.dmm; then
echo
echo -e "${RED}ERROR: Found multiple identical tables on the same tile, please remove them.${NC}"
st=1
fi;
if grep -Pzo '"\w+" = \(\n[^)]*?/obj/structure/chair(?<type>[/\w]*),\n[^)]*?/obj/structure/chair\g{type},\n[^)]*?/area/.+\)' _maps/**/*.dmm; then
echo
echo -e "${RED}ERROR: Found multiple identical chairs on the same tile, please remove them.${NC}"
st=1
fi;
if grep -Pzo '"\w+" = \(\n[^)]*?/obj/machinery/door/airlock[/\w]*?,\n[^)]*?/obj/machinery/door/airlock[/\w]*?,\n[^)]*?/area/.+\)' _maps/**/*.dmm; then
part "multiple airlocks"
if $grep -U '"\w+" = \(\n[^)]*?/obj/machinery/door/airlock[/\w]*?,\n[^)]*?/obj/machinery/door/airlock[/\w]*?,\n[^)]*?/area/.+\)' $map_files; then
echo
echo -e "${RED}ERROR: Found multiple airlocks on the same tile, please remove them.${NC}"
st=1
fi;
if grep -Pzo '"\w+" = \(\n[^)]*?/obj/machinery/door/firedoor[/\w]*?,\n[^)]*?/obj/machinery/door/firedoor[/\w]*?,\n[^)]*?/area/.+\)' _maps/**/*.dmm; then
part "multiple firelocks"
if $grep -U '"\w+" = \(\n[^)]*?/obj/machinery/door/firedoor[/\w]*?,\n[^)]*?/obj/machinery/door/firedoor[/\w]*?,\n[^)]*?/area/.+\)' $map_files; then
echo
echo -e "${RED}ERROR: Found multiple firelocks on the same tile, please remove them.${NC}"
st=1
fi;
if grep -Pzo '"\w+" = \(\n[^)]*?/obj/structure/closet(?<type>[/\w]*),\n[^)]*?/obj/structure/closet\g{type},\n[^)]*?/area/.+\)' _maps/**/*.dmm; then
echo
echo -e "${RED}ERROR: Found multiple identical closets on the same tile, please remove them.${NC}"
st=1
fi;
if grep -Pzo '"\w+" = \(\n[^)]*?/obj/structure/grille(?<type>[/\w]*),\n[^)]*?/obj/structure/grille/\g{type},\n[^)]*?/area/.+\)' _maps/**/*.dmm; then
echo
echo -e "${RED}ERROR: Found multiple identical grilles on the same tile, please remove them.${NC}"
st=1
fi;
if grep -Pzo '"\w+" = \(\n[^)]*?/obj/structure/girder(?<type>[/\w]*),\n[^)]*?/obj/structure/girder\g{type},\n[^)]*?/area/.+\)' _maps/**/*.dmm; then
echo
echo -e "${RED}ERROR: Found multiple identical girders on the same tile, please remove them.${NC}"
st=1
fi;
if grep -Pzo '"\w+" = \(\n[^)]*?/obj/structure/stairs/(?<type>[/\w]*),\n[^)]*?/obj/structure/stairs/\g{type},\n[^)]*?/area/.+\)' _maps/**/*.dmm; then
echo
echo -e "${RED}ERROR: Found multiple identical stairs on the same tile, please remove them.${NC}"
st=1
fi;
if grep -rzoP 'machinery/door.*{([^}]|\n)*name = .*("|\s)(?!of|and|to)[a-z].*\n' _maps/**/*.dmm; then
echo
echo -e "${RED}ERROR: Found door names without proper upper-casing. Please upper-case your door names.${NC}"
st=1
fi;
if grep -Pzo '/obj/machinery/power/apc[/\w]*?\{\n[^}]*?pixel_[xy] = -?[013-9]\d*?[^\d]*?\s*?\},?\n' _maps/**/*.dmm ||
grep -Pzo '/obj/machinery/power/apc[/\w]*?\{\n[^}]*?pixel_[xy] = -?\d+?[0-46-9][^\d]*?\s*?\},?\n' _maps/**/*.dmm ||
grep -Pzo '/obj/machinery/power/apc[/\w]*?\{\n[^}]*?pixel_[xy] = -?\d{3,1000}[^\d]*?\s*?\},?\n' _maps/**/*.dmm ; then
part "apc pixel shifts"
if $grep -U '/obj/machinery/power/apc[/\w]*?[{]\n[^}]*?pixel_[xy] = -?[013-9]\d*?[^\d]*?\s*?[}],?\n' $map_files ||
$grep -U '/obj/machinery/power/apc[/\w]*?[{]\n[^}]*?pixel_[xy] = -?\d+?[0-46-9][^\d]*?\s*?[}],?\n' $map_files ||
$grep -U '/obj/machinery/power/apc[/\w]*?[{]\n[^}]*?pixel_[xy] = -?\d{3,1000}[^\d]*?\s*?[}],?\n' $map_files ; then
echo
echo -e "${RED}ERROR: Found an APC with a manually set pixel_x or pixel_y that is not +-25. Use the directional variants when possible.${NC}"
st=1
fi;
if grep -Pzo '"\w+" = \(\n[^)]*?/obj/structure/lattice[/\w]*?,\n[^)]*?/turf/closed/wall[/\w]*?,\n[^)]*?/area/.+?\)' _maps/**/*.dmm; then
part "lattice and wall stacking"
if $grep -U '"\w+" = \(\n[^)]*?/obj/structure/lattice[/\w]*?,\n[^)]*?/turf/closed/wall[/\w]*?,\n[^)]*?/area/.+?\)' $map_files; then
echo
echo -e "${RED}ERROR: Found a lattice stacked with a wall, please remove them.${NC}"
st=1
fi;
if grep -Pzo '"\w+" = \(\n[^)]*?/obj/structure/lattice[/\w]*?,\n[^)]*?/turf/closed[/\w]*?,\n[^)]*?/area/.+?\)' _maps/**/*.dmm; then
if $grep -U '"\w+" = \(\n[^)]*?/obj/structure/lattice[/\w]*?,\n[^)]*?/turf/closed[/\w]*?,\n[^)]*?/area/.+?\)' $map_files; then
echo
echo -e "${RED}ERROR: Found a lattice stacked within a wall, please remove them.${NC}"
st=1
fi;
if grep -Pzo '"\w+" = \(\n[^)]*?/obj/structure/window[/\w]*?,\n[^)]*?/turf/closed[/\w]*?,\n[^)]*?/area/.+?\)' _maps/**/*.dmm; then
part "window and wall stacking"
if $grep -U '"\w+" = \(\n[^)]*?/obj/structure/window[/\w]*?,\n[^)]*?/turf/closed[/\w]*?,\n[^)]*?/area/.+?\)' $map_files; then
echo
echo -e "${RED}ERROR: Found a window stacked within a wall, please remove it.${NC}"
st=1
fi;
if grep -Pzo '"\w+" = \(\n[^)]*?/obj/machinery/door/airlock[/\w]*?,\n[^)]*?/turf/closed[/\w]*?,\n[^)]*?/area/.+?\)' _maps/**/*.dmm; then
part "airlock and wall stacking"
if $grep -U '"\w+" = \(\n[^)]*?/obj/machinery/door/airlock[/\w]*?,\n[^)]*?/turf/closed[/\w]*?,\n[^)]*?/area/.+?\)' $map_files; then
echo
echo -e "${RED}ERROR: Found an airlock stacked within a wall, please remove it.${NC}"
st=1
fi;
if grep -Pzo '"\w+" = \(\n[^)]*?/obj/structure/stairs[/\w]*?,\n[^)]*?/turf/open/genturf[/\w]*?,\n[^)]*?/area/.+?\)' _maps/**/*.dmm; then
part "genturf with staircases"
if $grep -U '"\w+" = \(\n[^)]*?/obj/structure/stairs[/\w]*?,\n[^)]*?/turf/open/genturf[/\w]*?,\n[^)]*?/area/.+?\)' $map_files; then
echo
echo -e "${RED}ERROR: Found a staircase on top of a gen_turf. Please replace the gen_turf with a proper turf.${NC}"
st=1
fi;
if grep -Pzo '"\w+" = \(\n[^)]*?/obj/structure/grille,\n[^)]*?/obj/structure/cable,\n[^)]*?/area/.+\)' _maps/**/*.dmm; then
part "grilles on cables"
if $grep -U '"\w+" = \(\n[^)]*?/obj/structure/grille,\n[^)]*?/obj/structure/cable,\n[^)]*?/area/.+\)' $map_files; then
echo
echo -e "${RED}ERROR: Found a grille above a cable. Please replace with the proper structure spawner.${NC}"
st=1
fi;
if grep -Pzo '"\w+" = \(\n[^)]*?/obj/structure/cable,\n[^)]*?/obj/structure/grille,\n[^)]*?/area/.+\)' _maps/**/*.dmm; then
if $grep -U '"\w+" = \(\n[^)]*?/obj/structure/cable,\n[^)]*?/obj/structure/grille,\n[^)]*?/area/.+\)' $map_files; then
echo
echo -e "${RED}ERROR: Found a grille above a cable. Please replace with the proper structure spawner.${NC}"
st=1
fi;
if grep -Pzo '"\w+" = \(\n[^)]*?/obj/structure/grille,\n[^)]*?/obj/structure/window/reinforced/fulltile/ice,\n[^)]*?/area/.+\)' _maps/**/*.dmm; then
part "grille and window stacking"
if $grep -U '"\w+" = \(\n[^)]*?/obj/structure/grille,\n[^)]*?/obj/structure/window/reinforced/fulltile/ice,\n[^)]*?/area/.+\)' $map_files; then
echo
echo -e "${RED}ERROR: Found grille above a fulltile ice window. Please replace it with the proper structure spawner.${NC}"
st=1
fi;
if grep -Pzo '"\w+" = \(\n[^)]*?/obj/structure/grille,\n[^)]*?/obj/structure/window[/\w]*?fulltile,\n[^)]*?/area/.+\)' _maps/**/*.dmm; then
if $grep -U '"\w+" = \(\n[^)]*?/obj/structure/grille,\n[^)]*?/obj/structure/window[/\w]*?fulltile,\n[^)]*?/area/.+\)' $map_files; then
echo
echo -e "${RED}ERROR: Found grille above a fulltile window. Please replace it with the proper structure spawner.${NC}"
st=1
fi;
if grep -Pzo '"\w+" = \(\n[^)]*?/obj/structure/grille,\n[^)]*?/obj/structure/window/reinforced/plasma/plastitanium,\n[^)]*?/area/.+\)' _maps/**/*.dmm; then
if $grep -U '"\w+" = \(\n[^)]*?/obj/structure/grille,\n[^)]*?/obj/structure/window/reinforced/plasma/plastitanium,\n[^)]*?/area/.+\)' $map_files; then
echo
echo -e "${RED}ERROR: Found grille above a fulltile plastitanium window. Please replace it with the proper structure spawner.${NC}"
st=1
fi;
if grep -Pzo '/obj/machinery/conveyor/inverted[/\w]*?\{\n[^}]*?dir = [1248];[^}]*?\},?\n' _maps/**/*.dmm; then
part "converyor cardinals inversion"
if $grep -U '/obj/machinery/conveyor/inverted[/\w]*?[{]\n[^}]*?dir = [1248];[^}]*?[}],?\n' $map_files; then
echo
echo -e "${RED}ERROR: Found an inverted conveyor belt with a cardinal dir. Please replace it with a normal conveyor belt.${NC}"
st=1
fi;
if grep -P '^/area/.+[\{]' _maps/**/*.dmm; then
part "area varedits"
if $grep '^/area/.+[{]' $map_files; then
echo
echo -e "${RED}ERROR: Variable editted /area path use detected in a map, please replace with a proper area path.${NC}"
st=1
fi;
if grep -P '\/turf\s*[,\){]' _maps/**/*.dmm; then
part "base turf type"
if $grep '/turf\s*[,\){]' $map_files; then
echo
echo -e "${RED}ERROR: Base /turf path use detected in maps, please replace it with a proper turf path.${NC}"
st=1
fi;
if grep -Pzo '"\w+" = \(\n[^)]*?/turf/[/\w]*?,\n[^)]*?/turf/[/\w]*?,\n[^)]*?/area/.+?\)' _maps/**/*.dmm; then
part "multiple turfs"
if $grep -U '"\w+" = \(\n[^)]*?/turf/[/\w]*?,\n[^)]*?/turf/[/\w]*?,\n[^)]*?/area/.+?\)' $map_files; then
echo
echo -e "${RED}ERROR: Multiple turfs detected on the same tile! Please choose only one turf!${NC}"
st=1
fi;
if grep -Pzo '"\w+" = \(\n[^)]*?/area/.+?,\n[^)]*?/area/.+?\)' _maps/**/*.dmm; then
part "multiple areas"
if $grep -U '"\w+" = \(\n[^)]*?/area/.+?,\n[^)]*?/area/.+?\)' $map_files; then
echo
echo -e "${RED}ERROR: Multiple areas detected on the same tile! Please choose only one area!${NC}"
st=1
fi;
if grep -ni 'nanotransen' _maps/**/*.dmm; then
part "common spelling mistakes"
if $grep -i 'nanotransen' $map_files; then
echo
echo -e "${RED}ERROR: Misspelling of Nanotrasen detected in maps, please remove the extra N(s).${NC}"
st=1
fi;
if grep -i 'centcomm' _maps/**/*.dmm; then
if $grep -i'centcomm' $map_files; then
echo
echo -e "${RED}ERROR: Misspelling(s) of CentCom detected in maps, please remove the extra M(s).${NC}"
st=1
fi;
echo -e "${BLUE}Checking for whitespace issues...${NC}"
if grep -P '(^ {2})|(^ [^ * ])|(^ +)' code/**/*.dm; then
section "whitespace issues"
part "space indentation"
if $grep '(^ {2})|(^ [^ * ])|(^ +)' $code_files; then
echo
echo -e "${RED}ERROR: Space indentation detected, please use tab indentation.${NC}"
st=1
fi;
if grep -P '^\t+ [^ *]' code/**/*.dm; then
part "mixed indentation"
if $grep '^\t+ [^ *]' $code_files; then
echo
echo -e "${RED}ERROR: Mixed <tab><space> indentation detected, please stick to tab indentation.${NC}"
st=1
fi;
nl='
'
nl=$'\n'
while read f; do
t=$(tail -c2 "$f"; printf x); r1="${nl}$"; r2="${nl}${r1}"
if [[ ! ${t%x} =~ $r1 ]]; then
echo
echo -e "${RED}ERROR: file $f is missing a trailing newline.${NC}"
st=1
fi;
done < <(find . -type f -name '*.dm')
echo -e "${BLUE}Checking for common mistakes...${NC}"
if grep -P 'to_chat\((?!.*,).*\)' code/**/*.dm; then
echo
echo -e "${RED}ERROR: to_chat() missing arguments.${NC}"
st=1
fi;
if grep -P 'addtimer\((?=.*TIMER_OVERRIDE)(?!.*TIMER_UNIQUE).*\)' code/**/*.dm; then
echo
echo -e "${RED}ERROR: TIMER_OVERRIDE used without TIMER_UNIQUE.${NC}"
st=1
fi;
if grep -P '^/*var/' code/**/*.dm; then
section "common mistakes"
part "global vars"
if $grep '^/*var/' $code_files; then
echo
echo -e "${RED}ERROR: Unmanaged global var use detected in code, please use the helpers.${NC}"
st=1
fi;
if grep -P '^/[\w/]\S+\(.*(var/|, ?var/.*).*\)' code/**/*.dm; then
part "proc args with var/"
if $grep '^/[\w/]\S+\(.*(var/|, ?var/.*).*\)' $code_files; then
echo
echo -e "${RED}ERROR: Changed files contains a proc argument starting with 'var'.${NC}"
st=1
fi;
if grep 'balloon_alert\(".+"\)' code/**/*.dm; then
part "balloon_alert sanity"
if $grep 'balloon_alert\(".+"\)' $code_files; then
echo
echo -e "${RED}ERROR: Found a balloon alert with improper arguments.${NC}"
st=1
fi;
if grep -i 'centcomm' code/**/*.dm; then
part "common spelling mistakes"
if $grep -i 'centcomm' $code_files; then
echo
echo -e "${RED}ERROR: Misspelling(s) of CentCom detected in code, please remove the extra M(s).${NC}"
st=1
fi;
if grep -ni 'nanotransen' code/**/*.dm; then
if $grep -ni 'nanotransen' $code_files; then
echo
echo -e "${RED}ERROR: Misspelling(s) of Nanotrasen detected in code, please remove the extra N(s).${NC}"
st=1
fi;
if ls _maps/*.json | grep -P "[A-Z]"; then
part "map json naming"
if ls _maps/*.json | $grep "[A-Z]"; then
echo
echo -e "${RED}ERROR: Uppercase in a map .JSON file detected, these must be all lowercase.${NC}"
st=1
fi;
if grep -i '/obj/effect/mapping_helpers/custom_icon' _maps/**/*.dmm; then
part "custom icon helpers"
if $grep -i '/obj/effect/mapping_helpers/custom_icon' $map_files; then
echo
echo -e "${RED}ERROR: Custom icon helper found. Please include DMI files as standard assets instead for repository maps.${NC}"
st=1
fi;
if grep -P '^/obj/docking_port/mobile.*\{\n[^}]*(width|height|dwidth|dheight)[^}]*\}' _maps/**/*.dmm; then
echo
echo -e "${RED}ERROR: Custom mobile docking_port sizes detected. This is done automatically and should not be varedits.${NC}"
st=1
fi;
part "map json sanity"
for json in _maps/*.json
do
map_path=$(jq -r '.map_path' $json)
@@ -308,16 +302,103 @@ do
done < <(jq -r '[.map_file] | flatten | .[]' $json)
done
# Check for non-515 compatable .proc/ syntax
if grep -P --exclude='__byond_version_compat.dm' '\.proc/' code/**/*.dm; then
section "515 Proc Syntax"
part "proc ref syntax"
if $grep '\.proc/' $code_files $ignore_515_proc_marker; then
echo
echo -e "${RED}ERROR: Outdated proc reference use detected in code, please use proc reference helpers.${NC}"
st=1
fi;
if [ "$pcre2_support" -eq 1 ]; then
section "regexes requiring PCRE2"
part "multiple pipes"
if $grep -PU '"\w+" = \(\n[^)]*?/obj/machinery/atmospherics/pipe/(?<type>[/\w]*),\n[^)]*?/obj/machinery/atmospherics/pipe/\g{type},\n[^)]*?/area/.+\)' $map_files; then
echo
echo -e "${RED}ERROR: Found multiple identical pipes on the same tile, please remove them.${NC}"
st=1
fi;
part "multiple barricades"
if $grep -PU '"\w+" = \(\n[^)]*?/obj/structure/barricade(?<type>[/\w]*),\n[^)]*?/obj/structure/barricade\g{type},\n[^)]*?/area/.+\)' $map_files; then
echo
echo -e "${RED}ERROR: Found multiple identical barricades on the same tile, please remove them.${NC}"
st=1
fi;
part "multiple tables"
if $grep -PU '"\w+" = \(\n[^)]*?/obj/structure/table(?<type>[/\w]*),\n[^)]*?/obj/structure/table\g{type},\n[^)]*?/area/.+\)' $map_files; then
echo
echo -e "${RED}ERROR: Found multiple identical tables on the same tile, please remove them.${NC}"
st=1
fi;
part "multiple closets"
if $grep -PU '"\w+" = \(\n[^)]*?/obj/structure/closet(?<type>[/\w]*),\n[^)]*?/obj/structure/closet\g{type},\n[^)]*?/area/.+\)' $map_files; then
echo
echo -e "${RED}ERROR: Found multiple identical closets on the same tile, please remove them.${NC}"
st=1
fi;
part "multiple grilles"
if $grep -PU '"\w+" = \(\n[^)]*?/obj/structure/grille(?<type>[/\w]*),\n[^)]*?/obj/structure/grille/\g{type},\n[^)]*?/area/.+\)' $map_files; then
echo
echo -e "${RED}ERROR: Found multiple identical grilles on the same tile, please remove them.${NC}"
st=1
fi;
part "multiple girders"
if $grep -PU '"\w+" = \(\n[^)]*?/obj/structure/girder(?<type>[/\w]*),\n[^)]*?/obj/structure/girder\g{type},\n[^)]*?/area/.+\)' $map_files; then
echo
echo -e "${RED}ERROR: Found multiple identical girders on the same tile, please remove them.${NC}"
st=1
fi;
part "multiple stairs"
if $grep -PU '"\w+" = \(\n[^)]*?/obj/structure/stairs/(?<type>[/\w]*),\n[^)]*?/obj/structure/stairs/\g{type},\n[^)]*?/area/.+\)' $map_files; then
echo
echo -e "${RED}ERROR: Found multiple identical stairs on the same tile, please remove them.${NC}"
st=1
fi;
part "door names"
if $grep -PU '/obj/machinery/door.*{([^}]|\n)*name = .*("|\s)(?!of|and|to)[a-z].*\n' $map_files; then
echo
echo -e "${RED}ERROR: Found door names without proper upper-casing. Please upper-case your door names.${NC}"
st=1
fi;
part "multiple chairs"
if $grep -PU '"\w+" = \(\n[^)]*?/obj/structure/chair(?<type>[/\w]*),\n[^)]*?/obj/structure/chair\g{type},\n[^)]*?/area/.+\)' $map_files; then
echo
echo -e "${RED}ERROR: Found multiple identical chairs on the same tile, please remove them.${NC}"
st=1
fi;
part "to_chat sanity"
if $grep -P 'to_chat\((?!.*,).*\)' $code_files; then
echo
echo -e "${RED}ERROR: to_chat() missing arguments.${NC}"
st=1
fi;
part "timer flag sanity"
if $grep -P 'addtimer\((?=.*TIMER_OVERRIDE)(?!.*TIMER_UNIQUE).*\)' $code_files; then
echo
echo -e "${RED}ERROR: TIMER_OVERRIDE used without TIMER_UNIQUE.${NC}"
st=1
fi
part "trailing newlines"
if $grep -PU '[^\n]$(?!\n)' $code_files; then
echo
echo -e "${RED}ERROR: File(s) with no trailing newline detected, please add one.${NC}"
st=1
fi
part "docking_port varedits"
if $grep -PU '^/obj/docking_port/mobile.*\{\n[^}]*(width|height|dwidth|dheight)[^}]*[}]' $map_files; then
echo
echo -e "${RED}ERROR: Custom mobile docking_port sizes detected. This is done automatically and should not be varedits."
echo -e "\t\tPlease remove the width, height, dwidth, and dheight varedits from the docking_port.${NC}"
st=1
fi;
else
echo -e "${RED}pcre2 not supported, skipping checks requiring pcre2"
echo -e "if you want to run these checks install ripgrep with pcre2 support.${NC}"
fi
if [ $st = 0 ]; then
echo
echo -e "${GREEN}No errors found using grep!${NC}"
echo -e "${GREEN}No errors found using $grep!${NC}"
fi;
if [ $st = 1 ]; then