mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-18 17:42:59 +00:00
design-lint: source sites use the root without the verbatim prefix and '/' separators; restore the trial-rooms exception; tests compare '/' paths
This commit is contained in:
Generated
+1
@@ -2199,6 +2199,7 @@ dependencies = [
|
||||
name = "craft-design-lint"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"dunce",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"serde",
|
||||
|
||||
@@ -10,6 +10,7 @@ repository.workspace = true
|
||||
publish = false
|
||||
|
||||
[dependencies]
|
||||
dunce = "1"
|
||||
proc-macro2 = { version = "1", features = ["span-locations"] }
|
||||
quote = "1"
|
||||
serde = { workspace = true }
|
||||
|
||||
@@ -88,7 +88,8 @@ fn unknown_crates(root: &Path, meta: &Metadata, maps: &LayerMaps) -> Vec<Finding
|
||||
|
||||
fn source_sites(root: &Path, index: &Index) -> Vec<Site> {
|
||||
// Source paths come from cargo metadata, which resolves `..` and links; the root must be resolved the same way.
|
||||
let root = &std::fs::canonicalize(root).unwrap_or_else(|_| root.to_owned());
|
||||
// `dunce` drops the `\\?\` prefix Windows' canonical paths carry, which metadata's paths lack.
|
||||
let root = &dunce::canonicalize(root).unwrap_or_else(|_| root.to_owned());
|
||||
let mut sites = Vec::new();
|
||||
for tree in index.trees.values() {
|
||||
let mut files: Vec<&PathBuf> = tree.modules.values().map(|m| &m.file).collect();
|
||||
@@ -96,7 +97,7 @@ fn source_sites(root: &Path, index: &Index) -> Vec<Site> {
|
||||
files.dedup();
|
||||
for file in files {
|
||||
if let Some(parsed) = index.files.get(file) {
|
||||
sites.extend(scan_parsed(&relative(root, file).to_string_lossy(), &parsed.src, Some(&parsed.file)));
|
||||
sites.extend(scan_parsed(&relative(root, file).to_string_lossy().replace('\\', "/"), &parsed.src, Some(&parsed.file)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ fn type_facts_cross_files_of_a_crate() {
|
||||
let root = Path::new(FIXTURES).join("tree");
|
||||
let scope = scope().layer("src/chips", 5).crate_tree(&root, "fx", "src/lib.rs").unwrap();
|
||||
let report = check_with_scope(&Config::new(["src/chips"]), &root, &scope).unwrap();
|
||||
let hits: Vec<_> = report.findings.iter().map(|f| (f.path.display().to_string(), f.rule)).collect();
|
||||
let hits: Vec<_> = report.findings.iter().map(|f| (f.path.display().to_string().replace('\\', "/"), f.rule)).collect();
|
||||
assert_eq!(
|
||||
hits,
|
||||
[
|
||||
|
||||
@@ -16,3 +16,10 @@ path = "crates/ui-panels/src/docking/iconic/stories.rs"
|
||||
reason = "A story sizes its stage from the rail token."
|
||||
count = 1
|
||||
|
||||
[[exception]]
|
||||
name = "iconic-trial-rooms"
|
||||
kind = "exempt"
|
||||
rule = "literal-size"
|
||||
path = "crates/ui-panels/src/docking/iconic/trials.rs"
|
||||
reason = "Trial rooms, not looks."
|
||||
count = 1
|
||||
|
||||
Reference in New Issue
Block a user