Skip to content

Commit

Permalink
Tf
Browse files Browse the repository at this point in the history
  • Loading branch information
Furrior committed Apr 2, 2024
1 parent 6e6e23b commit cf2c36f
Show file tree
Hide file tree
Showing 48 changed files with 929 additions and 159 deletions.
8 changes: 0 additions & 8 deletions .github/workflows/ci_suite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,6 @@ jobs:
key: ${{ runner.os }}-rust-${{ hashFiles('tools/ci/ci_dependencies.sh')}}
restore-keys: |
${{ runner.os }}-rust-
- name: Restore Cutter cache
uses: actions/cache@v4
with:
path: tools/icon_cutter/cache
key: ${{ runner.os }}-cutter-${{ hashFiles('dependencies.sh') }}
- name: Install Tools
Expand Down Expand Up @@ -91,9 +86,6 @@ jobs:
run: |
tools/bootstrap/python -m mapmerge2.dmm_test
tools/bootstrap/python -m tools.maplint.source
- name: Check Cutter
if: steps.linter-setup.conclusion == 'success' && !cancelled()
run: tools/bootstrap/python -m tools.icon_cutter.check
- name: Run DMI Tests
if: steps.linter-setup.conclusion == 'success' && !cancelled()
run: tools/bootstrap/python -m dmi.test
Expand Down
23 changes: 0 additions & 23 deletions tools/icon_cutter/README.md

This file was deleted.

1 change: 0 additions & 1 deletion tools/icon_cutter/cache/.gitignore

This file was deleted.

127 changes: 0 additions & 127 deletions tools/icon_cutter/check.py

This file was deleted.

132 changes: 132 additions & 0 deletions tools/maplint/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
# maplint
maplint is a tool that lets you prohibit anti-patterns in maps through simple rules. You can use maplint to do things like ban variable edits for specific types, ban specific variable edits, ban combinations of types, etc.

## Making lints

To create a lint, create a new file in the `lints` folder. Lints use [YAML](https://learnxinyminutes.com/docs/yaml/), which is very expressive, though can be a little complex. If you get stuck, read other lints in this folder.

### Typepaths
The root of the file is your typepaths. This will match not only that type, but also subtypes. For example:

```yml
/mob/dog:
# We'll get to this...
```

...will define rules for `/mob/dog`, `/mob/dog/corgi`, `/mob/dog/beagle`, etc.

If you only want to match a specific typepath, prefix it with `=`. This:

```yml
=/mob/dog:
```
...will only match `/mob/dog` specifically.

Alternatively, if you want to match ALL types, enter a single `*`, for wildcard.

### `banned`
The simplest rule is to completely ban a subtype. To do this, fill with `banned: true`.

For example, this lint will ban `/mob/dog` and all subtypes:

```yml
/mob/dog:
banned: true # Cats FTW
```

### `banned_neighbors`
If you want to ban other objects being on the same tile as another, you can specify `banned_neighbors`.

This takes a few forms. The simplest is just a list of types to not be next to. This lint will ban either cat_toy *or* cat_food (or their subtypes) from being on the same tile as a dog.

```yml
/mob/dog:
banned_neighbors:
- /obj/item/cat_toy
- /obj/item/cat_food
```

This also supports the `=` format as specified before. This will ban `/mob/dog` being on the same tile as `/obj/item/toy` *only*.

```yml
/mob/dog:
banned_neighbors:
- =/obj/item/toy # Only the best toys for our dogs
```

Anything in this list will *not* include the object itself, meaning you can use it to make sure two of the same object are not on the same tile. For example, this lint will ban two dogs from being on the same tile:

```yml
/mob/dog:
banned_neighbors:
- /mob/dog # We're a space station, not a dog park!
```

However, you can add a bit more specificity with `identical: true`. This will prohibit other instances of the *exact* same type *and* variable edits from being on the same tile.

```yml
/mob/dog:
banned_neighbors:
# Purebreeds are unnatural! We're okay with dogs as long as they're different.
/mob/dog: { identical: true }
```

Finally, if you need maximum precision, you can specify a [regular expression](https://en.wikipedia.org/wiki/Regular_expression) to match for a path. If we wanted to ban a `/mob/dog` from being on the same tile as `/obj/bowl/big/cat`, `/obj/bowl/small/cat`, etc, we can write:

```yml
/mob/dog:
banned_neighbors:
CAT_BOWLS: { pattern: ^/obj/bowl/.+/cat$ }
```

### `banned_variables`
To ban all variable edits, you can specify `banned_variables: true` for a typepath. For instance, if we want to block dogs from getting any var-edits, we can write:

```yml
/mob/dog:
banned_variables: true # No var edits, no matter what
```

If we want to be more specific, we can write out the specific variables we want to ban.

```yml
/mob/dog
banned_variables:
- species # Don't var-edit species, use the subtypes
```

We can also explicitly create allowlists and denylists of values through `allow` and `deny`. For example, if we want to make sure we're not creating invalid bowls for animals, we can write:

```yml
/obj/bowl/dog:
banned_variables:
species:
# If we specify a species, it's gotta be a dog
allow: ["beagle", "corgi", "pomeranian"]
/obj/bowl/humans:
banned_variables:
species:
# We're civilized, we don't want to eat from the same bowl that's var-edited for animals
deny: ["cats", "dogs"]
```

Similar to [banned_neighbors](#banned_neighbors), you can specify a regular expression pattern for allow/deny.

```yml
/mob/dog:
banned_variables:
# Names must start with a capital letter
name:
allow: { pattern: '^[A-Z].*$' }
```

### `help`
If you want a custom message to go with your lint, you can specify "help" in the root.

```yml
help: Pugs haven't existed on Sol since 2450.
/mob/dog/pug:
banned: true
```
3 changes: 3 additions & 0 deletions tools/maplint/lints/admin_library_computer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
help: This typepath exists to make an admin verb work, it should not be placed on maps
/obj/machinery/computer/libraryconsole/admin_only_do_not_map_in_you_fucker:
banned: true # Please don't man I swear to god
7 changes: 7 additions & 0 deletions tools/maplint/lints/apc_pixel_shifts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
help: "Use the directional variants when possible."
/obj/machinery/power/apc:
banned_variables:
pixel_x:
allow: [25, -25]
pixel_y:
allow: [25, -25]
3 changes: 3 additions & 0 deletions tools/maplint/lints/area_varedits.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
help: "Please replace it with a proper area path."
/area:
banned_variables: true
2 changes: 2 additions & 0 deletions tools/maplint/lints/base_turf.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
=/turf:
banned: true
7 changes: 7 additions & 0 deletions tools/maplint/lints/cable_varedits.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/obj/structure/cable:
banned_variables: true

/obj/structure/pipe_cleaner:
banned_variables:
- d1
- d2
6 changes: 6 additions & 0 deletions tools/maplint/lints/colorless_decals.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
help: Colorless turf_decal detected! Please delete it or replace it with the desired colored subtype.
=/obj/effect/turf_decal/tile:
banned: TRUE

=/obj/effect/turf_decal/trimline:
banned: TRUE
5 changes: 5 additions & 0 deletions tools/maplint/lints/conveyor_cardinal_inversion.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
help: "Please replace it with a normal conveyor belt."
/obj/machinery/conveyor/inverted:
banned_variables:
dir:
deny: [1, 2, 4, 8]
3 changes: 3 additions & 0 deletions tools/maplint/lints/custom_icon_helper.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
help: "Please include DMI files as standard assets instead for repository maps."
/obj/effect/mapping_helpers/custom_icon:
banned: true
7 changes: 7 additions & 0 deletions tools/maplint/lints/docking_port_varedits.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
help: "Custom mobile docking_port sizes detected. This is done automatically and should not be varedits."
/obj/docking_port/mobile:
banned_variables:
- width
- height
- dwidth
- dheight
5 changes: 5 additions & 0 deletions tools/maplint/lints/door_name_capitalization.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
help: "Please upper-case your door names."
/obj/machinery/door:
banned_variables:
name:
deny: { pattern: '.*\s(?!of|and|to)[a-z].*' }
7 changes: 7 additions & 0 deletions tools/maplint/lints/grille_stacking.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
help: "Please replace with the proper structure spawner."
=/obj/structure/grille:
banned_neighbors:
/obj/structure/cable:
/obj/structure/window/reinforced/plasma/plastitanium:
FULLTILE_WINDOW:
pattern: ^/obj/structure/window[/\w]*?fulltile$
4 changes: 4 additions & 0 deletions tools/maplint/lints/heat_capacity.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
help: "Do not override heat_capacity, you must use a custom subtype."
/turf:
banned_variables:
- heat_capacity
4 changes: 4 additions & 0 deletions tools/maplint/lints/identical_barricades.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/obj/structure/barricade:
banned_neighbors:
/obj/structure/barricade:
identical: true
4 changes: 4 additions & 0 deletions tools/maplint/lints/identical_pipes.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/obj/machinery/atmospherics/pipe:
banned_neighbors:
/obj/machinery/atmospherics/pipe:
identical: true
5 changes: 5 additions & 0 deletions tools/maplint/lints/merge_conflict_marker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
help:
This means you didn't clean up any potential merge conflicts,
make sure everything in that area is correct.
/obj/merge_conflict_marker:
banned: true
3 changes: 3 additions & 0 deletions tools/maplint/lints/multiple_airlocks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/obj/machinery/door/airlock:
banned_neighbors:
- /obj/machinery/door/airlock
Loading

0 comments on commit cf2c36f

Please sign in to comment.