Skip to content

Commit a6f1c5e

Browse files
authored
Disallow std::fs function calls prefer fs_err (#92)
1 parent 2555a95 commit a6f1c5e

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

clippy.toml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
disallowed-methods = [
2+
# Use fs_errr functions, so the filename is available in the error message
3+
{ path = "std::fs::canonicalize", replacement = "fs_err::canonicalize" },
4+
{ path = "std::fs::copy", replacement = "fs_err::copy" },
5+
{ path = "std::fs::create_dir", replacement = "fs_err::create_dir" },
6+
{ path = "std::fs::create_dir_all", replacement = "fs_err::create_dir_all" },
7+
{ path = "std::fs::exists", replacement = "fs_err::exists" },
8+
{ path = "std::fs::hard_link", replacement = "fs_err::hard_link" },
9+
{ path = "std::fs::metadata", replacement = "fs_err::metadata" },
10+
{ path = "std::fs::read", replacement = "fs_err::read" },
11+
{ path = "std::fs::read_dir", replacement = "fs_err::read_dir" },
12+
{ path = "std::fs::read_link", replacement = "fs_err::read_link" },
13+
{ path = "std::fs::read_to_string", replacement = "fs_err::read_to_string" },
14+
{ path = "std::fs::remove_dir", replacement = "fs_err::remove_dir" },
15+
{ path = "std::fs::remove_dir_all", replacement = "fs_err::remove_dir_all" },
16+
{ path = "std::fs::remove_file", replacement = "fs_err::remove_file" },
17+
{ path = "std::fs::rename", replacement = "fs_err::rename" },
18+
{ path = "std::fs::set_permissions", replacement = "fs_err::set_permissions" },
19+
{ path = "std::fs::soft_link", replacement = "fs_err::soft_link" },
20+
{ path = "std::fs::symlink_metadata", replacement = "fs_err::symlink_metadata" },
21+
{ path = "std::fs::write", replacement = "fs_err::write" },
22+
23+
# Use fs_err::path::PathExt methods, so the filename is available in the error message
24+
{ path = "std::path::Path::try_exists", reason = "Use fs_err::path::PathExt methods" },
25+
{ path = "std::path::Path::metadata", reason = "Use fs_err::path::PathExt methods" },
26+
{ path = "std::path::Path::symlink_metadata", reason = "Use fs_err::path::PathExt methods" },
27+
{ path = "std::path::Path::canonicalize", reason = "Use fs_err::path::PathExt methods" },
28+
{ path = "std::path::Path::read_link", reason = "Use fs_err::path::PathExt methods" },
29+
{ path = "std::path::Path::read_dir", reason = "Use fs_err::path::PathExt methods" },
30+
]

0 commit comments

Comments
 (0)