Assign a ranking tier to a file path. Lower tier = higher priority. Source implementation files rank above tests, config, build scripts, docs, and generated files.
(path: &str)
| 243 | /// Lower tier = higher priority. Source implementation files rank above |
| 244 | /// tests, config, build scripts, docs, and generated files. |
| 245 | fn path_tier(path: &str) -> usize { |
| 246 | // Tier 0: primary source directories |
| 247 | let source_prefixes = ["src/", "lib/", "pkg/", "internal/", "cmd/", "app/"]; |
| 248 | for prefix in &source_prefixes { |
| 249 | if path.starts_with(prefix) { |
| 250 | // Demote test files even within src/ |
| 251 | if is_test_path(path) { |
| 252 | return 2; |
| 253 | } |
| 254 | return 0; |
| 255 | } |
| 256 | } |
| 257 | |
| 258 | // Tier 1: other code files (root-level .rs/.py/.cpp etc.) |
| 259 | let code_extensions = [ |
| 260 | ".rs", ".go", ".py", ".ts", ".js", ".cpp", ".cc", ".c", ".h", ".hpp", ".java", ".kt", |
| 261 | ".swift", ".rb", ".cs", |
| 262 | ]; |
| 263 | if code_extensions.iter().any(|ext| path.ends_with(ext)) { |
| 264 | if is_test_path(path) { |
| 265 | return 2; |
| 266 | } |
| 267 | return 1; |
| 268 | } |
| 269 | |
| 270 | // Tier 2: test files |
| 271 | if is_test_path(path) { |
| 272 | return 2; |
| 273 | } |
| 274 | |
| 275 | // Tier 3: docs and markdown |
| 276 | if path.ends_with(".md") || path.starts_with("docs/") || path.starts_with("doc/") { |
| 277 | return 3; |
| 278 | } |
| 279 | |
| 280 | // Tier 4: build scripts, config, CI, generated files |
| 281 | let low_priority = [ |
| 282 | "buildscripts/", |
| 283 | "build/", |
| 284 | ".github/", |
| 285 | "ci/", |
| 286 | "scripts/", |
| 287 | "debian/", |
| 288 | "rpm/", |
| 289 | "packaging/", |
| 290 | "vendor/", |
| 291 | "third_party/", |
| 292 | "node_modules/", |
| 293 | "target/", |
| 294 | ]; |
| 295 | if low_priority.iter().any(|p| path.starts_with(p)) { |
| 296 | return 4; |
| 297 | } |
| 298 | if path.ends_with(".yml") |
| 299 | || path.ends_with(".yaml") |
| 300 | || path.ends_with(".toml") |
| 301 | || path.ends_with(".json") |
| 302 | || path.ends_with(".xml") |
no test coverage detected