Skip to content

Commit

Permalink
let's try this
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkSuckerberg committed Jan 7, 2024
1 parent 3960ce7 commit 5288987
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
2 changes: 1 addition & 1 deletion tools/maplint/lints/identical_pipes.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/obj/machinery/atmospherics/pipe:
banned_neighbors:
/obj/machinery/atmospherics/pipe:
identical: true
matching_vars: [dir, piping_layer]
2 changes: 1 addition & 1 deletion tools/maplint/lints/multiple_cables.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/obj/structure/cable:
banned_neighbors:
/obj/structure/cable:
identical: true
matching_vars: [dir]
4 changes: 4 additions & 0 deletions tools/maplint/lints/multiple_windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/obj/structure/window:
banned_neighbors:
/obj/structure/window:
identical: true
15 changes: 15 additions & 0 deletions tools/maplint/source/lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class BannedNeighbor:
identical: bool = False
typepath: Optional[TypepathExtra] = None
pattern: Optional[re.Pattern] = None
matching_vars: list[str] = []

def __init__(self, typepath, data = {}):
if typepath.upper() != typepath:
Expand All @@ -59,12 +60,26 @@ def __init__(self, typepath, data = {}):
self.identical = data.pop("identical")
expect(isinstance(self.identical, bool), "identical must be a boolean.")

if "matching_vars" in data:
self.same_dir = data.pop("matching_vars")
expect(isinstance(self.matching_vars, list), "matching_vars must be a list of variables.")

if "pattern" in data:
self.pattern = re.compile(data.pop("pattern"))

expect(len(data) == 0, f"Unknown key in banned neighbor: {', '.join(data.keys())}.")

def matches(self, identified: Content, neighbor: Content):
if len(self.matching_vars) > 0:
if not self.typepath.matches_path(neighbor.path):
return False

for variable in self.matching_vars:
if identified.var_edits[variable] != neighbor.var_edits[variable]:
return False

return True

if self.identical:
if identified.path != neighbor.path:
return False
Expand Down

0 comments on commit 5288987

Please sign in to comment.