From cfe8849a622c6308eaee333e8adba6c5bc3f457e Mon Sep 17 00:00:00 2001 From: Tyler Weaver Date: Thu, 12 Jan 2023 06:43:17 -0700 Subject: [PATCH 1/7] Document extending list type configs Signed-off-by: Tyler Weaver --- README.md | 9 +++++++++ book/src/configuration.md | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/README.md b/README.md index 81254ba8b..f7e03ca4c 100644 --- a/README.md +++ b/README.md @@ -200,6 +200,15 @@ cognitive-complexity-threshold = 30 See the [list of configurable lints](https://rust-lang.github.io/rust-clippy/master/index.html#Configuration), the lint descriptions contain the names and meanings of these configuration variables. +For configurations that are a list type with default values such as +[disallowed-names](https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_names), +you can use the unique value `".."` to extend the default values instead of replacing them. + +```toml +# default of disallowed-names is ["foo", "baz", "quux"] +disallowed-names = ["bar", ".."] # -> ["bar", "foo", "baz", "quux"] +``` + > **Note** > > `clippy.toml` or `.clippy.toml` cannot be used to allow/deny lints. diff --git a/book/src/configuration.md b/book/src/configuration.md index 430ff8b73..bbe1081cc 100644 --- a/book/src/configuration.md +++ b/book/src/configuration.md @@ -14,6 +14,15 @@ cognitive-complexity-threshold = 30 See the [list of configurable lints](https://rust-lang.github.io/rust-clippy/master/index.html#Configuration), the lint descriptions contain the names and meanings of these configuration variables. +For configurations that are a list type with default values such as +[disallowed-names](https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_names), +you can use the unique value `".."` to extend the default values instead of replacing them. + +```toml +# default of disallowed-names is ["foo", "baz", "quux"] +disallowed-names = ["bar", ".."] # -> ["bar", "foo", "baz", "quux"] +``` + To deactivate the "for further information visit *lint-link*" message you can define the `CLIPPY_DISABLE_DOCS_LINKS` environment variable. From d43dce14d5eb7af1656d730bfbb5918c84addbca Mon Sep 17 00:00:00 2001 From: Tyler Weaver Date: Fri, 13 Jan 2023 08:59:00 -0700 Subject: [PATCH 2/7] Remove cognitive-complexity-threshold from docs --- README.md | 1 - book/src/configuration.md | 1 - 2 files changed, 2 deletions(-) diff --git a/README.md b/README.md index f7e03ca4c..c78ae0676 100644 --- a/README.md +++ b/README.md @@ -194,7 +194,6 @@ value` mapping e.g. ```toml avoid-breaking-exported-api = false disallowed-names = ["toto", "tata", "titi"] -cognitive-complexity-threshold = 30 ``` See the [list of configurable lints](https://rust-lang.github.io/rust-clippy/master/index.html#Configuration), diff --git a/book/src/configuration.md b/book/src/configuration.md index bbe1081cc..fac3e438c 100644 --- a/book/src/configuration.md +++ b/book/src/configuration.md @@ -8,7 +8,6 @@ basic `variable = value` mapping eg. ```toml avoid-breaking-exported-api = false disallowed-names = ["toto", "tata", "titi"] -cognitive-complexity-threshold = 30 ``` See the [list of configurable lints](https://rust-lang.github.io/rust-clippy/master/index.html#Configuration), From 2e2ae68d5a3ef0b8c0c968fd6ec4e859c77ed2f1 Mon Sep 17 00:00:00 2001 From: Tyler Weaver Date: Fri, 13 Jan 2023 11:38:34 -0700 Subject: [PATCH 3/7] Document lint configuration values in Clippy's book Signed-off-by: Tyler Weaver --- .github/workflows/remark.yml | 3 + README.md | 3 + book/src/SUMMARY.md | 1 + book/src/configuration.md | 3 + book/src/lint_configuration.md | 52 ++++++++++++++++ .../internal_lints/metadata_collector.rs | 62 +++++++++++++++++-- 6 files changed, 118 insertions(+), 6 deletions(-) create mode 100644 book/src/lint_configuration.md diff --git a/.github/workflows/remark.yml b/.github/workflows/remark.yml index 81ef072bb..22925a753 100644 --- a/.github/workflows/remark.yml +++ b/.github/workflows/remark.yml @@ -33,6 +33,9 @@ jobs: echo `pwd`/mdbook >> $GITHUB_PATH # Run + - name: cargo collect-metadata + run: cargo collect-metadata + - name: Check *.md files run: git ls-files -z '*.md' | xargs -0 -n 1 -I {} ./node_modules/.bin/remark {} -u lint -f > /dev/null diff --git a/README.md b/README.md index c78ae0676..2ba095368 100644 --- a/README.md +++ b/README.md @@ -199,6 +199,9 @@ disallowed-names = ["toto", "tata", "titi"] See the [list of configurable lints](https://rust-lang.github.io/rust-clippy/master/index.html#Configuration), the lint descriptions contain the names and meanings of these configuration variables. +See [table of lint configurations](https://doc.rust-lang.org/nightly/clippy/lint_configuration.html) +to see what configuration options you can set and the lints they configure. + For configurations that are a list type with default values such as [disallowed-names](https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_names), you can use the unique value `".."` to extend the default values instead of replacing them. diff --git a/book/src/SUMMARY.md b/book/src/SUMMARY.md index 1f0b8db28..0649f7a63 100644 --- a/book/src/SUMMARY.md +++ b/book/src/SUMMARY.md @@ -5,6 +5,7 @@ - [Installation](installation.md) - [Usage](usage.md) - [Configuration](configuration.md) + - [Lint Configuration](lint_configuration.md) - [Clippy's Lints](lints.md) - [Continuous Integration](continuous_integration/README.md) - [GitHub Actions](continuous_integration/github_actions.md) diff --git a/book/src/configuration.md b/book/src/configuration.md index fac3e438c..e68f30be4 100644 --- a/book/src/configuration.md +++ b/book/src/configuration.md @@ -13,6 +13,9 @@ disallowed-names = ["toto", "tata", "titi"] See the [list of configurable lints](https://rust-lang.github.io/rust-clippy/master/index.html#Configuration), the lint descriptions contain the names and meanings of these configuration variables. +See [table of lint configurations](./lint_configuration.md) +to see what configuration options you can set and the lints they configure. + For configurations that are a list type with default values such as [disallowed-names](https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_names), you can use the unique value `".."` to extend the default values instead of replacing them. diff --git a/book/src/lint_configuration.md b/book/src/lint_configuration.md new file mode 100644 index 000000000..102ed7ad2 --- /dev/null +++ b/book/src/lint_configuration.md @@ -0,0 +1,52 @@ +## Configuration Options + +| Option | Default | Description | Lints | +|--|--|--|--| +| arithmetic-side-effects-allowed | `{}` | Suppress checking of the passed type names in all types of operations | [arithmetic_side_effects](https://rust-lang.github.io/rust-clippy/master/index.html#arithmetic_side_effects) | +| arithmetic-side-effects-allowed-binary | `[]` | Suppress checking of the passed type pair names in binary operations like addition or multiplication | [arithmetic_side_effects](https://rust-lang.github.io/rust-clippy/master/index.html#arithmetic_side_effects) | +| arithmetic-side-effects-allowed-unary | `{}` | Suppress checking of the passed type names in unary operations like "negation" (`-`) | [arithmetic_side_effects](https://rust-lang.github.io/rust-clippy/master/index.html#arithmetic_side_effects) | +| avoid-breaking-exported-api | `true` | Suppress lints whenever the suggested change would cause breakage for other crates | [enum_variant_names](https://rust-lang.github.io/rust-clippy/master/index.html#enum_variant_names) [large_types_passed_by_value](https://rust-lang.github.io/rust-clippy/master/index.html#large_types_passed_by_value) [trivially_copy_pass_by_ref](https://rust-lang.github.io/rust-clippy/master/index.html#trivially_copy_pass_by_ref) [unnecessary_wraps](https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_wraps) [unused_self](https://rust-lang.github.io/rust-clippy/master/index.html#unused_self) [upper_case_acronyms](https://rust-lang.github.io/rust-clippy/master/index.html#upper_case_acronyms) [wrong_self_convention](https://rust-lang.github.io/rust-clippy/master/index.html#wrong_self_convention) [box_collection](https://rust-lang.github.io/rust-clippy/master/index.html#box_collection) [redundant_allocation](https://rust-lang.github.io/rust-clippy/master/index.html#redundant_allocation) [rc_buffer](https://rust-lang.github.io/rust-clippy/master/index.html#rc_buffer) [vec_box](https://rust-lang.github.io/rust-clippy/master/index.html#vec_box) [option_option](https://rust-lang.github.io/rust-clippy/master/index.html#option_option) [linkedlist](https://rust-lang.github.io/rust-clippy/master/index.html#linkedlist) [rc_mutex](https://rust-lang.github.io/rust-clippy/master/index.html#rc_mutex) | +| msrv | `None` | The minimum rust version that the project supports | [manual_split_once](https://rust-lang.github.io/rust-clippy/master/index.html#manual_split_once) [manual_str_repeat](https://rust-lang.github.io/rust-clippy/master/index.html#manual_str_repeat) [cloned_instead_of_copied](https://rust-lang.github.io/rust-clippy/master/index.html#cloned_instead_of_copied) [redundant_field_names](https://rust-lang.github.io/rust-clippy/master/index.html#redundant_field_names) [redundant_static_lifetimes](https://rust-lang.github.io/rust-clippy/master/index.html#redundant_static_lifetimes) [filter_map_next](https://rust-lang.github.io/rust-clippy/master/index.html#filter_map_next) [checked_conversions](https://rust-lang.github.io/rust-clippy/master/index.html#checked_conversions) [manual_range_contains](https://rust-lang.github.io/rust-clippy/master/index.html#manual_range_contains) [use_self](https://rust-lang.github.io/rust-clippy/master/index.html#use_self) [mem_replace_with_default](https://rust-lang.github.io/rust-clippy/master/index.html#mem_replace_with_default) [manual_non_exhaustive](https://rust-lang.github.io/rust-clippy/master/index.html#manual_non_exhaustive) [option_as_ref_deref](https://rust-lang.github.io/rust-clippy/master/index.html#option_as_ref_deref) [map_unwrap_or](https://rust-lang.github.io/rust-clippy/master/index.html#map_unwrap_or) [match_like_matches_macro](https://rust-lang.github.io/rust-clippy/master/index.html#match_like_matches_macro) [manual_strip](https://rust-lang.github.io/rust-clippy/master/index.html#manual_strip) [missing_const_for_fn](https://rust-lang.github.io/rust-clippy/master/index.html#missing_const_for_fn) [unnested_or_patterns](https://rust-lang.github.io/rust-clippy/master/index.html#unnested_or_patterns) [from_over_into](https://rust-lang.github.io/rust-clippy/master/index.html#from_over_into) [ptr_as_ptr](https://rust-lang.github.io/rust-clippy/master/index.html#ptr_as_ptr) [if_then_some_else_none](https://rust-lang.github.io/rust-clippy/master/index.html#if_then_some_else_none) [approx_constant](https://rust-lang.github.io/rust-clippy/master/index.html#approx_constant) [deprecated_cfg_attr](https://rust-lang.github.io/rust-clippy/master/index.html#deprecated_cfg_attr) [index_refutable_slice](https://rust-lang.github.io/rust-clippy/master/index.html#index_refutable_slice) [map_clone](https://rust-lang.github.io/rust-clippy/master/index.html#map_clone) [borrow_as_ptr](https://rust-lang.github.io/rust-clippy/master/index.html#borrow_as_ptr) [manual_bits](https://rust-lang.github.io/rust-clippy/master/index.html#manual_bits) [err_expect](https://rust-lang.github.io/rust-clippy/master/index.html#err_expect) [cast_abs_to_unsigned](https://rust-lang.github.io/rust-clippy/master/index.html#cast_abs_to_unsigned) [uninlined_format_args](https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args) [manual_clamp](https://rust-lang.github.io/rust-clippy/master/index.html#manual_clamp) [manual_let_else](https://rust-lang.github.io/rust-clippy/master/index.html#manual_let_else) [unchecked_duration_subtraction](https://rust-lang.github.io/rust-clippy/master/index.html#unchecked_duration_subtraction) | +| cognitive-complexity-threshold | `25` | The maximum cognitive complexity a function can have | [cognitive_complexity](https://rust-lang.github.io/rust-clippy/master/index.html#cognitive_complexity) | +| disallowed-names | `["foo", "baz", "quux"]` | The list of disallowed names to lint about | [disallowed_names](https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_names) | +| doc-valid-idents | `["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"]` | The list of words this lint should not consider as identifiers needing ticks | [doc_markdown](https://rust-lang.github.io/rust-clippy/master/index.html#doc_markdown) | +| too-many-arguments-threshold | `7` | The maximum number of argument a function or method can have | [too_many_arguments](https://rust-lang.github.io/rust-clippy/master/index.html#too_many_arguments) | +| type-complexity-threshold | `250` | The maximum complexity a type can have | [type_complexity](https://rust-lang.github.io/rust-clippy/master/index.html#type_complexity) | +| single-char-binding-names-threshold | `4` | The maximum number of single char bindings a scope may have | [many_single_char_names](https://rust-lang.github.io/rust-clippy/master/index.html#many_single_char_names) | +| too-large-for-stack | `200` | The maximum size of objects (in bytes) that will be linted | [boxed_local](https://rust-lang.github.io/rust-clippy/master/index.html#boxed_local) [useless_vec](https://rust-lang.github.io/rust-clippy/master/index.html#useless_vec) | +| enum-variant-name-threshold | `3` | The minimum number of enum variants for the lints about variant names to trigger | [enum_variant_names](https://rust-lang.github.io/rust-clippy/master/index.html#enum_variant_names) | +| enum-variant-size-threshold | `200` | The maximum size of an enum's variant to avoid box suggestion | [large_enum_variant](https://rust-lang.github.io/rust-clippy/master/index.html#large_enum_variant) | +| verbose-bit-mask-threshold | `1` | The maximum allowed size of a bit mask before suggesting to use 'trailing_zeros' | [verbose_bit_mask](https://rust-lang.github.io/rust-clippy/master/index.html#verbose_bit_mask) | +| literal-representation-threshold | `16384` | The lower bound for linting decimal literals | [decimal_literal_representation](https://rust-lang.github.io/rust-clippy/master/index.html#decimal_literal_representation) | +| trivial-copy-size-limit | `None` | The maximum size (in bytes) to consider a `Copy` type for passing by value instead of by reference | [trivially_copy_pass_by_ref](https://rust-lang.github.io/rust-clippy/master/index.html#trivially_copy_pass_by_ref) | +| pass-by-value-size-limit | `256` | The minimum size (in bytes) to consider a type for passing by reference instead of by value | [large_type_pass_by_move](https://rust-lang.github.io/rust-clippy/master/index.html#large_type_pass_by_move) | +| too-many-lines-threshold | `100` | The maximum number of lines a function or method can have | [too_many_lines](https://rust-lang.github.io/rust-clippy/master/index.html#too_many_lines) | +| array-size-threshold | `512000` | The maximum allowed size for arrays on the stack | [large_stack_arrays](https://rust-lang.github.io/rust-clippy/master/index.html#large_stack_arrays) [large_const_arrays](https://rust-lang.github.io/rust-clippy/master/index.html#large_const_arrays) | +| vec-box-size-threshold | `4096` | The size of the boxed type in bytes, where boxing in a `Vec` is allowed | [vec_box](https://rust-lang.github.io/rust-clippy/master/index.html#vec_box) | +| max-trait-bounds | `3` | The maximum number of bounds a trait can have to be linted | [type_repetition_in_bounds](https://rust-lang.github.io/rust-clippy/master/index.html#type_repetition_in_bounds) | +| max-struct-bools | `3` | The maximum number of bool fields a struct can have | [struct_excessive_bools](https://rust-lang.github.io/rust-clippy/master/index.html#struct_excessive_bools) | +| max-fn-params-bools | `3` | The maximum number of bool parameters a function can have | [fn_params_excessive_bools](https://rust-lang.github.io/rust-clippy/master/index.html#fn_params_excessive_bools) | +| warn-on-all-wildcard-imports | `false` | Whether to allow certain wildcard imports (prelude, super in tests) | [wildcard_imports](https://rust-lang.github.io/rust-clippy/master/index.html#wildcard_imports) | +| disallowed-macros | `[]` | The list of disallowed macros, written as fully qualified paths | [disallowed_macros](https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_macros) | +| disallowed-methods | `[]` | The list of disallowed methods, written as fully qualified paths | [disallowed_methods](https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_methods) | +| disallowed-types | `[]` | The list of disallowed types, written as fully qualified paths | [disallowed_types](https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_types) | +| unreadable-literal-lint-fractions | `true` | Should the fraction of a decimal be linted to include separators | [unreadable_literal](https://rust-lang.github.io/rust-clippy/master/index.html#unreadable_literal) | +| upper-case-acronyms-aggressive | `false` | Enables verbose mode | [upper_case_acronyms](https://rust-lang.github.io/rust-clippy/master/index.html#upper_case_acronyms) | +| matches-for-let-else | `WellKnownTypes` | Whether the matches should be considered by the lint, and whether there should be filtering for common types | [manual_let_else](https://rust-lang.github.io/rust-clippy/master/index.html#manual_let_else) | +| cargo-ignore-publish | `false` | For internal testing only, ignores the current `publish` settings in the Cargo manifest | [_cargo_common_metadata](https://rust-lang.github.io/rust-clippy/master/index.html#_cargo_common_metadata) | +| standard-macro-braces | `[]` | Enforce the named macros always use the braces specified | [nonstandard_macro_braces](https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces) | +| enforced-import-renames | `[]` | The list of imports to always rename, a fully qualified path followed by the rename | [missing_enforced_import_renames](https://rust-lang.github.io/rust-clippy/master/index.html#missing_enforced_import_renames) | +| allowed-scripts | `["Latin"]` | The list of unicode scripts allowed to be used in the scope | [disallowed_script_idents](https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_script_idents) | +| enable-raw-pointer-heuristic-for-send | `true` | Whether to apply the raw pointer heuristic to determine if a type is `Send` | [non_send_fields_in_send_ty](https://rust-lang.github.io/rust-clippy/master/index.html#non_send_fields_in_send_ty) | +| max-suggested-slice-pattern-length | `3` | When Clippy suggests using a slice pattern, this is the maximum number of elements allowed in the slice pattern that is suggested | [index_refutable_slice](https://rust-lang.github.io/rust-clippy/master/index.html#index_refutable_slice) | +| await-holding-invalid-types | `[]` | [ERROR] MALFORMED DOC COMMENT | | +| max-include-file-size | `1000000` | The maximum size of a file included via `include_bytes!()` or `include_str!()`, in bytes | [large_include_file](https://rust-lang.github.io/rust-clippy/master/index.html#large_include_file) | +| allow-expect-in-tests | `false` | Whether `expect` should be allowed within `#[cfg(test)]` | [expect_used](https://rust-lang.github.io/rust-clippy/master/index.html#expect_used) | +| allow-unwrap-in-tests | `false` | Whether `unwrap` should be allowed in test cfg | [unwrap_used](https://rust-lang.github.io/rust-clippy/master/index.html#unwrap_used) | +| allow-dbg-in-tests | `false` | Whether `dbg!` should be allowed in test functions | [dbg_macro](https://rust-lang.github.io/rust-clippy/master/index.html#dbg_macro) | +| allow-print-in-tests | `false` | Whether print macros (ex | [print_stdout](https://rust-lang.github.io/rust-clippy/master/index.html#print_stdout) [print_stderr](https://rust-lang.github.io/rust-clippy/master/index.html#print_stderr) | +| large-error-threshold | `128` | The maximum size of the `Err`-variant in a `Result` returned from a function | [result_large_err](https://rust-lang.github.io/rust-clippy/master/index.html#result_large_err) | +| ignore-interior-mutability | `["bytes::Bytes"]` | A list of paths to types that should be treated like `Arc`, i | [mutable_key](https://rust-lang.github.io/rust-clippy/master/index.html#mutable_key) | +| allow-mixed-uninlined-format-args | `true` | Whether to allow mixed uninlined format args, e | [uninlined_format_args](https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args) | +| suppress-restriction-lint-in-const | `false` | In same cases the restructured operation might not be unavoidable, as the suggested counterparts are unavailable in constant code | [indexing_slicing](https://rust-lang.github.io/rust-clippy/master/index.html#indexing_slicing) | + diff --git a/clippy_lints/src/utils/internal_lints/metadata_collector.rs b/clippy_lints/src/utils/internal_lints/metadata_collector.rs index 929544cd6..c74f3b6e3 100644 --- a/clippy_lints/src/utils/internal_lints/metadata_collector.rs +++ b/clippy_lints/src/utils/internal_lints/metadata_collector.rs @@ -14,6 +14,7 @@ use clippy_utils::diagnostics::span_lint; use clippy_utils::ty::{match_type, walk_ptrs_ty_depth}; use clippy_utils::{last_path_segment, match_def_path, match_function_call, match_path, paths}; use if_chain::if_chain; +use itertools::Itertools; use rustc_ast as ast; use rustc_data_structures::fx::FxHashMap; use rustc_hir::{ @@ -34,8 +35,10 @@ use std::path::Path; use std::path::PathBuf; use std::process::Command; -/// This is the output file of the lint collector. -const OUTPUT_FILE: &str = "../util/gh-pages/lints.json"; +/// This is the json output file of the lint collector. +const JSON_OUTPUT_FILE: &str = "../util/gh-pages/lints.json"; +/// This is the markdown output file of the lint collector. +const MARKDOWN_OUTPUT_FILE: &str = "../book/src/lint_configuration.md"; /// These lints are excluded from the export. const BLACK_LISTED_LINTS: &[&str] = &["lint_author", "dump_hir", "internal_metadata_collector"]; /// These groups will be ignored by the lint group matcher. This is useful for collections like @@ -176,6 +179,14 @@ This lint has the following configuration variables: ) }) } + + fn get_markdown_table(&self) -> String { + self.config + .iter() + .filter(|config| config.deprecation_reason.is_none()) + .map(ClippyConfiguration::to_markdown_table_entry) + .join("\n") + } } impl Drop for MetadataCollector { @@ -199,12 +210,32 @@ impl Drop for MetadataCollector { collect_renames(&mut lints); - // Outputting - if Path::new(OUTPUT_FILE).exists() { - fs::remove_file(OUTPUT_FILE).unwrap(); + // Outputting json + if Path::new(JSON_OUTPUT_FILE).exists() { + fs::remove_file(JSON_OUTPUT_FILE).unwrap(); } - let mut file = OpenOptions::new().write(true).create(true).open(OUTPUT_FILE).unwrap(); + let mut file = OpenOptions::new() + .write(true) + .create(true) + .open(JSON_OUTPUT_FILE) + .unwrap(); writeln!(file, "{}", serde_json::to_string_pretty(&lints).unwrap()).unwrap(); + + // Outputting markdown + if Path::new(MARKDOWN_OUTPUT_FILE).exists() { + fs::remove_file(MARKDOWN_OUTPUT_FILE).unwrap(); + } + let mut file = OpenOptions::new() + .write(true) + .create(true) + .open(MARKDOWN_OUTPUT_FILE) + .unwrap(); + writeln!( + file, + "## Lint Configuration\n\n| Option | Default | Description | Lints |\n|--|--|--|--|\n{}\n", + self.get_markdown_table() + ) + .unwrap(); } } @@ -505,6 +536,25 @@ impl ClippyConfiguration { deprecation_reason, } } + + fn to_markdown_table_entry(&self) -> String { + format!( + "| {} | `{}` | {} | {} |", + self.name, + self.default, + self.doc + .split('.') + .next() + .unwrap_or("") + .replace('|', "\\|") + .replace("\n ", " "), + self.lints + .iter() + .map(|name| name.to_string().split_whitespace().next().unwrap().to_string()) + .map(|name| format!("[{name}](https://rust-lang.github.io/rust-clippy/master/index.html#{name})")) + .join(" ") + ) + } } fn collect_configs() -> Vec { From 7d1609dce356b9b603702f1ba0011f2fee949787 Mon Sep 17 00:00:00 2001 From: Tyler Weaver Date: Fri, 13 Jan 2023 15:32:04 -0700 Subject: [PATCH 4/7] Document configurations in table and paragraphs Signed-off-by: Tyler Weaver --- README.md | 9 +- book/src/configuration.md | 9 +- book/src/lint_configuration.md | 566 ++++++++++++++++-- clippy_lints/src/utils/conf.rs | 3 +- .../internal_lints/metadata_collector.rs | 43 +- 5 files changed, 551 insertions(+), 79 deletions(-) diff --git a/README.md b/README.md index 2ba095368..ab44db694 100644 --- a/README.md +++ b/README.md @@ -196,11 +196,10 @@ avoid-breaking-exported-api = false disallowed-names = ["toto", "tata", "titi"] ``` -See the [list of configurable lints](https://rust-lang.github.io/rust-clippy/master/index.html#Configuration), -the lint descriptions contain the names and meanings of these configuration variables. - -See [table of lint configurations](https://doc.rust-lang.org/nightly/clippy/lint_configuration.html) -to see what configuration options you can set and the lints they configure. +The [table of configurations](https://doc.rust-lang.org/nightly/clippy/lint_configuration.html) +contains all config values, their default, and a list of lints they affect. +Each [configurable lint](https://rust-lang.github.io/rust-clippy/master/index.html#Configuration) +, also contains information about these values. For configurations that are a list type with default values such as [disallowed-names](https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_names), diff --git a/book/src/configuration.md b/book/src/configuration.md index e68f30be4..87f4a697a 100644 --- a/book/src/configuration.md +++ b/book/src/configuration.md @@ -10,11 +10,10 @@ avoid-breaking-exported-api = false disallowed-names = ["toto", "tata", "titi"] ``` -See the [list of configurable lints](https://rust-lang.github.io/rust-clippy/master/index.html#Configuration), -the lint descriptions contain the names and meanings of these configuration variables. - -See [table of lint configurations](./lint_configuration.md) -to see what configuration options you can set and the lints they configure. +The [table of configurations](./lint_configuration.md) +contains all config values, their default, and a list of lints they affect. +Each [configurable lint](https://rust-lang.github.io/rust-clippy/master/index.html#Configuration) +, also contains information about these values. For configurations that are a list type with default values such as [disallowed-names](https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_names), diff --git a/book/src/lint_configuration.md b/book/src/lint_configuration.md index 102ed7ad2..cfaaefe3e 100644 --- a/book/src/lint_configuration.md +++ b/book/src/lint_configuration.md @@ -1,52 +1,518 @@ -## Configuration Options +## Lint Configuration Options +|
Option
| Default Value | +|--|--| +| [arithmetic-side-effects-allowed](#arithmetic-side-effects-allowed) | `{}` | +| [arithmetic-side-effects-allowed-binary](#arithmetic-side-effects-allowed-binary) | `[]` | +| [arithmetic-side-effects-allowed-unary](#arithmetic-side-effects-allowed-unary) | `{}` | +| [avoid-breaking-exported-api](#avoid-breaking-exported-api) | `true` | +| [msrv](#msrv) | `None` | +| [cognitive-complexity-threshold](#cognitive-complexity-threshold) | `25` | +| [disallowed-names](#disallowed-names) | `["foo", "baz", "quux"]` | +| [doc-valid-idents](#doc-valid-idents) | `["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"]` | +| [too-many-arguments-threshold](#too-many-arguments-threshold) | `7` | +| [type-complexity-threshold](#type-complexity-threshold) | `250` | +| [single-char-binding-names-threshold](#single-char-binding-names-threshold) | `4` | +| [too-large-for-stack](#too-large-for-stack) | `200` | +| [enum-variant-name-threshold](#enum-variant-name-threshold) | `3` | +| [enum-variant-size-threshold](#enum-variant-size-threshold) | `200` | +| [verbose-bit-mask-threshold](#verbose-bit-mask-threshold) | `1` | +| [literal-representation-threshold](#literal-representation-threshold) | `16384` | +| [trivial-copy-size-limit](#trivial-copy-size-limit) | `None` | +| [pass-by-value-size-limit](#pass-by-value-size-limit) | `256` | +| [too-many-lines-threshold](#too-many-lines-threshold) | `100` | +| [array-size-threshold](#array-size-threshold) | `512000` | +| [vec-box-size-threshold](#vec-box-size-threshold) | `4096` | +| [max-trait-bounds](#max-trait-bounds) | `3` | +| [max-struct-bools](#max-struct-bools) | `3` | +| [max-fn-params-bools](#max-fn-params-bools) | `3` | +| [warn-on-all-wildcard-imports](#warn-on-all-wildcard-imports) | `false` | +| [disallowed-macros](#disallowed-macros) | `[]` | +| [disallowed-methods](#disallowed-methods) | `[]` | +| [disallowed-types](#disallowed-types) | `[]` | +| [unreadable-literal-lint-fractions](#unreadable-literal-lint-fractions) | `true` | +| [upper-case-acronyms-aggressive](#upper-case-acronyms-aggressive) | `false` | +| [matches-for-let-else](#matches-for-let-else) | `WellKnownTypes` | +| [cargo-ignore-publish](#cargo-ignore-publish) | `false` | +| [standard-macro-braces](#standard-macro-braces) | `[]` | +| [enforced-import-renames](#enforced-import-renames) | `[]` | +| [allowed-scripts](#allowed-scripts) | `["Latin"]` | +| [enable-raw-pointer-heuristic-for-send](#enable-raw-pointer-heuristic-for-send) | `true` | +| [max-suggested-slice-pattern-length](#max-suggested-slice-pattern-length) | `3` | +| [max-include-file-size](#max-include-file-size) | `1000000` | +| [allow-expect-in-tests](#allow-expect-in-tests) | `false` | +| [allow-unwrap-in-tests](#allow-unwrap-in-tests) | `false` | +| [allow-dbg-in-tests](#allow-dbg-in-tests) | `false` | +| [allow-print-in-tests](#allow-print-in-tests) | `false` | +| [large-error-threshold](#large-error-threshold) | `128` | +| [ignore-interior-mutability](#ignore-interior-mutability) | `["bytes::Bytes"]` | +| [allow-mixed-uninlined-format-args](#allow-mixed-uninlined-format-args) | `true` | +| [suppress-restriction-lint-in-const](#suppress-restriction-lint-in-const) | `false` | + +### arithmetic-side-effects-allowed +Suppress checking of the passed type names in all types of operations. + +If a specific operation is desired, consider using `arithmetic_side_effects_allowed_binary` or `arithmetic_side_effects_allowed_unary` instead. + +#### Example + +```toml +arithmetic-side-effects-allowed = ["SomeType", "AnotherType"] +``` + +#### Noteworthy + +A type, say `SomeType`, listed in this configuration has the same behavior of +`["SomeType" , "*"], ["*", "SomeType"]` in `arithmetic_side_effects_allowed_binary`. + +**Default Value:** `{}` (`rustc_data_structures::fx::FxHashSet`) + +* [arithmetic_side_effects](https://rust-lang.github.io/rust-clippy/master/index.html#arithmetic_side_effects) + + +### arithmetic-side-effects-allowed-binary +Suppress checking of the passed type pair names in binary operations like addition or +multiplication. + +Supports the "*" wildcard to indicate that a certain type won't trigger the lint regardless +of the involved counterpart. For example, `["SomeType", "*"]` or `["*", "AnotherType"]`. + +Pairs are asymmetric, which means that `["SomeType", "AnotherType"]` is not the same as +`["AnotherType", "SomeType"]`. + +#### Example + +```toml +arithmetic-side-effects-allowed-binary = [["SomeType" , "f32"], ["AnotherType", "*"]] +``` + +**Default Value:** `[]` (`Vec<[String; 2]>`) + +* [arithmetic_side_effects](https://rust-lang.github.io/rust-clippy/master/index.html#arithmetic_side_effects) + + +### arithmetic-side-effects-allowed-unary +Suppress checking of the passed type names in unary operations like "negation" (`-`). + +#### Example + +```toml +arithmetic-side-effects-allowed-unary = ["SomeType", "AnotherType"] +``` + +**Default Value:** `{}` (`rustc_data_structures::fx::FxHashSet`) + +* [arithmetic_side_effects](https://rust-lang.github.io/rust-clippy/master/index.html#arithmetic_side_effects) + + +### avoid-breaking-exported-api +Suppress lints whenever the suggested change would cause breakage for other crates. + +**Default Value:** `true` (`bool`) + +* [enum_variant_names](https://rust-lang.github.io/rust-clippy/master/index.html#enum_variant_names) +* [large_types_passed_by_value](https://rust-lang.github.io/rust-clippy/master/index.html#large_types_passed_by_value) +* [trivially_copy_pass_by_ref](https://rust-lang.github.io/rust-clippy/master/index.html#trivially_copy_pass_by_ref) +* [unnecessary_wraps](https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_wraps) +* [unused_self](https://rust-lang.github.io/rust-clippy/master/index.html#unused_self) +* [upper_case_acronyms](https://rust-lang.github.io/rust-clippy/master/index.html#upper_case_acronyms) +* [wrong_self_convention](https://rust-lang.github.io/rust-clippy/master/index.html#wrong_self_convention) +* [box_collection](https://rust-lang.github.io/rust-clippy/master/index.html#box_collection) +* [redundant_allocation](https://rust-lang.github.io/rust-clippy/master/index.html#redundant_allocation) +* [rc_buffer](https://rust-lang.github.io/rust-clippy/master/index.html#rc_buffer) +* [vec_box](https://rust-lang.github.io/rust-clippy/master/index.html#vec_box) +* [option_option](https://rust-lang.github.io/rust-clippy/master/index.html#option_option) +* [linkedlist](https://rust-lang.github.io/rust-clippy/master/index.html#linkedlist) +* [rc_mutex](https://rust-lang.github.io/rust-clippy/master/index.html#rc_mutex) + + +### msrv +The minimum rust version that the project supports + +**Default Value:** `None` (`Option`) + +* [manual_split_once](https://rust-lang.github.io/rust-clippy/master/index.html#manual_split_once) +* [manual_str_repeat](https://rust-lang.github.io/rust-clippy/master/index.html#manual_str_repeat) +* [cloned_instead_of_copied](https://rust-lang.github.io/rust-clippy/master/index.html#cloned_instead_of_copied) +* [redundant_field_names](https://rust-lang.github.io/rust-clippy/master/index.html#redundant_field_names) +* [redundant_static_lifetimes](https://rust-lang.github.io/rust-clippy/master/index.html#redundant_static_lifetimes) +* [filter_map_next](https://rust-lang.github.io/rust-clippy/master/index.html#filter_map_next) +* [checked_conversions](https://rust-lang.github.io/rust-clippy/master/index.html#checked_conversions) +* [manual_range_contains](https://rust-lang.github.io/rust-clippy/master/index.html#manual_range_contains) +* [use_self](https://rust-lang.github.io/rust-clippy/master/index.html#use_self) +* [mem_replace_with_default](https://rust-lang.github.io/rust-clippy/master/index.html#mem_replace_with_default) +* [manual_non_exhaustive](https://rust-lang.github.io/rust-clippy/master/index.html#manual_non_exhaustive) +* [option_as_ref_deref](https://rust-lang.github.io/rust-clippy/master/index.html#option_as_ref_deref) +* [map_unwrap_or](https://rust-lang.github.io/rust-clippy/master/index.html#map_unwrap_or) +* [match_like_matches_macro](https://rust-lang.github.io/rust-clippy/master/index.html#match_like_matches_macro) +* [manual_strip](https://rust-lang.github.io/rust-clippy/master/index.html#manual_strip) +* [missing_const_for_fn](https://rust-lang.github.io/rust-clippy/master/index.html#missing_const_for_fn) +* [unnested_or_patterns](https://rust-lang.github.io/rust-clippy/master/index.html#unnested_or_patterns) +* [from_over_into](https://rust-lang.github.io/rust-clippy/master/index.html#from_over_into) +* [ptr_as_ptr](https://rust-lang.github.io/rust-clippy/master/index.html#ptr_as_ptr) +* [if_then_some_else_none](https://rust-lang.github.io/rust-clippy/master/index.html#if_then_some_else_none) +* [approx_constant](https://rust-lang.github.io/rust-clippy/master/index.html#approx_constant) +* [deprecated_cfg_attr](https://rust-lang.github.io/rust-clippy/master/index.html#deprecated_cfg_attr) +* [index_refutable_slice](https://rust-lang.github.io/rust-clippy/master/index.html#index_refutable_slice) +* [map_clone](https://rust-lang.github.io/rust-clippy/master/index.html#map_clone) +* [borrow_as_ptr](https://rust-lang.github.io/rust-clippy/master/index.html#borrow_as_ptr) +* [manual_bits](https://rust-lang.github.io/rust-clippy/master/index.html#manual_bits) +* [err_expect](https://rust-lang.github.io/rust-clippy/master/index.html#err_expect) +* [cast_abs_to_unsigned](https://rust-lang.github.io/rust-clippy/master/index.html#cast_abs_to_unsigned) +* [uninlined_format_args](https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args) +* [manual_clamp](https://rust-lang.github.io/rust-clippy/master/index.html#manual_clamp) +* [manual_let_else](https://rust-lang.github.io/rust-clippy/master/index.html#manual_let_else) +* [unchecked_duration_subtraction](https://rust-lang.github.io/rust-clippy/master/index.html#unchecked_duration_subtraction) + + +### cognitive-complexity-threshold +The maximum cognitive complexity a function can have + +**Default Value:** `25` (`u64`) + +* [cognitive_complexity](https://rust-lang.github.io/rust-clippy/master/index.html#cognitive_complexity) + + +### disallowed-names +The list of disallowed names to lint about. NB: `bar` is not here since it has legitimate uses. The value +`".."` can be used as part of the list to indicate, that the configured values should be appended to the +default configuration of Clippy. By default any configuration will replace the default value. + +**Default Value:** `["foo", "baz", "quux"]` (`Vec`) + +* [disallowed_names](https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_names) + + +### doc-valid-idents +The list of words this lint should not consider as identifiers needing ticks. The value +`".."` can be used as part of the list to indicate, that the configured values should be appended to the +default configuration of Clippy. By default any configuraction will replace the default value. For example: +* `doc-valid-idents = ["ClipPy"]` would replace the default list with `["ClipPy"]`. +* `doc-valid-idents = ["ClipPy", ".."]` would append `ClipPy` to the default list. + +Default list: + +**Default Value:** `["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"]` (`Vec`) + +* [doc_markdown](https://rust-lang.github.io/rust-clippy/master/index.html#doc_markdown) + + +### too-many-arguments-threshold +The maximum number of argument a function or method can have + +**Default Value:** `7` (`u64`) + +* [too_many_arguments](https://rust-lang.github.io/rust-clippy/master/index.html#too_many_arguments) + + +### type-complexity-threshold +The maximum complexity a type can have + +**Default Value:** `250` (`u64`) + +* [type_complexity](https://rust-lang.github.io/rust-clippy/master/index.html#type_complexity) + + +### single-char-binding-names-threshold +The maximum number of single char bindings a scope may have + +**Default Value:** `4` (`u64`) + +* [many_single_char_names](https://rust-lang.github.io/rust-clippy/master/index.html#many_single_char_names) + + +### too-large-for-stack +The maximum size of objects (in bytes) that will be linted. Larger objects are ok on the heap + +**Default Value:** `200` (`u64`) + +* [boxed_local](https://rust-lang.github.io/rust-clippy/master/index.html#boxed_local) +* [useless_vec](https://rust-lang.github.io/rust-clippy/master/index.html#useless_vec) + + +### enum-variant-name-threshold +The minimum number of enum variants for the lints about variant names to trigger + +**Default Value:** `3` (`u64`) + +* [enum_variant_names](https://rust-lang.github.io/rust-clippy/master/index.html#enum_variant_names) + + +### enum-variant-size-threshold +The maximum size of an enum's variant to avoid box suggestion + +**Default Value:** `200` (`u64`) + +* [large_enum_variant](https://rust-lang.github.io/rust-clippy/master/index.html#large_enum_variant) + + +### verbose-bit-mask-threshold +The maximum allowed size of a bit mask before suggesting to use 'trailing_zeros' + +**Default Value:** `1` (`u64`) + +* [verbose_bit_mask](https://rust-lang.github.io/rust-clippy/master/index.html#verbose_bit_mask) + + +### literal-representation-threshold +The lower bound for linting decimal literals + +**Default Value:** `16384` (`u64`) + +* [decimal_literal_representation](https://rust-lang.github.io/rust-clippy/master/index.html#decimal_literal_representation) + + +### trivial-copy-size-limit +The maximum size (in bytes) to consider a `Copy` type for passing by value instead of by reference. + +**Default Value:** `None` (`Option`) + +* [trivially_copy_pass_by_ref](https://rust-lang.github.io/rust-clippy/master/index.html#trivially_copy_pass_by_ref) + + +### pass-by-value-size-limit +The minimum size (in bytes) to consider a type for passing by reference instead of by value. + +**Default Value:** `256` (`u64`) + +* [large_type_pass_by_move](https://rust-lang.github.io/rust-clippy/master/index.html#large_type_pass_by_move) + + +### too-many-lines-threshold +The maximum number of lines a function or method can have + +**Default Value:** `100` (`u64`) + +* [too_many_lines](https://rust-lang.github.io/rust-clippy/master/index.html#too_many_lines) + + +### array-size-threshold +The maximum allowed size for arrays on the stack + +**Default Value:** `512000` (`u128`) + +* [large_stack_arrays](https://rust-lang.github.io/rust-clippy/master/index.html#large_stack_arrays) +* [large_const_arrays](https://rust-lang.github.io/rust-clippy/master/index.html#large_const_arrays) + + +### vec-box-size-threshold +The size of the boxed type in bytes, where boxing in a `Vec` is allowed + +**Default Value:** `4096` (`u64`) + +* [vec_box](https://rust-lang.github.io/rust-clippy/master/index.html#vec_box) + + +### max-trait-bounds +The maximum number of bounds a trait can have to be linted + +**Default Value:** `3` (`u64`) + +* [type_repetition_in_bounds](https://rust-lang.github.io/rust-clippy/master/index.html#type_repetition_in_bounds) + + +### max-struct-bools +The maximum number of bool fields a struct can have + +**Default Value:** `3` (`u64`) + +* [struct_excessive_bools](https://rust-lang.github.io/rust-clippy/master/index.html#struct_excessive_bools) + + +### max-fn-params-bools +The maximum number of bool parameters a function can have + +**Default Value:** `3` (`u64`) + +* [fn_params_excessive_bools](https://rust-lang.github.io/rust-clippy/master/index.html#fn_params_excessive_bools) + + +### warn-on-all-wildcard-imports +Whether to allow certain wildcard imports (prelude, super in tests). + +**Default Value:** `false` (`bool`) + +* [wildcard_imports](https://rust-lang.github.io/rust-clippy/master/index.html#wildcard_imports) + + +### disallowed-macros +The list of disallowed macros, written as fully qualified paths. + +**Default Value:** `[]` (`Vec`) + +* [disallowed_macros](https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_macros) + + +### disallowed-methods +The list of disallowed methods, written as fully qualified paths. + +**Default Value:** `[]` (`Vec`) + +* [disallowed_methods](https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_methods) + + +### disallowed-types +The list of disallowed types, written as fully qualified paths. + +**Default Value:** `[]` (`Vec`) + +* [disallowed_types](https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_types) + + +### unreadable-literal-lint-fractions +Should the fraction of a decimal be linted to include separators. + +**Default Value:** `true` (`bool`) + +* [unreadable_literal](https://rust-lang.github.io/rust-clippy/master/index.html#unreadable_literal) + + +### upper-case-acronyms-aggressive +Enables verbose mode. Triggers if there is more than one uppercase char next to each other + +**Default Value:** `false` (`bool`) + +* [upper_case_acronyms](https://rust-lang.github.io/rust-clippy/master/index.html#upper_case_acronyms) + + +### matches-for-let-else +Whether the matches should be considered by the lint, and whether there should +be filtering for common types. + +**Default Value:** `WellKnownTypes` (`crate::manual_let_else::MatchLintBehaviour`) + +* [manual_let_else](https://rust-lang.github.io/rust-clippy/master/index.html#manual_let_else) + + +### cargo-ignore-publish +For internal testing only, ignores the current `publish` settings in the Cargo manifest. + +**Default Value:** `false` (`bool`) + +* [_cargo_common_metadata](https://rust-lang.github.io/rust-clippy/master/index.html#_cargo_common_metadata) + + +### standard-macro-braces +Enforce the named macros always use the braces specified. + +A `MacroMatcher` can be added like so `{ name = "macro_name", brace = "(" }`. If the macro +is could be used with a full path two `MacroMatcher`s have to be added one with the full path +`crate_name::macro_name` and one with just the macro name. + +**Default Value:** `[]` (`Vec`) + +* [nonstandard_macro_braces](https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces) + + +### enforced-import-renames +The list of imports to always rename, a fully qualified path followed by the rename. + +**Default Value:** `[]` (`Vec`) + +* [missing_enforced_import_renames](https://rust-lang.github.io/rust-clippy/master/index.html#missing_enforced_import_renames) + + +### allowed-scripts +The list of unicode scripts allowed to be used in the scope. + +**Default Value:** `["Latin"]` (`Vec`) + +* [disallowed_script_idents](https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_script_idents) + + +### enable-raw-pointer-heuristic-for-send +Whether to apply the raw pointer heuristic to determine if a type is `Send`. + +**Default Value:** `true` (`bool`) + +* [non_send_fields_in_send_ty](https://rust-lang.github.io/rust-clippy/master/index.html#non_send_fields_in_send_ty) + + +### max-suggested-slice-pattern-length +When Clippy suggests using a slice pattern, this is the maximum number of elements allowed in +the slice pattern that is suggested. If more elements would be necessary, the lint is suppressed. +For example, `[_, _, _, e, ..]` is a slice pattern with 4 elements. + +**Default Value:** `3` (`u64`) + +* [index_refutable_slice](https://rust-lang.github.io/rust-clippy/master/index.html#index_refutable_slice) + + +### max-include-file-size +The maximum size of a file included via `include_bytes!()` or `include_str!()`, in bytes + +**Default Value:** `1000000` (`u64`) + +* [large_include_file](https://rust-lang.github.io/rust-clippy/master/index.html#large_include_file) + + +### allow-expect-in-tests +Whether `expect` should be allowed within `#[cfg(test)]` + +**Default Value:** `false` (`bool`) + +* [expect_used](https://rust-lang.github.io/rust-clippy/master/index.html#expect_used) + + +### allow-unwrap-in-tests +Whether `unwrap` should be allowed in test cfg + +**Default Value:** `false` (`bool`) + +* [unwrap_used](https://rust-lang.github.io/rust-clippy/master/index.html#unwrap_used) + + +### allow-dbg-in-tests +Whether `dbg!` should be allowed in test functions + +**Default Value:** `false` (`bool`) + +* [dbg_macro](https://rust-lang.github.io/rust-clippy/master/index.html#dbg_macro) + + +### allow-print-in-tests +Whether print macros (ex. `println!`) should be allowed in test functions + +**Default Value:** `false` (`bool`) + +* [print_stdout](https://rust-lang.github.io/rust-clippy/master/index.html#print_stdout) +* [print_stderr](https://rust-lang.github.io/rust-clippy/master/index.html#print_stderr) + + +### large-error-threshold +The maximum size of the `Err`-variant in a `Result` returned from a function + +**Default Value:** `128` (`u64`) + +* [result_large_err](https://rust-lang.github.io/rust-clippy/master/index.html#result_large_err) + + +### ignore-interior-mutability +A list of paths to types that should be treated like `Arc`, i.e. ignored but +for the generic parameters for determining interior mutability + +**Default Value:** `["bytes::Bytes"]` (`Vec`) + +* [mutable_key](https://rust-lang.github.io/rust-clippy/master/index.html#mutable_key) + + +### allow-mixed-uninlined-format-args +Whether to allow mixed uninlined format args, e.g. `format!("{} {}", a, foo.bar)` + +**Default Value:** `true` (`bool`) + +* [uninlined_format_args](https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args) + + +### suppress-restriction-lint-in-const +In same +cases the restructured operation might not be unavoidable, as the +suggested counterparts are unavailable in constant code. This +configuration will cause restriction lints to trigger even +if no suggestion can be made. + +**Default Value:** `false` (`bool`) + +* [indexing_slicing](https://rust-lang.github.io/rust-clippy/master/index.html#indexing_slicing) + -| Option | Default | Description | Lints | -|--|--|--|--| -| arithmetic-side-effects-allowed | `{}` | Suppress checking of the passed type names in all types of operations | [arithmetic_side_effects](https://rust-lang.github.io/rust-clippy/master/index.html#arithmetic_side_effects) | -| arithmetic-side-effects-allowed-binary | `[]` | Suppress checking of the passed type pair names in binary operations like addition or multiplication | [arithmetic_side_effects](https://rust-lang.github.io/rust-clippy/master/index.html#arithmetic_side_effects) | -| arithmetic-side-effects-allowed-unary | `{}` | Suppress checking of the passed type names in unary operations like "negation" (`-`) | [arithmetic_side_effects](https://rust-lang.github.io/rust-clippy/master/index.html#arithmetic_side_effects) | -| avoid-breaking-exported-api | `true` | Suppress lints whenever the suggested change would cause breakage for other crates | [enum_variant_names](https://rust-lang.github.io/rust-clippy/master/index.html#enum_variant_names) [large_types_passed_by_value](https://rust-lang.github.io/rust-clippy/master/index.html#large_types_passed_by_value) [trivially_copy_pass_by_ref](https://rust-lang.github.io/rust-clippy/master/index.html#trivially_copy_pass_by_ref) [unnecessary_wraps](https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_wraps) [unused_self](https://rust-lang.github.io/rust-clippy/master/index.html#unused_self) [upper_case_acronyms](https://rust-lang.github.io/rust-clippy/master/index.html#upper_case_acronyms) [wrong_self_convention](https://rust-lang.github.io/rust-clippy/master/index.html#wrong_self_convention) [box_collection](https://rust-lang.github.io/rust-clippy/master/index.html#box_collection) [redundant_allocation](https://rust-lang.github.io/rust-clippy/master/index.html#redundant_allocation) [rc_buffer](https://rust-lang.github.io/rust-clippy/master/index.html#rc_buffer) [vec_box](https://rust-lang.github.io/rust-clippy/master/index.html#vec_box) [option_option](https://rust-lang.github.io/rust-clippy/master/index.html#option_option) [linkedlist](https://rust-lang.github.io/rust-clippy/master/index.html#linkedlist) [rc_mutex](https://rust-lang.github.io/rust-clippy/master/index.html#rc_mutex) | -| msrv | `None` | The minimum rust version that the project supports | [manual_split_once](https://rust-lang.github.io/rust-clippy/master/index.html#manual_split_once) [manual_str_repeat](https://rust-lang.github.io/rust-clippy/master/index.html#manual_str_repeat) [cloned_instead_of_copied](https://rust-lang.github.io/rust-clippy/master/index.html#cloned_instead_of_copied) [redundant_field_names](https://rust-lang.github.io/rust-clippy/master/index.html#redundant_field_names) [redundant_static_lifetimes](https://rust-lang.github.io/rust-clippy/master/index.html#redundant_static_lifetimes) [filter_map_next](https://rust-lang.github.io/rust-clippy/master/index.html#filter_map_next) [checked_conversions](https://rust-lang.github.io/rust-clippy/master/index.html#checked_conversions) [manual_range_contains](https://rust-lang.github.io/rust-clippy/master/index.html#manual_range_contains) [use_self](https://rust-lang.github.io/rust-clippy/master/index.html#use_self) [mem_replace_with_default](https://rust-lang.github.io/rust-clippy/master/index.html#mem_replace_with_default) [manual_non_exhaustive](https://rust-lang.github.io/rust-clippy/master/index.html#manual_non_exhaustive) [option_as_ref_deref](https://rust-lang.github.io/rust-clippy/master/index.html#option_as_ref_deref) [map_unwrap_or](https://rust-lang.github.io/rust-clippy/master/index.html#map_unwrap_or) [match_like_matches_macro](https://rust-lang.github.io/rust-clippy/master/index.html#match_like_matches_macro) [manual_strip](https://rust-lang.github.io/rust-clippy/master/index.html#manual_strip) [missing_const_for_fn](https://rust-lang.github.io/rust-clippy/master/index.html#missing_const_for_fn) [unnested_or_patterns](https://rust-lang.github.io/rust-clippy/master/index.html#unnested_or_patterns) [from_over_into](https://rust-lang.github.io/rust-clippy/master/index.html#from_over_into) [ptr_as_ptr](https://rust-lang.github.io/rust-clippy/master/index.html#ptr_as_ptr) [if_then_some_else_none](https://rust-lang.github.io/rust-clippy/master/index.html#if_then_some_else_none) [approx_constant](https://rust-lang.github.io/rust-clippy/master/index.html#approx_constant) [deprecated_cfg_attr](https://rust-lang.github.io/rust-clippy/master/index.html#deprecated_cfg_attr) [index_refutable_slice](https://rust-lang.github.io/rust-clippy/master/index.html#index_refutable_slice) [map_clone](https://rust-lang.github.io/rust-clippy/master/index.html#map_clone) [borrow_as_ptr](https://rust-lang.github.io/rust-clippy/master/index.html#borrow_as_ptr) [manual_bits](https://rust-lang.github.io/rust-clippy/master/index.html#manual_bits) [err_expect](https://rust-lang.github.io/rust-clippy/master/index.html#err_expect) [cast_abs_to_unsigned](https://rust-lang.github.io/rust-clippy/master/index.html#cast_abs_to_unsigned) [uninlined_format_args](https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args) [manual_clamp](https://rust-lang.github.io/rust-clippy/master/index.html#manual_clamp) [manual_let_else](https://rust-lang.github.io/rust-clippy/master/index.html#manual_let_else) [unchecked_duration_subtraction](https://rust-lang.github.io/rust-clippy/master/index.html#unchecked_duration_subtraction) | -| cognitive-complexity-threshold | `25` | The maximum cognitive complexity a function can have | [cognitive_complexity](https://rust-lang.github.io/rust-clippy/master/index.html#cognitive_complexity) | -| disallowed-names | `["foo", "baz", "quux"]` | The list of disallowed names to lint about | [disallowed_names](https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_names) | -| doc-valid-idents | `["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"]` | The list of words this lint should not consider as identifiers needing ticks | [doc_markdown](https://rust-lang.github.io/rust-clippy/master/index.html#doc_markdown) | -| too-many-arguments-threshold | `7` | The maximum number of argument a function or method can have | [too_many_arguments](https://rust-lang.github.io/rust-clippy/master/index.html#too_many_arguments) | -| type-complexity-threshold | `250` | The maximum complexity a type can have | [type_complexity](https://rust-lang.github.io/rust-clippy/master/index.html#type_complexity) | -| single-char-binding-names-threshold | `4` | The maximum number of single char bindings a scope may have | [many_single_char_names](https://rust-lang.github.io/rust-clippy/master/index.html#many_single_char_names) | -| too-large-for-stack | `200` | The maximum size of objects (in bytes) that will be linted | [boxed_local](https://rust-lang.github.io/rust-clippy/master/index.html#boxed_local) [useless_vec](https://rust-lang.github.io/rust-clippy/master/index.html#useless_vec) | -| enum-variant-name-threshold | `3` | The minimum number of enum variants for the lints about variant names to trigger | [enum_variant_names](https://rust-lang.github.io/rust-clippy/master/index.html#enum_variant_names) | -| enum-variant-size-threshold | `200` | The maximum size of an enum's variant to avoid box suggestion | [large_enum_variant](https://rust-lang.github.io/rust-clippy/master/index.html#large_enum_variant) | -| verbose-bit-mask-threshold | `1` | The maximum allowed size of a bit mask before suggesting to use 'trailing_zeros' | [verbose_bit_mask](https://rust-lang.github.io/rust-clippy/master/index.html#verbose_bit_mask) | -| literal-representation-threshold | `16384` | The lower bound for linting decimal literals | [decimal_literal_representation](https://rust-lang.github.io/rust-clippy/master/index.html#decimal_literal_representation) | -| trivial-copy-size-limit | `None` | The maximum size (in bytes) to consider a `Copy` type for passing by value instead of by reference | [trivially_copy_pass_by_ref](https://rust-lang.github.io/rust-clippy/master/index.html#trivially_copy_pass_by_ref) | -| pass-by-value-size-limit | `256` | The minimum size (in bytes) to consider a type for passing by reference instead of by value | [large_type_pass_by_move](https://rust-lang.github.io/rust-clippy/master/index.html#large_type_pass_by_move) | -| too-many-lines-threshold | `100` | The maximum number of lines a function or method can have | [too_many_lines](https://rust-lang.github.io/rust-clippy/master/index.html#too_many_lines) | -| array-size-threshold | `512000` | The maximum allowed size for arrays on the stack | [large_stack_arrays](https://rust-lang.github.io/rust-clippy/master/index.html#large_stack_arrays) [large_const_arrays](https://rust-lang.github.io/rust-clippy/master/index.html#large_const_arrays) | -| vec-box-size-threshold | `4096` | The size of the boxed type in bytes, where boxing in a `Vec` is allowed | [vec_box](https://rust-lang.github.io/rust-clippy/master/index.html#vec_box) | -| max-trait-bounds | `3` | The maximum number of bounds a trait can have to be linted | [type_repetition_in_bounds](https://rust-lang.github.io/rust-clippy/master/index.html#type_repetition_in_bounds) | -| max-struct-bools | `3` | The maximum number of bool fields a struct can have | [struct_excessive_bools](https://rust-lang.github.io/rust-clippy/master/index.html#struct_excessive_bools) | -| max-fn-params-bools | `3` | The maximum number of bool parameters a function can have | [fn_params_excessive_bools](https://rust-lang.github.io/rust-clippy/master/index.html#fn_params_excessive_bools) | -| warn-on-all-wildcard-imports | `false` | Whether to allow certain wildcard imports (prelude, super in tests) | [wildcard_imports](https://rust-lang.github.io/rust-clippy/master/index.html#wildcard_imports) | -| disallowed-macros | `[]` | The list of disallowed macros, written as fully qualified paths | [disallowed_macros](https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_macros) | -| disallowed-methods | `[]` | The list of disallowed methods, written as fully qualified paths | [disallowed_methods](https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_methods) | -| disallowed-types | `[]` | The list of disallowed types, written as fully qualified paths | [disallowed_types](https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_types) | -| unreadable-literal-lint-fractions | `true` | Should the fraction of a decimal be linted to include separators | [unreadable_literal](https://rust-lang.github.io/rust-clippy/master/index.html#unreadable_literal) | -| upper-case-acronyms-aggressive | `false` | Enables verbose mode | [upper_case_acronyms](https://rust-lang.github.io/rust-clippy/master/index.html#upper_case_acronyms) | -| matches-for-let-else | `WellKnownTypes` | Whether the matches should be considered by the lint, and whether there should be filtering for common types | [manual_let_else](https://rust-lang.github.io/rust-clippy/master/index.html#manual_let_else) | -| cargo-ignore-publish | `false` | For internal testing only, ignores the current `publish` settings in the Cargo manifest | [_cargo_common_metadata](https://rust-lang.github.io/rust-clippy/master/index.html#_cargo_common_metadata) | -| standard-macro-braces | `[]` | Enforce the named macros always use the braces specified | [nonstandard_macro_braces](https://rust-lang.github.io/rust-clippy/master/index.html#nonstandard_macro_braces) | -| enforced-import-renames | `[]` | The list of imports to always rename, a fully qualified path followed by the rename | [missing_enforced_import_renames](https://rust-lang.github.io/rust-clippy/master/index.html#missing_enforced_import_renames) | -| allowed-scripts | `["Latin"]` | The list of unicode scripts allowed to be used in the scope | [disallowed_script_idents](https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_script_idents) | -| enable-raw-pointer-heuristic-for-send | `true` | Whether to apply the raw pointer heuristic to determine if a type is `Send` | [non_send_fields_in_send_ty](https://rust-lang.github.io/rust-clippy/master/index.html#non_send_fields_in_send_ty) | -| max-suggested-slice-pattern-length | `3` | When Clippy suggests using a slice pattern, this is the maximum number of elements allowed in the slice pattern that is suggested | [index_refutable_slice](https://rust-lang.github.io/rust-clippy/master/index.html#index_refutable_slice) | -| await-holding-invalid-types | `[]` | [ERROR] MALFORMED DOC COMMENT | | -| max-include-file-size | `1000000` | The maximum size of a file included via `include_bytes!()` or `include_str!()`, in bytes | [large_include_file](https://rust-lang.github.io/rust-clippy/master/index.html#large_include_file) | -| allow-expect-in-tests | `false` | Whether `expect` should be allowed within `#[cfg(test)]` | [expect_used](https://rust-lang.github.io/rust-clippy/master/index.html#expect_used) | -| allow-unwrap-in-tests | `false` | Whether `unwrap` should be allowed in test cfg | [unwrap_used](https://rust-lang.github.io/rust-clippy/master/index.html#unwrap_used) | -| allow-dbg-in-tests | `false` | Whether `dbg!` should be allowed in test functions | [dbg_macro](https://rust-lang.github.io/rust-clippy/master/index.html#dbg_macro) | -| allow-print-in-tests | `false` | Whether print macros (ex | [print_stdout](https://rust-lang.github.io/rust-clippy/master/index.html#print_stdout) [print_stderr](https://rust-lang.github.io/rust-clippy/master/index.html#print_stderr) | -| large-error-threshold | `128` | The maximum size of the `Err`-variant in a `Result` returned from a function | [result_large_err](https://rust-lang.github.io/rust-clippy/master/index.html#result_large_err) | -| ignore-interior-mutability | `["bytes::Bytes"]` | A list of paths to types that should be treated like `Arc`, i | [mutable_key](https://rust-lang.github.io/rust-clippy/master/index.html#mutable_key) | -| allow-mixed-uninlined-format-args | `true` | Whether to allow mixed uninlined format args, e | [uninlined_format_args](https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args) | -| suppress-restriction-lint-in-const | `false` | In same cases the restructured operation might not be unavoidable, as the suggested counterparts are unavailable in constant code | [indexing_slicing](https://rust-lang.github.io/rust-clippy/master/index.html#indexing_slicing) | diff --git a/clippy_lints/src/utils/conf.rs b/clippy_lints/src/utils/conf.rs index c1589c771..f48be2759 100644 --- a/clippy_lints/src/utils/conf.rs +++ b/clippy_lints/src/utils/conf.rs @@ -219,7 +219,8 @@ define_Conf! { /// /// #### Noteworthy /// - /// A type, say `SomeType`, listed in this configuration has the same behavior of `["SomeType" , "*"], ["*", "SomeType"]` in `arithmetic_side_effects_allowed_binary`. + /// A type, say `SomeType`, listed in this configuration has the same behavior of + /// `["SomeType" , "*"], ["*", "SomeType"]` in `arithmetic_side_effects_allowed_binary`. (arithmetic_side_effects_allowed: rustc_data_structures::fx::FxHashSet = <_>::default()), /// Lint: ARITHMETIC_SIDE_EFFECTS. /// diff --git a/clippy_lints/src/utils/internal_lints/metadata_collector.rs b/clippy_lints/src/utils/internal_lints/metadata_collector.rs index c74f3b6e3..47604f693 100644 --- a/clippy_lints/src/utils/internal_lints/metadata_collector.rs +++ b/clippy_lints/src/utils/internal_lints/metadata_collector.rs @@ -180,13 +180,22 @@ This lint has the following configuration variables: }) } - fn get_markdown_table(&self) -> String { + fn configs_to_markdown(&self, map_fn: fn(&ClippyConfiguration) -> String) -> String { self.config .iter() .filter(|config| config.deprecation_reason.is_none()) - .map(ClippyConfiguration::to_markdown_table_entry) + .filter(|config| !config.lints.is_empty()) + .map(map_fn) .join("\n") } + + fn get_markdown_docs(&self) -> String { + format!( + "## Lint Configuration Options\n|
Option
| Default Value |\n|--|--|\n{}\n\n{}\n", + self.configs_to_markdown(ClippyConfiguration::to_markdown_table_entry), + self.configs_to_markdown(ClippyConfiguration::to_markdown_paragraph), + ) + } } impl Drop for MetadataCollector { @@ -230,12 +239,7 @@ impl Drop for MetadataCollector { .create(true) .open(MARKDOWN_OUTPUT_FILE) .unwrap(); - writeln!( - file, - "## Lint Configuration\n\n| Option | Default | Description | Lints |\n|--|--|--|--|\n{}\n", - self.get_markdown_table() - ) - .unwrap(); + writeln!(file, "{}", self.get_markdown_docs(),).unwrap(); } } @@ -537,24 +541,27 @@ impl ClippyConfiguration { } } - fn to_markdown_table_entry(&self) -> String { + fn to_markdown_paragraph(&self) -> String { format!( - "| {} | `{}` | {} | {} |", + "### {}\n{}\n\n**Default Value:** `{}` (`{}`)\n\n{}\n\n", self.name, - self.default, self.doc - .split('.') - .next() - .unwrap_or("") - .replace('|', "\\|") - .replace("\n ", " "), + .lines() + .map(|line| line.strip_prefix(" ").unwrap_or(line)) + .join("\n"), + self.default, + self.config_type, self.lints .iter() .map(|name| name.to_string().split_whitespace().next().unwrap().to_string()) - .map(|name| format!("[{name}](https://rust-lang.github.io/rust-clippy/master/index.html#{name})")) - .join(" ") + .map(|name| format!("* [{name}](https://rust-lang.github.io/rust-clippy/master/index.html#{name})")) + .join("\n"), ) } + + fn to_markdown_table_entry(&self) -> String { + format!("| [{}](#{}) | `{}` |", self.name, self.name, self.default) + } } fn collect_configs() -> Vec { From dc5ce488e7e14e2cebb90d9c1cd189c970ee415f Mon Sep 17 00:00:00 2001 From: Tyler Weaver Date: Sat, 14 Jan 2023 07:38:29 -0700 Subject: [PATCH 5/7] Move CI tests for collect-metadata to clippy_bors.yml --- .github/workflows/clippy_bors.yml | 5 +++++ .github/workflows/remark.yml | 3 --- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/clippy_bors.yml b/.github/workflows/clippy_bors.yml index 1bc457a94..24e677ce8 100644 --- a/.github/workflows/clippy_bors.yml +++ b/.github/workflows/clippy_bors.yml @@ -157,6 +157,11 @@ jobs: - name: Test metadata collection run: cargo collect-metadata + - name: Test lint_configuration.md is up-to-date + run: | + echo "run \`cargo collect-metadata\` if this fails" + git update-index --refresh + integration_build: needs: changelog runs-on: ubuntu-latest diff --git a/.github/workflows/remark.yml b/.github/workflows/remark.yml index 22925a753..81ef072bb 100644 --- a/.github/workflows/remark.yml +++ b/.github/workflows/remark.yml @@ -33,9 +33,6 @@ jobs: echo `pwd`/mdbook >> $GITHUB_PATH # Run - - name: cargo collect-metadata - run: cargo collect-metadata - - name: Check *.md files run: git ls-files -z '*.md' | xargs -0 -n 1 -I {} ./node_modules/.bin/remark {} -u lint -f > /dev/null From d950279a039b5a598c87b347ba5d2f151a071a98 Mon Sep 17 00:00:00 2001 From: Tyler Weaver Date: Sat, 14 Jan 2023 07:39:49 -0700 Subject: [PATCH 6/7] Document generating lint config docs for adding configuration --- book/src/development/adding_lints.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/book/src/development/adding_lints.md b/book/src/development/adding_lints.md index 8b4eee8c9..fd6e1f5ae 100644 --- a/book/src/development/adding_lints.md +++ b/book/src/development/adding_lints.md @@ -699,6 +699,10 @@ for some users. Adding a configuration is done in the following steps: `clippy.toml` file with the configuration value and a rust file that should be linted by Clippy. The test can otherwise be written as usual. +5. Update [Lint Configuration](../lint_configuration.md) + + Run `cargo collect-metadata` to generate documentation changes for the book. + [`clippy_lints::utils::conf`]: https://github.com/rust-lang/rust-clippy/blob/master/clippy_lints/src/utils/conf.rs [`clippy_lints` lib file]: https://github.com/rust-lang/rust-clippy/blob/master/clippy_lints/src/lib.rs [`tests/ui`]: https://github.com/rust-lang/rust-clippy/blob/master/tests/ui From c0da8acb72529fdfc156b006e9ee5d2f18f1a730 Mon Sep 17 00:00:00 2001 From: Tyler Weaver Date: Sat, 14 Jan 2023 11:10:40 -0700 Subject: [PATCH 7/7] Comment that lint_configuration.md is machine generated --- book/src/lint_configuration.md | 5 +++++ .../src/utils/internal_lints/metadata_collector.rs | 12 +++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/book/src/lint_configuration.md b/book/src/lint_configuration.md index cfaaefe3e..f79dbb50f 100644 --- a/book/src/lint_configuration.md +++ b/book/src/lint_configuration.md @@ -1,3 +1,8 @@ + + ## Lint Configuration Options |
Option
| Default Value | |--|--| diff --git a/clippy_lints/src/utils/internal_lints/metadata_collector.rs b/clippy_lints/src/utils/internal_lints/metadata_collector.rs index 47604f693..1995c3738 100644 --- a/clippy_lints/src/utils/internal_lints/metadata_collector.rs +++ b/clippy_lints/src/utils/internal_lints/metadata_collector.rs @@ -239,7 +239,17 @@ impl Drop for MetadataCollector { .create(true) .open(MARKDOWN_OUTPUT_FILE) .unwrap(); - writeln!(file, "{}", self.get_markdown_docs(),).unwrap(); + writeln!( + file, + " + +{}", + self.get_markdown_docs(), + ) + .unwrap(); } }