Run the Rust linter and return results in the Python linter shape.
(files: list[str] | None)
| 92 | |
| 93 | |
| 94 | def run_rust_linter(files: list[str] | None) -> dict[str, CheckerResults]: |
| 95 | """Run the Rust linter and return results in the Python linter shape.""" |
| 96 | cmd = [ |
| 97 | "soldr", |
| 98 | "cargo", |
| 99 | "run", |
| 100 | "--release", |
| 101 | "--bin", |
| 102 | "fastled-lint", |
| 103 | "--manifest-path", |
| 104 | "ci/lint_cpp_rs/Cargo.toml", |
| 105 | "--", |
| 106 | "--format", |
| 107 | "json", |
| 108 | "--project-root", |
| 109 | str(PROJECT_ROOT), |
| 110 | ] |
| 111 | |
| 112 | if files: |
| 113 | cmd.extend(files) |
| 114 | |
| 115 | result = RunningProcess.run( |
| 116 | cmd, |
| 117 | cwd=str(PROJECT_ROOT), |
| 118 | capture_output=True, |
| 119 | check=False, |
| 120 | timeout=300, |
| 121 | ) |
| 122 | |
| 123 | if result.stderr: |
| 124 | print( |
| 125 | result.stderr, |
| 126 | file=sys.stderr, |
| 127 | end="" if result.stderr.endswith("\n") else "\n", |
| 128 | ) |
| 129 | |
| 130 | if result.returncode not in (0, 1): |
| 131 | raise RuntimeError( |
| 132 | "Rust C++ linter failed before producing lint results " |
| 133 | f"(exit {result.returncode})" |
| 134 | ) |
| 135 | |
| 136 | raw_violations = parse_rust_json_output(result.stdout) |
| 137 | |
| 138 | return _violations_to_results(raw_violations) |
| 139 | |
| 140 | |
| 141 | def parse_rust_json_output(stdout: str | None) -> list[dict[str, Any]]: |
no test coverage detected