INNER CODE UNIT · Python

_stream_issues_from_file

f-droid/fdroidclient · tools/checkstyle-to-codeclimate.py:106

def _stream_issues_from_file(
    path: pathlib.Path, base_dir: Optional[str]
) -> Iterator[Issue]:
    """Memory-efficient streaming parser using iterparse.

    We use start/end events to track the current <file> context and emit issues
    when encountering <error> end events. Elements are cleared after their
    subtrees are processed to free memory for very large reports.
    """
    current_file: Optional[str] = None
    rel_file: Optional[str] = None
    for event, elem in ET.iterparse(str(path), events=("start", "end")):
        if event == "start" and elem.tag == "file":
            current_file = elem.get("name") or None
            if current_file:
                rel_file = _relativize(current_file, base_dir)
        elif event == "end" and elem.tag == "error" and current_file and rel_file:
            line = elem.get("line") or "1"

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…