File tree 9 files changed +25
-17
lines changed
9 files changed +25
-17
lines changed Original file line number Diff line number Diff line change 88
88
- name : Build and run tests (+ GUI)
89
89
run : cargo test --locked --target x86_64-unknown-linux-gnu --test gui
90
90
91
+ # Ensure there are no clippy warnings
92
+ clippy :
93
+ runs-on : ubuntu-latest
94
+ steps :
95
+ - uses : actions/checkout@v4
96
+ - name : Install Rust
97
+ run : bash ci/install-rust.sh stable x86_64-unknown-linux-gnu
98
+ - run : rustup component add clippy
99
+ - run : cargo clippy --workspace --all-targets --no-deps -- -D warnings
100
+
91
101
# The success job is here to consolidate the total success/failure state of
92
102
# all other jobs. This job is then included in the GitHub branch protection
93
103
# rule which prevents merges unless all other jobs are passing. This makes
@@ -101,6 +111,7 @@ jobs:
101
111
- rustfmt
102
112
- aarch64-cross-builds
103
113
- gui
114
+ - clippy
104
115
runs-on : ubuntu-latest
105
116
steps :
106
117
- run : jq --exit-status 'all(.result == "success")' <<< '${{ toJson(needs) }}'
Original file line number Diff line number Diff line change 1
1
[workspace ]
2
2
members = [" ." , " examples/remove-emphasis/mdbook-remove-emphasis" ]
3
3
4
+ [workspace .lints .clippy ]
5
+ all = { level = " allow" , priority = -2 }
6
+ correctness = { level = " warn" , priority = -1 }
7
+ complexity = { level = " warn" , priority = -1 }
8
+ needless-lifetimes = " allow" # Remove once 1.87 is stable, https://github.com/rust-lang/rust-clippy/issues/13514
9
+
4
10
[package ]
5
11
name = " mdbook"
6
12
version = " 0.4.48"
@@ -91,3 +97,6 @@ test = false
91
97
name = " gui"
92
98
path = " tests/gui/runner.rs"
93
99
crate-type = [" bin" ]
100
+
101
+ [lints ]
102
+ workspace = true
Original file line number Diff line number Diff line change 1
- use mdbook:: MDBook ;
2
-
3
1
#[ test]
4
2
fn remove_emphasis_works ( ) {
5
3
// Tests that the remove-emphasis example works as expected.
6
4
7
5
// Workaround for https://github.com/rust-lang/mdBook/issues/1424
8
6
std:: env:: set_current_dir ( "examples/remove-emphasis" ) . unwrap ( ) ;
9
- let book = MDBook :: load ( "." ) . unwrap ( ) ;
7
+ let book = mdbook :: MDBook :: load ( "." ) . unwrap ( ) ;
10
8
book. build ( ) . unwrap ( ) ;
11
9
let ch1 = std:: fs:: read_to_string ( "book/chapter_1.html" ) . unwrap ( ) ;
12
10
assert ! ( ch1. contains( "This has light emphasis and bold emphasis." ) ) ;
Original file line number Diff line number Diff line change 5
5
//!
6
6
//! [1]: ../index.html
7
7
8
- #[ allow( clippy:: module_inception) ]
9
8
mod book;
10
9
mod init;
11
10
mod summary;
@@ -860,7 +859,7 @@ mod tests {
860
859
. and_then ( Value :: as_str)
861
860
. unwrap ( ) ;
862
861
assert_eq ! ( html, "html" ) ;
863
- let html_renderer = HtmlHandlebars :: default ( ) ;
862
+ let html_renderer = HtmlHandlebars ;
864
863
let pre = LinkPreprocessor :: new ( ) ;
865
864
866
865
let should_run = preprocessor_should_run ( & pre, & html_renderer, & cfg) ;
Original file line number Diff line number Diff line change @@ -248,7 +248,7 @@ impl<'a> SummaryParser<'a> {
248
248
249
249
let mut files = HashSet :: new ( ) ;
250
250
for part in [ & prefix_chapters, & numbered_chapters, & suffix_chapters] {
251
- self . check_for_duplicates ( & part, & mut files) ?;
251
+ Self :: check_for_duplicates ( & part, & mut files) ?;
252
252
}
253
253
254
254
Ok ( Summary {
@@ -261,7 +261,6 @@ impl<'a> SummaryParser<'a> {
261
261
262
262
/// Recursively check for duplicate files in the summary items.
263
263
fn check_for_duplicates < ' b > (
264
- & self ,
265
264
items : & ' b [ SummaryItem ] ,
266
265
files : & mut HashSet < & ' b PathBuf > ,
267
266
) -> Result < ( ) > {
@@ -276,7 +275,7 @@ impl<'a> SummaryParser<'a> {
276
275
}
277
276
}
278
277
// Recursively check nested items
279
- self . check_for_duplicates ( & link. nested_items , files) ?;
278
+ Self :: check_for_duplicates ( & link. nested_items , files) ?;
280
279
}
281
280
}
282
281
Ok ( ( ) )
Original file line number Diff line number Diff line change @@ -148,7 +148,6 @@ enum RangeOrAnchor {
148
148
}
149
149
150
150
// A range of lines specified with some include directive.
151
- #[ allow( clippy:: enum_variant_names) ] // The prefix can't be removed, and is meant to mirror the contained type
152
151
#[ derive( PartialEq , Debug , Clone ) ]
153
152
enum LineRange {
154
153
Range ( Range < usize > ) ,
Original file line number Diff line number Diff line change @@ -207,7 +207,6 @@ impl HtmlHandlebars {
207
207
Ok ( ( ) )
208
208
}
209
209
210
- #[ allow( clippy:: let_and_return) ]
211
210
fn post_process (
212
211
& self ,
213
212
rendered : String ,
Original file line number Diff line number Diff line change @@ -39,12 +39,7 @@ impl HelperDef for ResourceHelper {
39
39
let path_to_root = utils:: fs:: path_to_root ( & base_path) ;
40
40
41
41
out. write ( & path_to_root) ?;
42
- out. write (
43
- self . hash_map
44
- . get ( & param[ ..] )
45
- . map ( |p| & p[ ..] )
46
- . unwrap_or ( & param) ,
47
- ) ?;
42
+ out. write ( self . hash_map . get ( param) . map ( |p| & p[ ..] ) . unwrap_or ( & param) ) ?;
48
43
Ok ( ( ) )
49
44
}
50
45
}
Original file line number Diff line number Diff line change @@ -780,7 +780,6 @@ mod search {
780
780
}
781
781
782
782
#[ test]
783
- #[ allow( clippy:: float_cmp) ]
784
783
fn book_creates_reasonable_search_index ( ) {
785
784
let temp = DummyBook :: new ( ) . build ( ) . unwrap ( ) ;
786
785
let md = MDBook :: load ( temp. path ( ) ) . unwrap ( ) ;
You can’t perform that action at this time.
0 commit comments