Last active
October 14, 2021 02:44
-
-
Save repi/0a3289416fcc81225d44398b16a9325c to your computer and use it in GitHub Desktop.
Embark Clippy.toml for `disallowed_method` lint
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
msrv = "1.55.0" | |
# for `disallowed_method`: https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_method | |
disallowed-methods = [ | |
# std functions | |
"std::env::temp_dir", # we use the tempdir crate instead through ark_file_system::TempDir | |
"std::env::home_dir", # deprecated, and we use app_dirs2 crate | |
"std::env::set_current_dir", # don't change the current working directory, it usually leads to shared sadness | |
"std::env::var_os", # use std::env::var and UTF-8 strings instead, including for paths | |
"std::env::env_os", # use std::env::env and UTF-8 strings instead, including for paths | |
"std::env::args_os", # use std::env::args and UTF-8 strings instead, including for paths | |
# Use cap-std instead. | |
# this list is from https://github.com/sunfishcode/ambient-authority/blob/main/clippy.toml | |
# TODO: all of these should be disallowed, but we have some lingering use cases | |
# we can enable function after function here once we have converted/removed the last usage of the function | |
#"std::fs::canonicalize", | |
"std::fs::copy", | |
"std::fs::create_dir", | |
#"std::fs::create_dir_all", | |
"std::fs::hard_link", | |
#"std::fs::metadata", | |
#"std::fs::read", | |
"std::fs::read_dir", | |
"std::fs::read_link", | |
#"std::fs::read_to_string", | |
"std::fs::remove_dir", | |
"std::fs::remove_dir_all", | |
#"std::fs::remove_file", | |
"std::fs::rename", | |
"std::fs::set_permissions", | |
"std::fs::soft_link", | |
"std::fs::symlink_metadata", | |
"std::fs::try_exists", | |
#"std::fs::write", | |
"std::fs::DirBuilder::create", | |
#"std::fs::File::open", | |
"std::fs::File::create", | |
#"std::fs::OpenOptions::open", | |
"std::path::Path::metadata", | |
"std::path::Path::symlink_metadata", | |
"std::path::Path::canonicalize", | |
"std::path::Path::read_link", | |
"std::path::Path::read_dir", | |
#"std::path::Path::exists", | |
"std::path::Path::is_file", # use Dir::metadata function instead | |
"std::path::Path::is_dir", # use metadata function instead | |
"std::path::Path::new", # use ark_file_system::Path::new | |
"std::path::PathBuf::new", # use ark_file_system::PathBuf::new | |
"std::path::PathBuf::from", # use ark_file_system::PathBuf::from | |
"remove_dir_all::ensure_empty_dir", | |
"remove_dir_all::remove_dir_all", | |
"remove_dir_all::remove_dir_contents", | |
# Use cap-std instead; specifically, `cap_std::fs_utf8`. | |
# TODO: all of these should be disallowed, but we have some lingering use cases | |
"camino::Utf8Path::metadata", | |
"camino::Utf8Path::symlink_metadata", | |
"camino::Utf8Path::canonicalize", | |
"camino::Utf8Path::read_link", | |
"camino::Utf8Path::read_dir", | |
#"camino::Utf8Path::exists", | |
"camino::Utf8Path::try_exists", | |
"camino::Utf8Path::is_file", | |
"camino::Utf8Path::is_dir", | |
# Use cap-std through ark-file-system instead within blocking tokio scope | |
# the tokio functions are not capability-based and use non-UTF-8 paths | |
# TODO: for some reason these disallowed methods doesn't seem to trigger with clippy, last testded with cargo 1.56.0-nightly (18751dd3f 2021-09-01) | |
"tokio::fs::canonicalize", | |
"tokio::fs::copy", | |
"tokio::fs::create_dir", | |
"tokio::fs::create_dir_all", | |
"tokio::fs::hard_link", | |
"tokio::fs::metadata", | |
"tokio::fs::read", | |
"tokio::fs::read_dir", | |
"tokio::fs::read_link", | |
"tokio::fs::read_to_string", | |
"tokio::fs::remove_dir", | |
"tokio::fs::remove_dir_all", | |
"tokio::fs::remove_file", | |
"tokio::fs::rename", | |
"tokio::fs::set_permissions", | |
"tokio::fs::symlink", | |
"tokio::fs::symlink_metadata", | |
"tokio::fs::write", | |
# use image crate functions that load and save to memory, do not allow file system usage outside of cap-std | |
#"image::load", | |
#"image::open", | |
#"image::image_dimensions", | |
#"image::save_buffer", | |
#"image::save_buffer_with_format", | |
#"image::io::Reader::open", | |
#"image::ImageFormat::from_path", | |
#"std::path::Path::to_string_lossy", # we use camino UTF-8 paths instead that are compatible strings | |
# use `ark_future::block_on` instead | |
"futures::executor::block_on", | |
# SHA-1 is cryptographically broken, and we are building new code so should not use it | |
"sha1::Digest::new", | |
] | |
# for `disallowed_type`: https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_type | |
disallowed-types = [ | |
# use the faster & simpler non-poisonable primitives in `parking_lot` instead | |
"std::sync::Mutex", | |
"std::sync::RwLock", | |
"std::sync::Condvar", | |
# "std::sync::Once", # enabled for now as the `log_once` macro uses it internally | |
# Use cap-std through ark-file-system instead within blocking tokio scope | |
# the tokio functions are not capability-based and use non-UTF-8 paths | |
"tokio::fs::File", | |
"tokio::fs::OpenOptions", | |
# slow and almost never needed | |
"std::collections::LinkedList", | |
# SHA-1 is cryptographically broken, and we are building new code so should not use it | |
"ring::digest::SHA1_FOR_LEGACY_USE_ONLY", | |
] | |
# add additional identifiers that we use in the codebase so `doc_markdown` lint doesn't complain about them | |
# unfortunately this overrides the default ones, so we've manually copy'n'pasted in the default ones here | |
# from https://rust-lang.github.io/rust-clippy/master/index.html#doc_markdown | |
doc-valid-idents = [ | |
"gRPC", "VTune", "WebAssembly", | |
"KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "DirectX", "ECMAScript", "GPLv2", "GPLv3", "GitHub", "GitLab", "IPv4", "IPv6", "ClojureScript", "CoffeeScript", "JavaScript", "PureScript", "TypeScript", "NaN", "NaNs", "OAuth", "GraphQL", "OCaml", "OpenGL", "OpenMP", "OpenSSH", "OpenSSL", "OpenStreetMap", "OpenDNS", "WebGL", "TensorFlow", "TrueType", "iOS", "macOS", "FreeBSD", "TeX", "LaTeX", "BibTeX", "BibLaTeX", "MinGW", "CamelCase" | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment