(root: Path)
| 51 | |
| 52 | |
| 53 | def audit(root: Path) -> List[Finding]: |
| 54 | findings: List[Finding] = [] |
| 55 | for file_path in sorted(iter_files(root)): |
| 56 | if not file_path.is_file(): |
| 57 | continue |
| 58 | rel = file_path.relative_to(root) |
| 59 | text = file_path.read_text(encoding="utf-8", errors="ignore") |
| 60 | for idx, line in enumerate(text.splitlines(), start=1): |
| 61 | if should_ignore_line(line): |
| 62 | continue |
| 63 | |
| 64 | for match in ABS_CN1_RE.finditer(line): |
| 65 | url = match.group(0) |
| 66 | findings.append( |
| 67 | Finding( |
| 68 | kind="ABSOLUTE_CN1_URL", |
| 69 | file=rel, |
| 70 | line_no=idx, |
| 71 | url=url, |
| 72 | suggestion=suggestion_for_abs(url), |
| 73 | ) |
| 74 | ) |
| 75 | |
| 76 | wp_match = WP_RE.search(line) |
| 77 | if wp_match: |
| 78 | findings.append( |
| 79 | Finding( |
| 80 | kind="WORDPRESS_URL", |
| 81 | file=rel, |
| 82 | line_no=idx, |
| 83 | url=wp_match.group(0), |
| 84 | suggestion="Replace with current migrated site path/resource.", |
| 85 | ) |
| 86 | ) |
| 87 | return findings |
| 88 | |
| 89 | |
| 90 | def write_report(findings: List[Finding], report_file: Path) -> None: |
no test coverage detected