Created
May 13, 2025 05:01
-
-
Save aksh1618/f457919c3d367983bee99f3298aca50c to your computer and use it in GitHub Desktop.
Clippy lint configuration curated for those getting started with serious projects in Rust. Just drop it at the end of your Cargo.toml!
This file contains hidden or 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
[lints.clippy] | |
#################################### Warns ##################################### | |
#--- suspicious, complexity, perf & style groups are warn-by-default | |
#--- set entire pedantic group to warn (pedantic is intended for opt-outs) | |
pedantic = { level = "warn", priority = -1 } # feel free to #[allow] specific lints in code | |
nursery = { level = "warn", priority = -1 } | |
#--- set selective lints from restriction group to warn (restriction is intended for opt-ins) | |
# restriction = { level = "warn", priority = -1 } | |
absolute_paths = "warn" # clippy.toml: `absolute-paths-max-segments = 2` | |
allow_attributes = "warn" | |
allow_attributes_without_reason = "warn" | |
clone_on_ref_ptr = "warn" | |
create_dir = "warn" | |
empty_enum_variants_with_brackets = "warn" | |
empty_structs_with_brackets = "warn" | |
error_impl_error = "warn" | |
filetype_is_file = "warn" | |
fn_to_numeric_cast_any = "warn" | |
format_push_string = "warn" | |
if_then_some_else_none = "warn" | |
impl_trait_in_params = "warn" | |
infinite_loop = "warn" | |
integer_division = "warn" # feel free to #[allow] where required | |
let_underscore_untyped = "warn" | |
lossy_float_literal = "warn" | |
map_err_ignore = "warn" | |
map_with_unused_argument_over_ranges = "warn" | |
min_ident_chars = "warn" # clippy config: `min-ident-chars-threshold = 1` | |
mem_forget = "warn" | |
missing_assert_message = "warn" | |
missing_asserts_for_indexing = "warn" | |
mixed_read_write_in_expression = "warn" | |
module_name_repetitions = "warn" | |
multiple_inherent_impl = "warn" | |
multiple_unsafe_ops_per_block = "warn" # combines with undocumented_unsafe_blocks to ensure each unsafe usage is documented | |
mutex_atomic = "warn" | |
non_zero_suggestions = "warn" | |
panic_in_result_fn = "warn" | |
partial_pub_fields = "warn" | |
pathbuf_init_then_push = "warn" | |
pub_without_shorthand = "warn" # choosing pub_with_shorthand as it's more concise | |
rc_buffer = "warn" | |
rc_mutex = "warn" | |
renamed_function_params = "warn" # clippy config: `allow-renamed-params-for = [ "..", "mycrate::myTrait" ]` | |
rest_pat_in_fully_bound_structs = "warn" | |
same_name_method = "warn" | |
self_named_module_files = "warn" # choosing mod_module_files as it keeps related rs files in same dir | |
semicolon_outside_block = "warn" | |
shadow_unrelated = "warn" | |
string_to_string = "warn" | |
tests_outside_test_module = "warn" | |
try_err = "warn" | |
undocumented_unsafe_blocks = "warn" | |
unnecessary_safety_comment = "warn" | |
unnecessary_safety_doc = "warn" | |
unnecessary_self_imports = "warn" | |
unneeded_field_pattern = "warn" | |
unseparated_literal_suffix = "warn" # choosing separated_literal_suffix for better readability | |
unused_result_ok = "warn" | |
unused_trait_names = "warn" | |
unwrap_in_result = "warn" # feel free to #[allow] for specific functions | |
unwrap_used = "warn" | |
# use_debug = "warn" # keeping disabled by default, can be enabled when required | |
verbose_file_reads = "warn" | |
wildcard_enum_match_arm = "warn" # feel free to #[allow] for specific blocks | |
#################################### Allows #################################### | |
#--- set selective lints from pedantic group to allow | |
map_unwrap_or = "allow" # This reduces readability; see https://github.com/rust-lang/rust-clippy/issues/10428 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment