Skip to content

Commit 2c826f4

Browse files
Change for clippy + README + stderr
1 parent 8a5ad94 commit 2c826f4

File tree

3 files changed

+25
-28
lines changed

3 files changed

+25
-28
lines changed

README.md

+9-9
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ Arguments:
1616
1717
Options:
1818
-d, --debug
19-
--dump-ir <DUMP_IR> Dump the IR for the specified function
20-
-dt, --dump-dt <DUMP_DOM_TREE> Dump the Dominator Tree for the specified app
21-
-f, --function <FUNCTION> A specific function to scan, must be an entrypoint specified in `manifest.yml`
22-
-h, --help Print help information
23-
-V, --version Print version information
24-
--check-permissions Runs the permission checker
25-
--cached-permissions Uses cached swagger permissions to avoid redownloading them
26-
--cached-permissions-path User designated cache location, if not specified defaults to ~/.cache
27-
--graphql-schema-path <LOCATION> Uses the graphql schema in location; othwerwise selects ~/.config dir
19+
--dump-ir <DUMP_IR> Dump the IR for the specified function
20+
-dt, --dump-dt <DUMP_DOM_TREE> Dump the Dominator Tree for the specified app
21+
-f, --function <FUNCTION> A specific function to scan, must be an entrypoint specified in `manifest.yml`
22+
-h, --help Print help information
23+
-V, --version Print version information
24+
--check-permissions Runs the permission checker
25+
--cached-permissions Uses cached swagger permissions to avoid redownloading them
26+
--cached-permissions-path <LOCATION> Uses the designated cache location, otherwise selects ~/.cache dir
27+
--graphql-schema-path <LOCATION> Uses the graphql schema in location; othwerwise selects ~/.config dir
2828
```
2929

3030
## Installation

crates/forge_permission_resolver/src/permissions_cache.rs

+9-6
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,11 @@ use tracing::debug;
1313
const CACHE_EXPIRATION: Duration = Duration::from_secs(60 * 60 * 24 * 7); // 1 week
1414

1515
fn default_cache_path() -> PathBuf {
16-
let home = env::var("HOME").unwrap_or_else(|_| ".".to_string());
17-
PathBuf::from(home).join(".cache/fsrt")
16+
if let Ok(home) = env::var("HOME") {
17+
PathBuf::from(home).join(".cache/fsrt")
18+
} else {
19+
PathBuf::new()
20+
}
1821
}
1922

2023
/// Struct to hold cache-related settings
@@ -65,19 +68,19 @@ impl PermissionsCache {
6568
if duration < self.config.ttl {
6669
return true;
6770
} else {
68-
println!(
71+
eprintln!(
6972
"Cache file expired: {:?}, duration {:?} is greater than ttl {:?}",
7073
path, duration, self.config.ttl
7174
);
7275
}
7376
} else {
74-
println!("Failed to get elapsed time for cache file: {:?}", path);
77+
eprintln!("Failed to get elapsed time for cache file: {:?}", path);
7578
}
7679
} else {
77-
println!("Failed to get modified time for cache file: {:?}", path);
80+
eprintln!("Failed to get modified time for cache file: {:?}", path);
7881
}
7982
} else {
80-
println!("Failed to get metadata for cache file: {:?}", path);
83+
eprintln!("Failed to get metadata for cache file: {:?}", path);
8184
}
8285
false
8386
}

crates/forge_permission_resolver/src/serde.rs

+7-13
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,14 @@ impl From<SerializablePermissionHashMap> for PermissionHashMap {
2626
let deserialized_map: PermissionHashMap = serialized
2727
.map
2828
.into_iter()
29-
.filter_map(|(key, v)| {
29+
.map(|(key, v)| {
3030
let mut parts = key.split("::");
31-
let url = parts.next();
32-
let req = parts.next();
33-
if let (Some(url), Some(req)) = (url, req) {
34-
match req.parse::<RequestType>() {
35-
Ok(req_type) => Some(((url.to_string(), req_type), v)),
36-
Err(_) => {
37-
panic!("Failed to parse RequestType from: {}", req);
38-
}
39-
}
40-
} else {
41-
panic!("Failed to split key: {}", key);
42-
}
31+
let url = parts.next().expect("Failed to split key");
32+
let req = parts.next().expect("Failed to split key");
33+
let req_type = req
34+
.parse::<RequestType>()
35+
.expect("Failed to parse RequestType");
36+
((url.to_string(), req_type), v)
4337
})
4438
.collect();
4539
deserialized_map

0 commit comments

Comments
 (0)