Add new too_long_first_doc_paragraph first paragraph lint
This commit is contained in:
parent
345c94c98f
commit
855a9d1377
9 changed files with 269 additions and 32 deletions
8
tests/ui/too_long_first_doc_paragraph-fix.fixed
Normal file
8
tests/ui/too_long_first_doc_paragraph-fix.fixed
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
#![warn(clippy::too_long_first_doc_paragraph)]
|
||||
|
||||
/// A very short summary.
|
||||
///
|
||||
/// A much longer explanation that goes into a lot more detail about
|
||||
/// how the thing works, possibly with doclinks and so one,
|
||||
/// and probably spanning a many rows.
|
||||
struct Foo;
|
||||
7
tests/ui/too_long_first_doc_paragraph-fix.rs
Normal file
7
tests/ui/too_long_first_doc_paragraph-fix.rs
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
#![warn(clippy::too_long_first_doc_paragraph)]
|
||||
|
||||
/// A very short summary.
|
||||
/// A much longer explanation that goes into a lot more detail about
|
||||
/// how the thing works, possibly with doclinks and so one,
|
||||
/// and probably spanning a many rows.
|
||||
struct Foo;
|
||||
19
tests/ui/too_long_first_doc_paragraph-fix.stderr
Normal file
19
tests/ui/too_long_first_doc_paragraph-fix.stderr
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
error: first doc comment paragraph is too long
|
||||
--> tests/ui/too_long_first_doc_paragraph-fix.rs:3:1
|
||||
|
|
||||
LL | / /// A very short summary.
|
||||
LL | | /// A much longer explanation that goes into a lot more detail about
|
||||
LL | | /// how the thing works, possibly with doclinks and so one,
|
||||
LL | | /// and probably spanning a many rows.
|
||||
| |_
|
||||
|
|
||||
= note: `-D clippy::too-long-first-doc-paragraph` implied by `-D warnings`
|
||||
= help: to override `-D warnings` add `#[allow(clippy::too_long_first_doc_paragraph)]`
|
||||
help: add an empty line
|
||||
|
|
||||
LL ~ /// A very short summary.
|
||||
LL + ///
|
||||
|
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
47
tests/ui/too_long_first_doc_paragraph.rs
Normal file
47
tests/ui/too_long_first_doc_paragraph.rs
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
//@no-rustfix
|
||||
|
||||
#![warn(clippy::too_long_first_doc_paragraph)]
|
||||
|
||||
/// Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc turpis nunc, lacinia
|
||||
/// a dolor in, pellentesque aliquet enim. Cras nec maximus sem. Mauris arcu libero,
|
||||
/// gravida non lacinia at, rhoncus eu lacus.
|
||||
pub struct Bar;
|
||||
|
||||
// Should not warn! (not an item visible on mod page)
|
||||
/// Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc turpis nunc, lacinia
|
||||
/// a dolor in, pellentesque aliquet enim. Cras nec maximus sem. Mauris arcu libero,
|
||||
/// gravida non lacinia at, rhoncus eu lacus.
|
||||
impl Bar {}
|
||||
|
||||
// Should not warn! (less than 80 characters)
|
||||
/// Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
||||
///
|
||||
/// Nunc turpis nunc, lacinia
|
||||
/// a dolor in, pellentesque aliquet enim. Cras nec maximus sem. Mauris arcu libero,
|
||||
/// gravida non lacinia at, rhoncus eu lacus.
|
||||
enum Enum {
|
||||
A,
|
||||
}
|
||||
|
||||
/// Lorem
|
||||
/// ipsum dolor sit amet, consectetur adipiscing elit. Nunc turpis nunc, lacinia
|
||||
/// a dolor in, pellentesque aliquet enim. Cras nec maximus sem. Mauris arcu libero,
|
||||
/// gravida non lacinia at, rhoncus eu lacus.
|
||||
union Union {
|
||||
a: u8,
|
||||
b: u8,
|
||||
}
|
||||
|
||||
// Should not warn! (title)
|
||||
/// # bla
|
||||
/// Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc turpis nunc, lacinia
|
||||
/// a dolor in, pellentesque aliquet enim. Cras nec maximus sem. Mauris arcu libero,
|
||||
/// gravida non lacinia at, rhoncus eu lacus.
|
||||
union Union2 {
|
||||
a: u8,
|
||||
b: u8,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
// test code goes here
|
||||
}
|
||||
22
tests/ui/too_long_first_doc_paragraph.stderr
Normal file
22
tests/ui/too_long_first_doc_paragraph.stderr
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
error: first doc comment paragraph is too long
|
||||
--> tests/ui/too_long_first_doc_paragraph.rs:5:1
|
||||
|
|
||||
LL | / /// Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc turpis nunc, lacinia
|
||||
LL | | /// a dolor in, pellentesque aliquet enim. Cras nec maximus sem. Mauris arcu libero,
|
||||
LL | | /// gravida non lacinia at, rhoncus eu lacus.
|
||||
| |_
|
||||
|
|
||||
= note: `-D clippy::too-long-first-doc-paragraph` implied by `-D warnings`
|
||||
= help: to override `-D warnings` add `#[allow(clippy::too_long_first_doc_paragraph)]`
|
||||
|
||||
error: first doc comment paragraph is too long
|
||||
--> tests/ui/too_long_first_doc_paragraph.rs:26:1
|
||||
|
|
||||
LL | / /// Lorem
|
||||
LL | | /// ipsum dolor sit amet, consectetur adipiscing elit. Nunc turpis nunc, lacinia
|
||||
LL | | /// a dolor in, pellentesque aliquet enim. Cras nec maximus sem. Mauris arcu libero,
|
||||
LL | | /// gravida non lacinia at, rhoncus eu lacus.
|
||||
| |_
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue