rust-clippy/book/src/lint_configuration.md

24 KiB

Lint Configuration Options

Option
Default Value
arithmetic-side-effects-allowed {}
arithmetic-side-effects-allowed-binary []
arithmetic-side-effects-allowed-unary {}
avoid-breaking-exported-api true
msrv None
cognitive-complexity-threshold 25
disallowed-names ["foo", "baz", "quux"]
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 7
type-complexity-threshold 250
single-char-binding-names-threshold 4
too-large-for-stack 200
enum-variant-name-threshold 3
enum-variant-size-threshold 200
verbose-bit-mask-threshold 1
literal-representation-threshold 16384
trivial-copy-size-limit None
pass-by-value-size-limit 256
too-many-lines-threshold 100
array-size-threshold 512000
vec-box-size-threshold 4096
max-trait-bounds 3
max-struct-bools 3
max-fn-params-bools 3
warn-on-all-wildcard-imports false
disallowed-macros []
disallowed-methods []
disallowed-types []
unreadable-literal-lint-fractions true
upper-case-acronyms-aggressive false
matches-for-let-else WellKnownTypes
cargo-ignore-publish false
standard-macro-braces []
enforced-import-renames []
allowed-scripts ["Latin"]
enable-raw-pointer-heuristic-for-send true
max-suggested-slice-pattern-length 3
await-holding-invalid-types []
max-include-file-size 1000000
allow-expect-in-tests false
allow-unwrap-in-tests false
allow-dbg-in-tests false
allow-print-in-tests false
large-error-threshold 128
ignore-interior-mutability ["bytes::Bytes"]
allow-mixed-uninlined-format-args true
suppress-restriction-lint-in-const false
missing-docs-in-crate-items 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

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<String>)

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

arithmetic-side-effects-allowed-binary = [["SomeType" , "f32"], ["AnotherType", "*"]]

Default Value: [] (Vec<[String; 2]>)

arithmetic-side-effects-allowed-unary

Suppress checking of the passed type names in unary operations like "negation" (-).

Example

arithmetic-side-effects-allowed-unary = ["SomeType", "AnotherType"]

Default Value: {} (rustc_data_structures::fx::FxHashSet<String>)

avoid-breaking-exported-api

Suppress lints whenever the suggested change would cause breakage for other crates.

Default Value: true (bool)

msrv

The minimum rust version that the project supports

Default Value: None (Option<String>)

cognitive-complexity-threshold

The maximum cognitive complexity a function can have

Default Value: 25 (u64)

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<String>)

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<String>)

too-many-arguments-threshold

The maximum number of argument a function or method can have

Default Value: 7 (u64)

type-complexity-threshold

The maximum complexity a type can have

Default Value: 250 (u64)

single-char-binding-names-threshold

The maximum number of single char bindings a scope may have

Default Value: 4 (u64)

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)

enum-variant-name-threshold

The minimum number of enum variants for the lints about variant names to trigger

Default Value: 3 (u64)

enum-variant-size-threshold

The maximum size of an enum's variant to avoid box suggestion

Default Value: 200 (u64)

verbose-bit-mask-threshold

The maximum allowed size of a bit mask before suggesting to use 'trailing_zeros'

Default Value: 1 (u64)

literal-representation-threshold

The lower bound for linting decimal literals

Default Value: 16384 (u64)

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<u64>)

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)

too-many-lines-threshold

The maximum number of lines a function or method can have

Default Value: 100 (u64)

array-size-threshold

The maximum allowed size for arrays on the stack

Default Value: 512000 (u64)

vec-box-size-threshold

The size of the boxed type in bytes, where boxing in a Vec is allowed

Default Value: 4096 (u64)

max-trait-bounds

The maximum number of bounds a trait can have to be linted

Default Value: 3 (u64)

max-struct-bools

The maximum number of bool fields a struct can have

Default Value: 3 (u64)

max-fn-params-bools

The maximum number of bool parameters a function can have

Default Value: 3 (u64)

warn-on-all-wildcard-imports

Whether to allow certain wildcard imports (prelude, super in tests).

Default Value: false (bool)

disallowed-macros

The list of disallowed macros, written as fully qualified paths.

Default Value: [] (Vec<crate::utils::conf::DisallowedPath>)

disallowed-methods

The list of disallowed methods, written as fully qualified paths.

Default Value: [] (Vec<crate::utils::conf::DisallowedPath>)

disallowed-types

The list of disallowed types, written as fully qualified paths.

Default Value: [] (Vec<crate::utils::conf::DisallowedPath>)

unreadable-literal-lint-fractions

Should the fraction of a decimal be linted to include separators.

Default Value: true (bool)

upper-case-acronyms-aggressive

Enables verbose mode. Triggers if there is more than one uppercase char next to each other

Default Value: false (bool)

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)

cargo-ignore-publish

For internal testing only, ignores the current publish settings in the Cargo manifest.

Default Value: false (bool)

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 MacroMatchers have to be added one with the full path crate_name::macro_name and one with just the macro name.

Default Value: [] (Vec<crate::nonstandard_macro_braces::MacroMatcher>)

enforced-import-renames

The list of imports to always rename, a fully qualified path followed by the rename.

Default Value: [] (Vec<crate::utils::conf::Rename>)

allowed-scripts

The list of unicode scripts allowed to be used in the scope.

Default Value: ["Latin"] (Vec<String>)

enable-raw-pointer-heuristic-for-send

Whether to apply the raw pointer heuristic to determine if a type is Send.

Default Value: true (bool)

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)

await-holding-invalid-types

Default Value: [] (Vec<crate::utils::conf::DisallowedPath>)

max-include-file-size

The maximum size of a file included via include_bytes!() or include_str!(), in bytes

Default Value: 1000000 (u64)

allow-expect-in-tests

Whether expect should be allowed in test functions or #[cfg(test)]

Default Value: false (bool)

allow-unwrap-in-tests

Whether unwrap should be allowed in test functions or #[cfg(test)]

Default Value: false (bool)

allow-dbg-in-tests

Whether dbg! should be allowed in test functions or #[cfg(test)]

Default Value: false (bool)

allow-print-in-tests

Whether print macros (ex. println!) should be allowed in test functions or #[cfg(test)]

Default Value: false (bool)

large-error-threshold

The maximum size of the Err-variant in a Result returned from a function

Default Value: 128 (u64)

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<String>)

allow-mixed-uninlined-format-args

Whether to allow mixed uninlined format args, e.g. format!("{} {}", a, foo.bar)

Default Value: true (bool)

suppress-restriction-lint-in-const

Whether to suppress a restriction lint in constant code. 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)

missing-docs-in-crate-items

Whether to only check for missing documentation in items visible within the current crate. For example, pub(crate) items.

Default Value: false (bool)