MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / strip_noise

Function strip_noise

scripts/lint-mem-gate.py:53–85  ·  view source on GitHub ↗

Blank out string/char literals and comments so brace counting is sane.

(text)

Source from the content-addressed store, hash-verified

51
52
53def strip_noise(text):
54 """Blank out string/char literals and comments so brace counting is sane."""
55 out = []
56 i, n = 0, len(text)
57 while i < n:
58 c = text[i]
59 if c == "/" and i + 1 < n and text[i + 1] == "/":
60 while i < n and text[i] != "\n":
61 out.append(" ")
62 i += 1
63 elif c == "/" and i + 1 < n and text[i + 1] == "*":
64 while i + 1 < n and not (text[i] == "*" and text[i + 1] == "/"):
65 out.append("\n" if text[i] == "\n" else " ")
66 i += 1
67 out.append(" ")
68 i += 2
69 elif c in "\"&#x27;":
70 quote = c
71 out.append(" ")
72 i += 1
73 while i < n and text[i] != quote:
74 if text[i] == "\\":
75 out.append(" ")
76 i += 1
77 if i < n:
78 out.append("\n" if text[i] == "\n" else " ")
79 i += 1
80 out.append(" ")
81 i += 1
82 else:
83 out.append(c)
84 i += 1
85 return "".join(out)
86
87
88def function_spans(path):

Callers 1

function_spansFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected