Skip to content

Commit eb06e26

Browse files
committed
fix: redundant_test_prefix dogfooding
1 parent 24aa783 commit eb06e26

File tree

8 files changed

+44
-34
lines changed

8 files changed

+44
-34
lines changed

clippy_config/src/conf.rs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -633,6 +633,20 @@ define_Conf! {
633633
/// exported visibility, or whether they are marked as "pub".
634634
#[lints(pub_underscore_fields)]
635635
pub_underscore_fields_behavior: PubUnderscoreFieldsBehaviour = PubUnderscoreFieldsBehaviour::PubliclyExported,
636+
/// Whether to include functions outside of `#[cfg(test)]` in the linting process or not.
637+
///
638+
/// This option allows running the lint against the integration tests: test functions located
639+
/// there are not inside a node marked with `#[cfg(test)]` annotation (although they are
640+
/// still marked using `#[test]` annotation and thus can have redundant "test_" prefix).
641+
#[lints(redundant_test_prefix)]
642+
redundant_test_prefix_check_outside_cfg_test: bool = false,
643+
/// What suffix to use to avoid function name collisions when `test_` prefix is removed.
644+
///
645+
/// If set to `"_works"`, the lint will suggest renaming `test_foo` to `foo_works`.
646+
/// Suffix is added only when there is a collision with an existing function name,
647+
/// otherwise just `test_` prefix is removed (and no suffix added).
648+
#[lints(redundant_test_prefix)]
649+
redundant_test_prefix_custom_suffix: String = String::from("_works"),
636650
/// Whether to lint only if it's multiline.
637651
#[lints(semicolon_inside_block)]
638652
semicolon_inside_block_ignore_singleline: bool = false,
@@ -706,16 +720,6 @@ define_Conf! {
706720
/// Whether to also emit warnings for unsafe blocks with metavariable expansions in **private** macros.
707721
#[lints(macro_metavars_in_unsafe)]
708722
warn_unsafe_macro_metavars_in_private_macros: bool = false,
709-
/// Whether to include integration tests in the linting process or not.
710-
#[lints(redundant_test_prefix)]
711-
redundant_test_prefix_in_integration_tests: bool = false,
712-
/// What suffix to use to avoid function name collisions when `test_` prefix is removed.
713-
///
714-
/// If set to `"_works"`, the lint will suggest renaming `test_foo` to `foo_works`.
715-
/// Suffix is added only when there is a collision with an existing function name,
716-
/// otherwise just `test_` prefix is removed (and no suffix added).
717-
#[lints(redundant_test_prefix)]
718-
redundant_test_prefix_custom_suffix: String = String::from("_works"),
719723
}
720724

721725
/// Search for the configuration file.

clippy_dev/src/update_lints.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -963,7 +963,7 @@ mod tests {
963963
use super::*;
964964

965965
#[test]
966-
fn test_parse_contents() {
966+
fn parse_contents_works() {
967967
static CONTENTS: &str = r#"
968968
declare_clippy_lint! {
969969
#[clippy::version = "Hello Clippy!"]
@@ -1006,7 +1006,7 @@ mod tests {
10061006
}
10071007

10081008
#[test]
1009-
fn test_usable_lints() {
1009+
fn usable_lints_works() {
10101010
let lints = vec![
10111011
Lint::new(
10121012
"should_assert_eq2",
@@ -1041,7 +1041,7 @@ mod tests {
10411041
}
10421042

10431043
#[test]
1044-
fn test_by_lint_group() {
1044+
fn by_lint_group_works() {
10451045
let lints = vec![
10461046
Lint::new("should_assert_eq", "group1", "\"abc\"", "module_name", Range::default()),
10471047
Lint::new(

clippy_lints/src/empty_with_brackets.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ mod unit_test {
147147
use super::*;
148148

149149
#[test]
150-
fn test_has_no_ident_token() {
150+
fn has_no_ident_token_works() {
151151
let input = "{ field: u8 }";
152152
assert!(!has_no_ident_token(input));
153153

clippy_lints/src/needless_continue.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ mod test {
410410

411411
#[test]
412412
#[rustfmt::skip]
413-
fn test_erode_from_back() {
413+
fn erode_from_back_works() {
414414
let input = "\
415415
{
416416
let x = 5;
@@ -428,7 +428,7 @@ mod test {
428428

429429
#[test]
430430
#[rustfmt::skip]
431-
fn test_erode_from_back_no_brace() {
431+
fn erode_from_back_no_brace() {
432432
let input = "\
433433
let x = 5;
434434
let y = something();

clippy_lints/src/tabs_in_doc_comments.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -152,77 +152,77 @@ mod tests_for_get_chunks_of_tabs {
152152
use super::get_chunks_of_tabs;
153153

154154
#[test]
155-
fn test_unicode_han_string() {
155+
fn unicode_han_string() {
156156
let res = get_chunks_of_tabs(" \u{4f4d}\t");
157157

158158
assert_eq!(res, vec![(4, 5)]);
159159
}
160160

161161
#[test]
162-
fn test_empty_string() {
162+
fn empty_string() {
163163
let res = get_chunks_of_tabs("");
164164

165165
assert_eq!(res, vec![]);
166166
}
167167

168168
#[test]
169-
fn test_simple() {
169+
fn simple() {
170170
let res = get_chunks_of_tabs("sd\t\t\taa");
171171

172172
assert_eq!(res, vec![(2, 5)]);
173173
}
174174

175175
#[test]
176-
fn test_only_t() {
176+
fn only_t() {
177177
let res = get_chunks_of_tabs("\t\t");
178178

179179
assert_eq!(res, vec![(0, 2)]);
180180
}
181181

182182
#[test]
183-
fn test_only_one_t() {
183+
fn only_one_t() {
184184
let res = get_chunks_of_tabs("\t");
185185

186186
assert_eq!(res, vec![(0, 1)]);
187187
}
188188

189189
#[test]
190-
fn test_double() {
190+
fn double() {
191191
let res = get_chunks_of_tabs("sd\tasd\t\taa");
192192

193193
assert_eq!(res, vec![(2, 3), (6, 8)]);
194194
}
195195

196196
#[test]
197-
fn test_start() {
197+
fn start() {
198198
let res = get_chunks_of_tabs("\t\taa");
199199

200200
assert_eq!(res, vec![(0, 2)]);
201201
}
202202

203203
#[test]
204-
fn test_end() {
204+
fn end() {
205205
let res = get_chunks_of_tabs("aa\t\t");
206206

207207
assert_eq!(res, vec![(2, 4)]);
208208
}
209209

210210
#[test]
211-
fn test_start_single() {
211+
fn start_single() {
212212
let res = get_chunks_of_tabs("\taa");
213213

214214
assert_eq!(res, vec![(0, 1)]);
215215
}
216216

217217
#[test]
218-
fn test_end_single() {
218+
fn end_single() {
219219
let res = get_chunks_of_tabs("aa\t");
220220

221221
assert_eq!(res, vec![(2, 3)]);
222222
}
223223

224224
#[test]
225-
fn test_no_tabs() {
225+
fn no_tabs() {
226226
let res = get_chunks_of_tabs("dsfs");
227227

228228
assert_eq!(res, vec![]);

clippy_utils/src/source.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,7 @@ mod test {
744744
use super::reindent_multiline;
745745

746746
#[test]
747-
fn test_reindent_multiline_single_line() {
747+
fn reindent_multiline_single_line() {
748748
assert_eq!("", reindent_multiline("".into(), false, None));
749749
assert_eq!("...", reindent_multiline("...".into(), false, None));
750750
assert_eq!("...", reindent_multiline(" ...".into(), false, None));
@@ -754,7 +754,7 @@ mod test {
754754

755755
#[test]
756756
#[rustfmt::skip]
757-
fn test_reindent_multiline_block() {
757+
fn reindent_multiline_block() {
758758
assert_eq!("\
759759
if x {
760760
y
@@ -779,7 +779,7 @@ mod test {
779779

780780
#[test]
781781
#[rustfmt::skip]
782-
fn test_reindent_multiline_empty_line() {
782+
fn reindent_multiline_empty_line() {
783783
assert_eq!("\
784784
if x {
785785
y
@@ -796,7 +796,7 @@ mod test {
796796

797797
#[test]
798798
#[rustfmt::skip]
799-
fn test_reindent_multiline_lines_deeper() {
799+
fn reindent_multiline_lines_deeper() {
800800
assert_eq!("\
801801
if x {
802802
y

rustc_tools_util/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ mod test {
175175
use super::*;
176176

177177
#[test]
178-
fn test_struct_local() {
178+
fn struct_local() {
179179
let vi = get_version_info!();
180180
assert_eq!(vi.major, 0);
181181
assert_eq!(vi.minor, 4);
@@ -187,13 +187,13 @@ mod test {
187187
}
188188

189189
#[test]
190-
fn test_display_local() {
190+
fn display_local() {
191191
let vi = get_version_info!();
192192
assert_eq!(vi.to_string(), "rustc_tools_util 0.4.0");
193193
}
194194

195195
#[test]
196-
fn test_debug_local() {
196+
fn debug_local() {
197197
let vi = get_version_info!();
198198
let s = format!("{vi:?}");
199199
assert_eq!(

tests/ui-toml/toml_unknown_key/conf_unknown_key.stderr

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ error: error reading Clippy's configuration file: unknown field `foobar`, expect
5858
msrv
5959
pass-by-value-size-limit
6060
pub-underscore-fields-behavior
61+
redundant-test-prefix-check-outside-cfg-test
62+
redundant-test-prefix-custom-suffix
6163
semicolon-inside-block-ignore-singleline
6264
semicolon-outside-block-ignore-multiline
6365
single-char-binding-names-threshold
@@ -145,6 +147,8 @@ error: error reading Clippy's configuration file: unknown field `barfoo`, expect
145147
msrv
146148
pass-by-value-size-limit
147149
pub-underscore-fields-behavior
150+
redundant-test-prefix-check-outside-cfg-test
151+
redundant-test-prefix-custom-suffix
148152
semicolon-inside-block-ignore-singleline
149153
semicolon-outside-block-ignore-multiline
150154
single-char-binding-names-threshold
@@ -232,6 +236,8 @@ error: error reading Clippy's configuration file: unknown field `allow_mixed_uni
232236
msrv
233237
pass-by-value-size-limit
234238
pub-underscore-fields-behavior
239+
redundant-test-prefix-check-outside-cfg-test
240+
redundant-test-prefix-custom-suffix
235241
semicolon-inside-block-ignore-singleline
236242
semicolon-outside-block-ignore-multiline
237243
single-char-binding-names-threshold

0 commit comments

Comments
 (0)