Buckets:

download
raw
1.21 kB
"""Simple linting fallback and small checks for diffs/snippets.
This module tries to provide quick deterministic lint-like findings without
relying on external tools. If a real linter (e.g. ruff) is installed and on
PATH, we can extend to call it; for now we provide conservative, fast checks.
"""
from __future__ import annotations
from typing import List, Dict, Any
def run_basic_lint(code: str) -> List[Dict[str, Any]]:
findings: List[Dict[str, Any]] = []
for i, ln in enumerate(code.splitlines(), start=1):
if len(ln) > 120:
findings.append({"type": "long_line", "message": "Line exceeds 120 characters", "line": i, "severity": "low"})
if ln.endswith(" "):
findings.append({"type": "trailing_whitespace", "message": "Trailing whitespace", "line": i, "severity": "low"})
if "import *" in ln:
findings.append({"type": "wildcard_import", "message": "Wildcard import found; avoid using import *", "line": i, "severity": "medium"})
# detect obvious 'eval(' calls
if "eval(" in code:
findings.append({"type": "unsafe_eval", "message": "Use of eval() detected; this can be dangerous", "severity": "high"})
return findings

Xet Storage Details

Size:
1.21 kB
·
Xet hash:
ba388f2ae761b553abb64494ca283b2ec704ad6c94b8d51f8c7c40f27aaa4b37

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.