mirror of
https://github.com/storytold/gridcraft.git
synced 2026-10-29 13:16:50 -06:00
Sonar: explicit imports, fn paths for closures, extract helpers for cognitive complexity
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
72c1d57d1e
commit
4e86fe7ad3
+1
-1
@@ -20,7 +20,7 @@ const EXAMPLE_EXT: &[&str] = &["csv", "tsv", "json"];
|
||||
const ASSET_DIRS: &[&str] = &["assets/", "docs/brand/", "docs/images/"];
|
||||
|
||||
fn ext(path: &str) -> String {
|
||||
Path::new(path).extension().and_then(|e| e.to_str()).map(str::to_ascii_lowercase).unwrap_or_default()
|
||||
Path::new(path).extension().and_then(std::ffi::OsStr::to_str).map(str::to_ascii_lowercase).unwrap_or_default()
|
||||
}
|
||||
|
||||
pub fn is_asset(path: &str) -> bool {
|
||||
|
||||
@@ -27,8 +27,8 @@ pub fn run(root: &Path) -> Result<(), String> {
|
||||
};
|
||||
for entry in entries.flatten() {
|
||||
let path = entry.path();
|
||||
let Some(stem) = path.file_stem().and_then(|s| s.to_str()).map(str::to_owned) else { continue };
|
||||
if path.extension().and_then(|e| e.to_str()) != Some("rs") {
|
||||
let Some(stem) = path.file_stem().and_then(std::ffi::OsStr::to_str).map(str::to_owned) else { continue };
|
||||
if path.extension().and_then(std::ffi::OsStr::to_str) != Some("rs") {
|
||||
continue;
|
||||
}
|
||||
let Ok(source) = std::fs::read_to_string(&path) else { continue };
|
||||
|
||||
+1
-1
@@ -174,7 +174,7 @@ pub fn check(crates: &[Crate]) -> Vec<Violation> {
|
||||
}
|
||||
}
|
||||
}
|
||||
out.sort_by_key(|v| v.to_string());
|
||||
out.sort_by_key(ToString::to_string);
|
||||
out.dedup();
|
||||
out
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user