{"id":13720041,"url":"https://rust-lang.github.io/rust-clippy/","last_synced_at":"2025-05-07T12:30:45.963Z","repository":{"id":23485342,"uuid":"26850443","full_name":"rust-lang/rust-clippy","owner":"rust-lang","description":"A bunch of lints to catch common mistakes and improve your Rust code. Book: https://doc.rust-lang.org/clippy/","archived":false,"fork":false,"pushed_at":"2025-05-05T15:55:29.000Z","size":66448,"stargazers_count":11982,"open_issues_count":2338,"forks_count":1633,"subscribers_count":86,"default_branch":"master","last_synced_at":"2025-05-05T16:01:13.880Z","etag":null,"topics":["lint","rust"],"latest_commit_sha":null,"homepage":"https://rust-lang.github.io/rust-clippy/","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rust-lang.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE-APACHE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2014-11-19T07:49:21.000Z","updated_at":"2025-05-05T15:11:58.000Z","dependencies_parsed_at":"2023-10-20T14:36:48.920Z","dependency_job_id":"14708130-86e9-4128-9622-e75a0e5a7e1a","html_url":"https://github.com/rust-lang/rust-clippy","commit_stats":{"total_commits":11372,"total_committers":955,"mean_commits":"11.907853403141361","dds":0.9494372142103412,"last_synced_commit":"990bbdc2bee264291843497cebe59f307c2ed86f"},"previous_names":["rust-lang-nursery/rust-clippy"],"tags_count":215,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rust-lang%2Frust-clippy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rust-lang%2Frust-clippy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rust-lang%2Frust-clippy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rust-lang%2Frust-clippy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rust-lang","download_url":"https://codeload.github.com/rust-lang/rust-clippy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252876294,"owners_count":21818158,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["lint","rust"],"created_at":"2024-08-03T01:00:59.225Z","updated_at":"2025-05-07T12:30:45.933Z","avatar_url":"https://github.com/rust-lang.png","language":"Rust","readme":"# Clippy\n\n[![License: MIT OR Apache-2.0](https://img.shields.io/crates/l/clippy.svg)](#license)\n\nA collection of lints to catch common mistakes and improve your [Rust](https://github.com/rust-lang/rust) code.\n\n[There are over 750 lints included in this crate!](https://rust-lang.github.io/rust-clippy/master/index.html)\n\nLints are divided into categories, each with a default [lint level](https://doc.rust-lang.org/rustc/lints/levels.html).\nYou can choose how much Clippy is supposed to ~~annoy~~ help you by changing the lint level by category.\n\n| Category              | Description                                                                         | Default level |\n|-----------------------|-------------------------------------------------------------------------------------|---------------|\n| `clippy::all`         | all lints that are on by default (correctness, suspicious, style, complexity, perf) | **warn/deny** |\n| `clippy::correctness` | code that is outright wrong or useless                                              | **deny**      |\n| `clippy::suspicious`  | code that is most likely wrong or useless                                           | **warn**      |\n| `clippy::style`       | code that should be written in a more idiomatic way                                 | **warn**      |\n| `clippy::complexity`  | code that does something simple but in a complex way                                | **warn**      |\n| `clippy::perf`        | code that can be written to run faster                                              | **warn**      |\n| `clippy::pedantic`    | lints which are rather strict or have occasional false positives                    | allow         |\n| `clippy::restriction` | lints which prevent the use of language and library features[^restrict]             | allow         |\n| `clippy::nursery`     | new lints that are still under development                                          | allow         |\n| `clippy::cargo`       | lints for the cargo manifest                                                        | allow         |\n\nMore to come, please [file an issue](https://github.com/rust-lang/rust-clippy/issues) if you have ideas!\n\nThe `restriction` category should, *emphatically*, not be enabled as a whole. The contained\nlints may lint against perfectly reasonable code, may not have an alternative suggestion,\nand may contradict any other lints (including other categories). Lints should be considered\non a case-by-case basis before enabling.\n\n[^restrict]: Some use cases for `restriction` lints include:\n    - Strict coding styles (e.g. [`clippy::else_if_without_else`]).\n    - Additional restrictions on CI (e.g. [`clippy::todo`]).\n    - Preventing panicking in certain functions (e.g. [`clippy::unwrap_used`]).\n    - Running a lint only on a subset of code (e.g. `#[forbid(clippy::float_arithmetic)]` on a module).\n\n[`clippy::else_if_without_else`]: https://rust-lang.github.io/rust-clippy/master/index.html#else_if_without_else\n[`clippy::todo`]: https://rust-lang.github.io/rust-clippy/master/index.html#todo\n[`clippy::unwrap_used`]: https://rust-lang.github.io/rust-clippy/master/index.html#unwrap_used\n\n---\n\nTable of contents:\n\n* [Usage instructions](#usage)\n* [Configuration](#configuration)\n* [Contributing](#contributing)\n* [License](#license)\n\n## Usage\n\nBelow are instructions on how to use Clippy as a cargo subcommand,\nin projects that do not use cargo, or in Travis CI.\n\n### As a cargo subcommand (`cargo clippy`)\n\nOne way to use Clippy is by installing Clippy through rustup as a cargo\nsubcommand.\n\n#### Step 1: Install Rustup\n\nYou can install [Rustup](https://rustup.rs/) on supported platforms. This will help\nus install Clippy and its dependencies.\n\nIf you already have Rustup installed, update to ensure you have the latest\nRustup and compiler:\n\n```terminal\nrustup update\n```\n\n#### Step 2: Install Clippy\n\nOnce you have rustup and the latest stable release (at least Rust 1.29) installed, run the following command:\n\n```terminal\nrustup component add clippy\n```\n\nIf it says that it can't find the `clippy` component, please run `rustup self update`.\n\n#### Step 3: Run Clippy\n\nNow you can run Clippy by invoking the following command:\n\n```terminal\ncargo clippy\n```\n\n#### Automatically applying Clippy suggestions\n\nClippy can automatically apply some lint suggestions, just like the compiler. Note that `--fix` implies\n`--all-targets`, so it can fix as much code as it can.\n\n```terminal\ncargo clippy --fix\n```\n\n#### Workspaces\n\nAll the usual workspace options should work with Clippy. For example the following command\nwill run Clippy on the `example` crate:\n\n```terminal\ncargo clippy -p example\n```\n\nAs with `cargo check`, this includes dependencies that are members of the workspace, like path dependencies.\nIf you want to run Clippy **only** on the given crate, use the `--no-deps` option like this:\n\n```terminal\ncargo clippy -p example -- --no-deps\n```\n\n### Using `clippy-driver`\n\nClippy can also be used in projects that do not use cargo. To do so, run `clippy-driver`\nwith the same arguments you use for `rustc`. For example:\n\n```terminal\nclippy-driver --edition 2018 -Cpanic=abort foo.rs\n```\n\nNote that `clippy-driver` is designed for running Clippy only and should not be used as a general\nreplacement for `rustc`. `clippy-driver` may produce artifacts that are not optimized as expected,\nfor example.\n\n### Travis CI\n\nYou can add Clippy to Travis CI in the same way you use it locally:\n\n```yaml\nlanguage: rust\nrust:\n  - stable\n  - beta\nbefore_script:\n  - rustup component add clippy\nscript:\n  - cargo clippy\n  # if you want the build job to fail when encountering warnings, use\n  - cargo clippy -- -D warnings\n  # in order to also check tests and non-default crate features, use\n  - cargo clippy --all-targets --all-features -- -D warnings\n  - cargo test\n  # etc.\n```\n\nNote that adding `-D warnings` will cause your build to fail if **any** warnings are found in your code.\nThat includes warnings found by rustc (e.g. `dead_code`, etc.). If you want to avoid this and only cause\nan error for Clippy warnings, use `#![deny(clippy::all)]` in your code or `-D clippy::all` on the command\nline. (You can swap `clippy::all` with the specific lint category you are targeting.)\n\n## Configuration\n\n### Allowing/denying lints\n\nYou can add options to your code to `allow`/`warn`/`deny` Clippy lints:\n\n* the whole set of `Warn` lints using the `clippy` lint group (`#![deny(clippy::all)]`).\n  Note that `rustc` has additional [lint groups](https://doc.rust-lang.org/rustc/lints/groups.html).\n\n* all lints using both the `clippy` and `clippy::pedantic` lint groups (`#![deny(clippy::all)]`,\n  `#![deny(clippy::pedantic)]`). Note that `clippy::pedantic` contains some very aggressive\n  lints prone to false positives.\n\n* only some lints (`#![deny(clippy::single_match, clippy::box_vec)]`, etc.)\n\n* `allow`/`warn`/`deny` can be limited to a single function or module using `#[allow(...)]`, etc.\n\nNote: `allow` means to suppress the lint for your code. With `warn` the lint\nwill only emit a warning, while with `deny` the lint will emit an error, when\ntriggering for your code. An error causes Clippy to exit with an error code, so\nis useful in scripts like CI/CD.\n\nIf you do not want to include your lint levels in your code, you can globally\nenable/disable lints by passing extra flags to Clippy during the run:\n\nTo allow `lint_name`, run\n\n```terminal\ncargo clippy -- -A clippy::lint_name\n```\n\nAnd to warn on `lint_name`, run\n\n```terminal\ncargo clippy -- -W clippy::lint_name\n```\n\nThis also works with lint groups. For example, you\ncan run Clippy with warnings for all lints enabled:\n\n```terminal\ncargo clippy -- -W clippy::pedantic\n```\n\nIf you care only about a single lint, you can allow all others and then explicitly warn on\nthe lint(s) you are interested in:\n\n```terminal\ncargo clippy -- -A clippy::all -W clippy::useless_format -W clippy::...\n```\n\n### Configure the behavior of some lints\n\nSome lints can be configured in a TOML file named `clippy.toml` or `.clippy.toml`. It contains a basic `variable =\nvalue` mapping e.g.\n\n```toml\navoid-breaking-exported-api = false\ndisallowed-names = [\"toto\", \"tata\", \"titi\"]\n```\n\nThe [table of configurations](https://doc.rust-lang.org/nightly/clippy/lint_configuration.html)\ncontains all config values, their default, and a list of lints they affect.\nEach [configurable lint](https://rust-lang.github.io/rust-clippy/master/index.html#Configuration)\n, also contains information about these values.\n\nFor configurations that are a list type with default values such as\n[disallowed-names](https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_names),\nyou can use the unique value `\"..\"` to extend the default values instead of replacing them.\n\n```toml\n# default of disallowed-names is [\"foo\", \"baz\", \"quux\"]\ndisallowed-names = [\"bar\", \"..\"] # -\u003e [\"bar\", \"foo\", \"baz\", \"quux\"]\n```\n\n\u003e **Note**\n\u003e\n\u003e `clippy.toml` or `.clippy.toml` cannot be used to allow/deny lints.\n\nTo deactivate the “for further information visit *lint-link*” message you can\ndefine the `CLIPPY_DISABLE_DOCS_LINKS` environment variable.\n\n### Specifying the minimum supported Rust version\n\nProjects that intend to support old versions of Rust can disable lints pertaining to newer features by\nspecifying the minimum supported Rust version (MSRV) in the Clippy configuration file.\n\n```toml\nmsrv = \"1.30.0\"\n```\n\nAlternatively, the [`rust-version` field](https://doc.rust-lang.org/cargo/reference/manifest.html#the-rust-version-field)\nin the `Cargo.toml` can be used.\n\n```toml\n# Cargo.toml\nrust-version = \"1.30\"\n```\n\nThe MSRV can also be specified as an attribute, like below.\n\n```rust,ignore\n#![feature(custom_inner_attributes)]\n#![clippy::msrv = \"1.30.0\"]\n\nfn main() {\n  ...\n}\n```\n\nYou can also omit the patch version when specifying the MSRV, so `msrv = 1.30`\nis equivalent to `msrv = 1.30.0`.\n\nNote: `custom_inner_attributes` is an unstable feature, so it has to be enabled explicitly.\n\nLints that recognize this configuration option can be found [here](https://rust-lang.github.io/rust-clippy/master/index.html#msrv)\n\n## Contributing\n\nIf you want to contribute to Clippy, you can find more information in [CONTRIBUTING.md](https://github.com/rust-lang/rust-clippy/blob/master/CONTRIBUTING.md).\n\n## License\n\n\u003c!-- REUSE-IgnoreStart --\u003e\n\nCopyright 2014-2025 The Rust Project Developers\n\nLicensed under the Apache License, Version 2.0 \u003cLICENSE-APACHE or\n[https://www.apache.org/licenses/LICENSE-2.0](https://www.apache.org/licenses/LICENSE-2.0)\u003e or the MIT license\n\u003cLICENSE-MIT or [https://opensource.org/licenses/MIT](https://opensource.org/licenses/MIT)\u003e, at your\noption. Files in the project may not be\ncopied, modified, or distributed except according to those terms.\n\n\u003c!-- REUSE-IgnoreEnd --\u003e\n","funding_links":[],"categories":["Rust Tools","Rust Tools and Frameworks","Rust Tools, Libraries, and Frameworks","Tools"],"sub_categories":["In-memory data grids","Interfaces","E-Books","VS Code Extensions for Developer Productivity","Mesh networks","JavaScript Libraries for Machine Learning"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/rust-lang.github.io%2Frust-clippy%2F","html_url":"https://awesome.ecosyste.ms/projects/rust-lang.github.io%2Frust-clippy%2F","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/rust-lang.github.io%2Frust-clippy%2F/lists"}