MCPcopy Create free account
hub / github.com/idank/explainshell / _suspicious_changes

Function _suspicious_changes

tests/evals/render/render_eval.py:264–334  ·  view source on GitHub ↗
(
    path: str, old: dict[str, Any] | None, new: dict[str, Any] | None
)

Source from the content-addressed store, hash-verified

262
263
264def _suspicious_changes(
265 path: str, old: dict[str, Any] | None, new: dict[str, Any] | None
266) -> list[str]:
267 if old is None:
268 return ["page added"]
269 if new is None:
270 return ["page removed"]
271
272 reasons: list[str] = []
273 # All thresholds 0.0: any non-zero delta surfaces the page. Cheap
274 # structural metrics rarely move by accident, so false positives are
275 # tolerable and small structural improvements are exactly what we want
276 # flagged.
277 checks = {
278 "markdown.max_line_length": 0.0,
279 "markdown.giant_lines_500": 0.0,
280 "markdown.giant_lines_1000": 0.0,
281 "markdown.max_option_like_tokens_on_line": 0.0,
282 "markdown.unescaped_star_runs": 0.0,
283 "markdown.unescaped_under_runs": 0.0,
284 "markdown.char_count": 0.02,
285 "filtered.line_count": 0.0,
286 "html.tags.a": 0.0,
287 "html.tags.blockquote": 0.0,
288 "html.tags.br": 0.0,
289 "html.tags.code": 0.0,
290 "html.tags.em": 0.0,
291 "html.tags.h1": 0.0,
292 "html.tags.h2": 0.0,
293 "html.tags.h3": 0.0,
294 "html.tags.h4": 0.0,
295 "html.tags.h5": 0.0,
296 "html.tags.h6": 0.0,
297 "html.tags.li": 0.0,
298 "html.tags.pre": 0.0,
299 "html.tags.strong": 0.0,
300 "html.tags.tr": 0.0,
301 "html.tags.ul": 0.0,
302 "html.tags.ol": 0.0,
303 "html.tags.p": 0.0,
304 "html.data_chars": 0.02,
305 "html.chars.\\": 0.0,
306 "html.chars.[": 0.0,
307 "html.chars.]": 0.0,
308 "html.chars.*": 0.0,
309 "html.chars._": 0.0,
310 "html.chars.`": 0.0,
311 "html.chars.<": 0.0,
312 "html.chars.>": 0.0,
313 }
314 for key, tolerance in checks.items():
315 before = _get_metric(old, key)
316 after = _get_metric(new, key)
317 delta = after - before
318 if delta == 0:
319 continue
320 if tolerance == 0.0:
321 reasons.append(f"{key}: {before} -> {after} ({delta:+})")

Callers 1

_comparison_dataFunction · 0.85

Calls 1

_get_metricFunction · 0.90

Tested by

no test coverage detected