(evidence: list[dict[str, Any]])
| 172 | |
| 173 | |
| 174 | def _code_evidence_lines(evidence: list[dict[str, Any]]) -> list[str]: |
| 175 | lines: list[str] = [] |
| 176 | for index, item in enumerate(evidence): |
| 177 | label = _text(item.get("label"), f"Code evidence {index + 1}") |
| 178 | location = _text(_code_evidence_location(item), "") |
| 179 | explanation = _text(item.get("explanation"), "") |
| 180 | language = item.get("language") if isinstance(item.get("language"), str) else "" |
| 181 | language = language if re.fullmatch(r"[A-Za-z0-9_+.-]*", language) else "" |
| 182 | code = item["code"] |
| 183 | fence = _code_fence(code) |
| 184 | heading = f"**{label}**" |
| 185 | if location: |
| 186 | heading += f" — `{location}`" |
| 187 | lines.extend(["", heading]) |
| 188 | if explanation: |
| 189 | lines.extend(["", explanation]) |
| 190 | lines.extend(["", f"{fence}{language}", code, fence]) |
| 191 | return lines |
| 192 | |
| 193 | |
| 194 | def _severity_mix(findings: list[dict[str, Any]]) -> str: |
no test coverage detected