Skip to content

Commit c89ac83

Browse files
committed
fix: redundant_test_prefix dogfooding
1 parent d665e0e commit c89ac83

File tree

8 files changed

+44
-34
lines changed

8 files changed

+44
-34
lines changed

clippy_config/src/conf.rs

+14-10
Original file line numberDiff line numberDiff line change
@@ -772,6 +772,20 @@ define_Conf! {
772772
/// exported visibility, or whether they are marked as "pub".
773773
#[lints(pub_underscore_fields)]
774774
pub_underscore_fields_behavior: PubUnderscoreFieldsBehaviour = PubUnderscoreFieldsBehaviour::PubliclyExported,
775+
/// Whether to include functions outside of `#[cfg(test)]` in the linting process or not.
776+
///
777+
/// This option allows running the lint against the integration tests: test functions located
778+
/// there are not inside a node marked with `#[cfg(test)]` annotation (although they are
779+
/// still marked using `#[test]` annotation and thus can have redundant "test_" prefix).
780+
#[lints(redundant_test_prefix)]
781+
redundant_test_prefix_check_outside_cfg_test: bool = false,
782+
/// What suffix to use to avoid function name collisions when `test_` prefix is removed.
783+
///
784+
/// If set to `"_works"`, the lint will suggest renaming `test_foo` to `foo_works`.
785+
/// Suffix is added only when there is a collision with an existing function name,
786+
/// otherwise just `test_` prefix is removed (and no suffix added).
787+
#[lints(redundant_test_prefix)]
788+
redundant_test_prefix_custom_suffix: String = String::from("_works"),
775789
/// Whether to lint only if it's multiline.
776790
#[lints(semicolon_inside_block)]
777791
semicolon_inside_block_ignore_singleline: bool = false,
@@ -846,16 +860,6 @@ define_Conf! {
846860
/// Whether to also emit warnings for unsafe blocks with metavariable expansions in **private** macros.
847861
#[lints(macro_metavars_in_unsafe)]
848862
warn_unsafe_macro_metavars_in_private_macros: bool = false,
849-
/// Whether to include integration tests in the linting process or not.
850-
#[lints(redundant_test_prefix)]
851-
redundant_test_prefix_in_integration_tests: bool = false,
852-
/// What suffix to use to avoid function name collisions when `test_` prefix is removed.
853-
///
854-
/// If set to `"_works"`, the lint will suggest renaming `test_foo` to `foo_works`.
855-
/// Suffix is added only when there is a collision with an existing function name,
856-
/// otherwise just `test_` prefix is removed (and no suffix added).
857-
#[lints(redundant_test_prefix)]
858-
redundant_test_prefix_custom_suffix: String = String::from("_works"),
859863
}
860864

861865
/// Search for the configuration file.

clippy_dev/src/update_lints.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -894,7 +894,7 @@ mod tests {
894894
use super::*;
895895

896896
#[test]
897-
fn test_parse_contents() {
897+
fn parse_contents_works() {
898898
static CONTENTS: &str = r#"
899899
declare_clippy_lint! {
900900
#[clippy::version = "Hello Clippy!"]
@@ -937,7 +937,7 @@ mod tests {
937937
}
938938

939939
#[test]
940-
fn test_usable_lints() {
940+
fn usable_lints_works() {
941941
let lints = vec![
942942
Lint::new(
943943
"should_assert_eq2",
@@ -972,7 +972,7 @@ mod tests {
972972
}
973973

974974
#[test]
975-
fn test_by_lint_group() {
975+
fn by_lint_group_works() {
976976
let lints = vec![
977977
Lint::new("should_assert_eq", "group1", "\"abc\"", "module_name", Range::default()),
978978
Lint::new(

clippy_lints/src/empty_with_brackets.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ mod unit_test {
146146
use super::*;
147147

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

clippy_lints/src/needless_continue.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ mod test {
501501

502502
#[test]
503503
#[rustfmt::skip]
504-
fn test_erode_from_back() {
504+
fn erode_from_back_works() {
505505
let input = "\
506506
{
507507
let x = 5;
@@ -519,7 +519,7 @@ mod test {
519519

520520
#[test]
521521
#[rustfmt::skip]
522-
fn test_erode_from_back_no_brace() {
522+
fn erode_from_back_no_brace() {
523523
let input = "\
524524
let x = 5;
525525
let y = something();

clippy_lints/src/tabs_in_doc_comments.rs

+11-11
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

+4-4
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,7 @@ mod test {
759759
use super::reindent_multiline;
760760

761761
#[test]
762-
fn test_reindent_multiline_single_line() {
762+
fn reindent_multiline_single_line() {
763763
assert_eq!("", reindent_multiline("", false, None));
764764
assert_eq!("...", reindent_multiline("...", false, None));
765765
assert_eq!("...", reindent_multiline(" ...", false, None));
@@ -769,7 +769,7 @@ mod test {
769769

770770
#[test]
771771
#[rustfmt::skip]
772-
fn test_reindent_multiline_block() {
772+
fn reindent_multiline_block() {
773773
assert_eq!("\
774774
if x {
775775
y
@@ -794,7 +794,7 @@ mod test {
794794

795795
#[test]
796796
#[rustfmt::skip]
797-
fn test_reindent_multiline_empty_line() {
797+
fn reindent_multiline_empty_line() {
798798
assert_eq!("\
799799
if x {
800800
y
@@ -811,7 +811,7 @@ mod test {
811811

812812
#[test]
813813
#[rustfmt::skip]
814-
fn test_reindent_multiline_lines_deeper() {
814+
fn reindent_multiline_lines_deeper() {
815815
assert_eq!("\
816816
if x {
817817
y

rustc_tools_util/src/lib.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ mod test {
184184
use super::*;
185185

186186
#[test]
187-
fn test_struct_local() {
187+
fn struct_local() {
188188
let vi = get_version_info!();
189189
assert_eq!(vi.major, 0);
190190
assert_eq!(vi.minor, 4);
@@ -198,13 +198,13 @@ mod test {
198198
}
199199

200200
#[test]
201-
fn test_display_local() {
201+
fn display_local() {
202202
let vi = get_version_info!();
203203
assert_eq!(vi.to_string(), "rustc_tools_util 0.4.2");
204204
}
205205

206206
#[test]
207-
fn test_debug_local() {
207+
fn debug_local() {
208208
let vi = get_version_info!();
209209
let s = format!("{vi:?}");
210210
assert_eq!(

tests/ui-toml/toml_unknown_key/conf_unknown_key.stderr

+6
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ error: error reading Clippy's configuration file: unknown field `foobar`, expect
6363
msrv
6464
pass-by-value-size-limit
6565
pub-underscore-fields-behavior
66+
redundant-test-prefix-check-outside-cfg-test
67+
redundant-test-prefix-custom-suffix
6668
semicolon-inside-block-ignore-singleline
6769
semicolon-outside-block-ignore-multiline
6870
single-char-binding-names-threshold
@@ -155,6 +157,8 @@ error: error reading Clippy's configuration file: unknown field `barfoo`, expect
155157
msrv
156158
pass-by-value-size-limit
157159
pub-underscore-fields-behavior
160+
redundant-test-prefix-check-outside-cfg-test
161+
redundant-test-prefix-custom-suffix
158162
semicolon-inside-block-ignore-singleline
159163
semicolon-outside-block-ignore-multiline
160164
single-char-binding-names-threshold
@@ -247,6 +251,8 @@ error: error reading Clippy's configuration file: unknown field `allow_mixed_uni
247251
msrv
248252
pass-by-value-size-limit
249253
pub-underscore-fields-behavior
254+
redundant-test-prefix-check-outside-cfg-test
255+
redundant-test-prefix-custom-suffix
250256
semicolon-inside-block-ignore-singleline
251257
semicolon-outside-block-ignore-multiline
252258
single-char-binding-names-threshold

0 commit comments

Comments
 (0)