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)
| 132 | /// Lower tier = higher priority. Source implementation files rank above |
| 133 | /// tests, config, build scripts, docs, and generated files. |
| 134 | fn path_tier(path: &str) -> usize { |
| 135 | // Tier 0: primary source directories |
| 136 | let source_prefixes = ["src/", "lib/", "pkg/", "internal/", "cmd/", "app/"]; |
| 137 | for prefix in &source_prefixes { |
| 138 | if path.starts_with(prefix) { |
| 139 | // Demote test files even within src/ |
| 140 | if is_test_path(path) { |
| 141 | return 2; |
| 142 | } |
| 143 | return 0; |
| 144 | } |
| 145 | } |
| 146 | |
| 147 | // Tier 1: other code files (root-level .rs/.py/.cpp etc.) |
| 148 | let code_extensions = [ |
| 149 | ".rs", ".go", ".py", ".ts", ".js", ".cpp", ".cc", ".c", ".h", ".hpp", ".java", ".kt", |
| 150 | ".swift", ".rb", ".cs", |
| 151 | ]; |
| 152 | if code_extensions.iter().any(|ext| path.ends_with(ext)) { |
| 153 | if is_test_path(path) { |
| 154 | return 2; |
| 155 | } |
| 156 | return 1; |
| 157 | } |
| 158 | |
| 159 | // Tier 2: test files |
| 160 | if is_test_path(path) { |
| 161 | return 2; |
| 162 | } |
| 163 | |
| 164 | // Tier 3: docs and markdown |
| 165 | if path.ends_with(".md") || path.starts_with("docs/") || path.starts_with("doc/") { |
| 166 | return 3; |
| 167 | } |
| 168 | |
| 169 | // Tier 4: build scripts, config, CI, generated files |
| 170 | let low_priority = [ |
| 171 | "buildscripts/", |
| 172 | "build/", |
| 173 | ".github/", |
| 174 | "ci/", |
| 175 | "scripts/", |
| 176 | "debian/", |
| 177 | "rpm/", |
| 178 | "packaging/", |
| 179 | "vendor/", |
| 180 | "third_party/", |
| 181 | "node_modules/", |
| 182 | "target/", |
| 183 | ]; |
| 184 | if low_priority.iter().any(|p| path.starts_with(p)) { |
| 185 | return 4; |
| 186 | } |
| 187 | if path.ends_with(".yml") |
| 188 | || path.ends_with(".yaml") |
| 189 | || path.ends_with(".toml") |
| 190 | || path.ends_with(".json") |
| 191 | || path.ends_with(".xml") |
no test coverage detected