Skip to content

Commit 7e21db5

Browse files
committed
Add suspicious group
1 parent 8d427b6 commit 7e21db5

File tree

6 files changed

+27
-15
lines changed

6 files changed

+27
-15
lines changed

README.md

+11-10
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,17 @@ A collection of lints to catch common mistakes and improve your [Rust](https://g
1010
Lints are divided into categories, each with a default [lint level](https://doc.rust-lang.org/rustc/lints/levels.html).
1111
You can choose how much Clippy is supposed to ~~annoy~~ help you by changing the lint level by category.
1212

13-
| Category | Description | Default level |
14-
| --------------------- | ----------------------------------------------------------------------- | ------------- |
15-
| `clippy::all` | all lints that are on by default (correctness, style, complexity, perf) | **warn/deny** |
16-
| `clippy::correctness` | code that is outright wrong or very useless | **deny** |
17-
| `clippy::style` | code that should be written in a more idiomatic way | **warn** |
18-
| `clippy::complexity` | code that does something simple but in a complex way | **warn** |
19-
| `clippy::perf` | code that can be written to run faster | **warn** |
20-
| `clippy::pedantic` | lints which are rather strict or might have false positives | allow |
21-
| `clippy::nursery` | new lints that are still under development | allow |
22-
| `clippy::cargo` | lints for the cargo manifest | allow |
13+
| Category | Description | Default level |
14+
| --------------------- | ----------------------------------------------------------------------------------- | ------------- |
15+
| `clippy::all` | all lints that are on by default (correctness, suspicious, style, complexity, perf) | **warn/deny** |
16+
| `clippy::correctness` | code that is outright wrong or useless | **deny** |
17+
| `clippy::suspicious` | code that is most likely wrong or useless | **warn** |
18+
| `clippy::style` | code that should be written in a more idiomatic way | **warn** |
19+
| `clippy::complexity` | code that does something simple but in a complex way | **warn** |
20+
| `clippy::perf` | code that can be written to run faster | **warn** |
21+
| `clippy::pedantic` | lints which are rather strict or might have false positives | allow |
22+
| `clippy::nursery` | new lints that are still under development | allow |
23+
| `clippy::cargo` | lints for the cargo manifest | allow |
2324

2425
More to come, please [file an issue](https://github.com/rust-lang/rust-clippy/issues) if you have ideas!
2526

clippy_dev/src/main.rs

+1
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ fn get_clap_config<'a>() -> ArgMatches<'a> {
137137
.possible_values(&[
138138
"style",
139139
"correctness",
140+
"suspicious",
140141
"complexity",
141142
"perf",
142143
"pedantic",

clippy_dev/src/update_lints.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,10 @@ pub fn run(update_mode: UpdateMode) {
9292
|| {
9393
// clippy::all should only include the following lint groups:
9494
let all_group_lints = usable_lints.iter().filter(|l| {
95-
l.group == "correctness" || l.group == "style" || l.group == "complexity" || l.group == "perf"
95+
matches!(
96+
&*l.group,
97+
"correctness" | "suspicious" | "style" | "complexity" | "perf"
98+
)
9699
});
97100

98101
gen_lint_group_list(all_group_lints)

clippy_lints/src/lib.rs

+8-3
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ use rustc_session::Session;
6060
/// 4. The `description` that contains a short explanation on what's wrong with code where the
6161
/// lint is triggered.
6262
///
63-
/// Currently the categories `style`, `correctness`, `complexity` and `perf` are enabled by default.
64-
/// As said in the README.md of this repository, if the lint level mapping changes, please update
65-
/// README.md.
63+
/// Currently the categories `style`, `correctness`, `suspicious`, `complexity` and `perf` are
64+
/// enabled by default. As said in the README.md of this repository, if the lint level mapping
65+
/// changes, please update README.md.
6666
///
6767
/// # Example
6868
///
@@ -106,6 +106,11 @@ macro_rules! declare_clippy_lint {
106106
$(#[$attr])* pub clippy::$name, Deny, $description, report_in_external_macro: true
107107
}
108108
};
109+
{ $(#[$attr:meta])* pub $name:tt, suspicious, $description:tt } => {
110+
declare_tool_lint! {
111+
$(#[$attr])* pub clippy::$name, Warn, $description, report_in_external_macro: true
112+
}
113+
};
109114
{ $(#[$attr:meta])* pub $name:tt, complexity, $description:tt } => {
110115
declare_tool_lint! {
111116
$(#[$attr])* pub clippy::$name, Warn, $description, report_in_external_macro: true

clippy_lints/src/utils/internal_lints/metadata_collector.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,9 @@ const DEPRECATED_LINT_GROUP_STR: &str = "deprecated";
4747
const DEPRECATED_LINT_LEVEL: &str = "none";
4848
/// This array holds Clippy's lint groups with their corresponding default lint level. The
4949
/// lint level for deprecated lints is set in `DEPRECATED_LINT_LEVEL`.
50-
const DEFAULT_LINT_LEVELS: [(&str, &str); 8] = [
50+
const DEFAULT_LINT_LEVELS: &[(&str, &str)] = &[
5151
("correctness", "deny"),
52+
("suspicious", "warn"),
5253
("restriction", "allow"),
5354
("style", "warn"),
5455
("pedantic", "allow"),

util/lintlib.py

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
lint_levels = {
2121
"correctness": 'Deny',
22+
"suspicious": 'Warn',
2223
"style": 'Warn',
2324
"complexity": 'Warn',
2425
"perf": 'Warn',

0 commit comments

Comments
 (0)