mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-10 23:24:24 +00:00
Add suspicious group
This commit is contained in:
parent
8d427b624f
commit
7e21db5b5c
6 changed files with 27 additions and 15 deletions
21
README.md
21
README.md
|
@ -10,16 +10,17 @@ A collection of lints to catch common mistakes and improve your [Rust](https://g
|
|||
Lints are divided into categories, each with a default [lint level](https://doc.rust-lang.org/rustc/lints/levels.html).
|
||||
You can choose how much Clippy is supposed to ~~annoy~~ help you by changing the lint level by category.
|
||||
|
||||
| Category | Description | Default level |
|
||||
| --------------------- | ----------------------------------------------------------------------- | ------------- |
|
||||
| `clippy::all` | all lints that are on by default (correctness, style, complexity, perf) | **warn/deny** |
|
||||
| `clippy::correctness` | code that is outright wrong or very useless | **deny** |
|
||||
| `clippy::style` | code that should be written in a more idiomatic way | **warn** |
|
||||
| `clippy::complexity` | code that does something simple but in a complex way | **warn** |
|
||||
| `clippy::perf` | code that can be written to run faster | **warn** |
|
||||
| `clippy::pedantic` | lints which are rather strict or might have false positives | allow |
|
||||
| `clippy::nursery` | new lints that are still under development | allow |
|
||||
| `clippy::cargo` | lints for the cargo manifest | allow |
|
||||
| Category | Description | Default level |
|
||||
| --------------------- | ----------------------------------------------------------------------------------- | ------------- |
|
||||
| `clippy::all` | all lints that are on by default (correctness, suspicious, style, complexity, perf) | **warn/deny** |
|
||||
| `clippy::correctness` | code that is outright wrong or useless | **deny** |
|
||||
| `clippy::suspicious` | code that is most likely wrong or useless | **warn** |
|
||||
| `clippy::style` | code that should be written in a more idiomatic way | **warn** |
|
||||
| `clippy::complexity` | code that does something simple but in a complex way | **warn** |
|
||||
| `clippy::perf` | code that can be written to run faster | **warn** |
|
||||
| `clippy::pedantic` | lints which are rather strict or might have false positives | allow |
|
||||
| `clippy::nursery` | new lints that are still under development | allow |
|
||||
| `clippy::cargo` | lints for the cargo manifest | allow |
|
||||
|
||||
More to come, please [file an issue](https://github.com/rust-lang/rust-clippy/issues) if you have ideas!
|
||||
|
||||
|
|
|
@ -137,6 +137,7 @@ fn get_clap_config<'a>() -> ArgMatches<'a> {
|
|||
.possible_values(&[
|
||||
"style",
|
||||
"correctness",
|
||||
"suspicious",
|
||||
"complexity",
|
||||
"perf",
|
||||
"pedantic",
|
||||
|
|
|
@ -92,7 +92,10 @@ pub fn run(update_mode: UpdateMode) {
|
|||
|| {
|
||||
// clippy::all should only include the following lint groups:
|
||||
let all_group_lints = usable_lints.iter().filter(|l| {
|
||||
l.group == "correctness" || l.group == "style" || l.group == "complexity" || l.group == "perf"
|
||||
matches!(
|
||||
&*l.group,
|
||||
"correctness" | "suspicious" | "style" | "complexity" | "perf"
|
||||
)
|
||||
});
|
||||
|
||||
gen_lint_group_list(all_group_lints)
|
||||
|
|
|
@ -60,9 +60,9 @@ use rustc_session::Session;
|
|||
/// 4. The `description` that contains a short explanation on what's wrong with code where the
|
||||
/// lint is triggered.
|
||||
///
|
||||
/// Currently the categories `style`, `correctness`, `complexity` and `perf` are enabled by default.
|
||||
/// As said in the README.md of this repository, if the lint level mapping changes, please update
|
||||
/// README.md.
|
||||
/// Currently the categories `style`, `correctness`, `suspicious`, `complexity` and `perf` are
|
||||
/// enabled by default. As said in the README.md of this repository, if the lint level mapping
|
||||
/// changes, please update README.md.
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
|
@ -106,6 +106,11 @@ macro_rules! declare_clippy_lint {
|
|||
$(#[$attr])* pub clippy::$name, Deny, $description, report_in_external_macro: true
|
||||
}
|
||||
};
|
||||
{ $(#[$attr:meta])* pub $name:tt, suspicious, $description:tt } => {
|
||||
declare_tool_lint! {
|
||||
$(#[$attr])* pub clippy::$name, Warn, $description, report_in_external_macro: true
|
||||
}
|
||||
};
|
||||
{ $(#[$attr:meta])* pub $name:tt, complexity, $description:tt } => {
|
||||
declare_tool_lint! {
|
||||
$(#[$attr])* pub clippy::$name, Warn, $description, report_in_external_macro: true
|
||||
|
|
|
@ -47,8 +47,9 @@ const DEPRECATED_LINT_GROUP_STR: &str = "deprecated";
|
|||
const DEPRECATED_LINT_LEVEL: &str = "none";
|
||||
/// This array holds Clippy's lint groups with their corresponding default lint level. The
|
||||
/// lint level for deprecated lints is set in `DEPRECATED_LINT_LEVEL`.
|
||||
const DEFAULT_LINT_LEVELS: [(&str, &str); 8] = [
|
||||
const DEFAULT_LINT_LEVELS: &[(&str, &str)] = &[
|
||||
("correctness", "deny"),
|
||||
("suspicious", "warn"),
|
||||
("restriction", "allow"),
|
||||
("style", "warn"),
|
||||
("pedantic", "allow"),
|
||||
|
|
|
@ -19,6 +19,7 @@ comment_re = re.compile(r'''\s*/// ?(.*)''')
|
|||
|
||||
lint_levels = {
|
||||
"correctness": 'Deny',
|
||||
"suspicious": 'Warn',
|
||||
"style": 'Warn',
|
||||
"complexity": 'Warn',
|
||||
"perf": 'Warn',
|
||||
|
|
Loading…
Reference in a new issue