Skip to main content

Lint clippy::assert_is_empty

warning clippy::assert_is_empty §

used `assert!` to check that a value is not empty

src/diagnostic/dedup.rs:115:9

Clippy · Category: pedantic · cargo-clippy-html

Official Clippy documentation

Targets (1)
  • cargo-clippy-html (bin)

Primary: src/diagnostic/dedup.rs:115:9

        assert!(!r[0].id.is_empty());

Primary: src/diagnostic/dedup.rs:115:15

        assert!(!r[0].id.is_empty());

Primary: src/diagnostic/dedup.rs:115:17

        assert!(!r[0].id.is_empty());

help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.100.0/index.html#assert_is_empty

note: `-W clippy::assert-is-empty` implied by `-W clippy::pedantic`

help: to override `-W clippy::pedantic` add `#[allow(clippy::assert_is_empty)]`

help: use `assert_ne!` to show the value on failure

Suggestion: use `assert_ne!` to show the value on failure

MachineApplicable

--- "a/src/diagnostic/dedup.rs"
+++ "b/src/diagnostic/dedup.rs"
@@ -112,6 +112,6 @@
         let r = merge_findings(vec![a.clone(), b.clone()]);
         let s = merge_findings(vec![b, a]);
         assert_eq!(r, s);
-        assert!(!r[0].id.is_empty());
+        assert_ne!(r[0].id, "");
     }
 }
Rendered diagnostic (text)
warning: used `assert!` to check that a value is not empty
   --> src/diagnostic/dedup.rs:115:9
    |
115 |         assert!(!r[0].id.is_empty());
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.100.0/index.html#assert_is_empty
    = note: `-W clippy::assert-is-empty` implied by `-W clippy::pedantic`
    = help: to override `-W clippy::pedantic` add `#[allow(clippy::assert_is_empty)]`
help: use `assert_ne!` to show the value on failure
    |
115 -         assert!(!r[0].id.is_empty());
115 +         assert_ne!(r[0].id, "");
    |

warning clippy::assert_is_empty §

used `assert!` to check that a value is empty

src/output.rs:345:9

Clippy · Category: pedantic · cargo-clippy-html

Official Clippy documentation

Targets (1)
  • cargo-clippy-html (bin)

Primary: src/output.rs:345:9

        assert!(result.warnings.is_empty());

Primary: src/output.rs:345:15

        assert!(result.warnings.is_empty());

Primary: src/output.rs:345:17

        assert!(result.warnings.is_empty());

help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.100.0/index.html#assert_is_empty

help: use `assert_eq!` to show the value on failure

Suggestion: use `assert_eq!` to show the value on failure

MachineApplicable

--- "a/src/output.rs"
+++ "b/src/output.rs"
@@ -342,7 +342,7 @@
         })
         .unwrap();
         assert!(result.index.is_file());
-        assert!(result.warnings.is_empty());
+        assert_eq!(result.warnings, [] as [std::string::String; 0]);
     }
     #[test]
     fn publication_lock_covers_external_metadata_and_is_released_with_the_receipt() {
Rendered diagnostic (text)
warning: used `assert!` to check that a value is empty
   --> src/output.rs:345:9
    |
345 |         assert!(result.warnings.is_empty());
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.100.0/index.html#assert_is_empty
help: use `assert_eq!` to show the value on failure
    |
345 -         assert!(result.warnings.is_empty());
345 +         assert_eq!(result.warnings, [] as [std::string::String; 0]);
    |

warning clippy::assert_is_empty §

used `assert!` to check that a value is empty

tests/integration.rs:265:13

Clippy · Category: pedantic · cargo-clippy-html

Official Clippy documentation

Targets (1)
  • integration (test)

Primary: tests/integration.rs:265:13

            assert!(script.text().collect::<String>().is_empty());

Primary: tests/integration.rs:265:19

            assert!(script.text().collect::<String>().is_empty());

Primary: tests/integration.rs:265:21

            assert!(script.text().collect::<String>().is_empty());

help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.100.0/index.html#assert_is_empty

note: `-W clippy::assert-is-empty` implied by `-W clippy::pedantic`

help: to override `-W clippy::pedantic` add `#[allow(clippy::assert_is_empty)]`

help: use `assert_eq!` to show the value on failure

Suggestion: use `assert_eq!` to show the value on failure

MachineApplicable

--- "a/tests/integration.rs"
+++ "b/tests/integration.rs"
@@ -262,7 +262,7 @@
                 script.value().attr("defer").is_some(),
                 name != "settings-storage.js"
             );
-            assert!(script.text().collect::<String>().is_empty());
+            assert_eq!(script.text().collect::<String>(), "");
         }
         assert_eq!(
             doc.select(
Rendered diagnostic (text)
warning: used `assert!` to check that a value is empty
   --> tests/integration.rs:265:13
    |
265 |             assert!(script.text().collect::<String>().is_empty());
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.100.0/index.html#assert_is_empty
    = note: `-W clippy::assert-is-empty` implied by `-W clippy::pedantic`
    = help: to override `-W clippy::pedantic` add `#[allow(clippy::assert_is_empty)]`
help: use `assert_eq!` to show the value on failure
    |
265 -             assert!(script.text().collect::<String>().is_empty());
265 +             assert_eq!(script.text().collect::<String>(), "");
    |

warning clippy::assert_is_empty §

used `assert!` to check that a value is not empty

tests/integration.rs:435:5

Clippy · Category: pedantic · cargo-clippy-html

Official Clippy documentation

Targets (1)
  • integration (test)

Primary: tests/integration.rs:435:5

    assert!(!files.is_empty());

Primary: tests/integration.rs:435:11

    assert!(!files.is_empty());

Primary: tests/integration.rs:435:13

    assert!(!files.is_empty());

help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.100.0/index.html#assert_is_empty

help: use `assert_ne!` to show the value on failure

Suggestion: use `assert_ne!` to show the value on failure

MachineApplicable

--- "a/tests/integration.rs"
+++ "b/tests/integration.rs"
@@ -432,7 +432,7 @@
     let f = Fixture::new("nested-dependency");
     assert_eq!(f.run(&[]).status.code(), Some(101));
     let files = html_files(&f.report().join("src"));
-    assert!(!files.is_empty());
+    assert_ne!(files, [] as [std::path::PathBuf; 0]);
     for path in files {
         let html = std::fs::read_to_string(path).unwrap();
         let doc = Html::parse_document(&html);
Rendered diagnostic (text)
warning: used `assert!` to check that a value is not empty
   --> tests/integration.rs:435:5
    |
435 |     assert!(!files.is_empty());
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.100.0/index.html#assert_is_empty
help: use `assert_ne!` to show the value on failure
    |
435 -     assert!(!files.is_empty());
435 +     assert_ne!(files, [] as [std::path::PathBuf; 0]);
    |

warning clippy::assert_is_empty §

used `assert!` to check that a value is not empty

tests/integration.rs:605:5

Clippy · Category: pedantic · cargo-clippy-html

Official Clippy documentation

Targets (1)
  • integration (test)

Primary: tests/integration.rs:605:5

    assert!(!html_files(&e.report().join("lint")).is_empty());

Primary: tests/integration.rs:605:11

    assert!(!html_files(&e.report().join("lint")).is_empty());

Primary: tests/integration.rs:605:13

    assert!(!html_files(&e.report().join("lint")).is_empty());

help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.100.0/index.html#assert_is_empty

help: use `assert_ne!` to show the value on failure

Suggestion: use `assert_ne!` to show the value on failure

MachineApplicable

--- "a/tests/integration.rs"
+++ "b/tests/integration.rs"
@@ -602,7 +602,7 @@
     assert_eq!(out.status.code(), Some(101));
     assert!(e.html("index.html").contains("Failed"));
     assert!(e.report().join("lint/rustc/E0308.html").is_file());
-    assert!(!html_files(&e.report().join("lint")).is_empty());
+    assert_ne!(html_files(&e.report().join("lint")), [] as [std::path::PathBuf; 0]);
 }
 #[test]
 fn workspace_paths_unicode_and_multi_target_dedup() {
Rendered diagnostic (text)
warning: used `assert!` to check that a value is not empty
   --> tests/integration.rs:605:5
    |
605 |     assert!(!html_files(&e.report().join("lint")).is_empty());
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.100.0/index.html#assert_is_empty
help: use `assert_ne!` to show the value on failure
    |
605 -     assert!(!html_files(&e.report().join("lint")).is_empty());
605 +     assert_ne!(html_files(&e.report().join("lint")), [] as [std::path::PathBuf; 0]);
    |

warning clippy::assert_is_empty §

used `assert!` to check that a value is not empty

tests/metadata.rs:82:5

Clippy · Category: pedantic · cargo-clippy-html

Official Clippy documentation

Targets (1)
  • metadata (test)

Primary: tests/metadata.rs:82:5

    assert!(!findings.is_empty());

Primary: tests/metadata.rs:82:11

    assert!(!findings.is_empty());

Primary: tests/metadata.rs:82:13

    assert!(!findings.is_empty());

help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.100.0/index.html#assert_is_empty

note: `-W clippy::assert-is-empty` implied by `-W clippy::pedantic`

help: to override `-W clippy::pedantic` add `#[allow(clippy::assert_is_empty)]`

help: use `assert_ne!` to show the value on failure

Suggestion: use `assert_ne!` to show the value on failure

MachineApplicable

--- "a/tests/metadata.rs"
+++ "b/tests/metadata.rs"
@@ -79,7 +79,7 @@
         assert_url(&f.report(), page["url"].as_str().unwrap());
     }
     let findings = json["findings"].as_array().unwrap();
-    assert!(!findings.is_empty());
+    assert_ne!(findings.as_slice(), []);
     for finding in findings {
         assert_eq!(finding["code"], "clippy::clone_on_copy");
         assert_eq!(finding["level"], "warning");
Rendered diagnostic (text)
warning: used `assert!` to check that a value is not empty
  --> tests/metadata.rs:82:5
   |
82 |     assert!(!findings.is_empty());
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.100.0/index.html#assert_is_empty
   = note: `-W clippy::assert-is-empty` implied by `-W clippy::pedantic`
   = help: to override `-W clippy::pedantic` add `#[allow(clippy::assert_is_empty)]`
help: use `assert_ne!` to show the value on failure
   |
82 -     assert!(!findings.is_empty());
82 +     assert_ne!(findings.as_slice(), []);
   |

warning clippy::assert_is_empty §

used `assert!` to check that a value is empty

tests/metadata.rs:156:13

Clippy · Category: pedantic · cargo-clippy-html

Official Clippy documentation

Targets (1)
  • metadata (test)

Primary: tests/metadata.rs:156:13

            assert!(json["findings"].as_array().unwrap().is_empty());

Primary: tests/metadata.rs:156:19

            assert!(json["findings"].as_array().unwrap().is_empty());

Primary: tests/metadata.rs:156:21

            assert!(json["findings"].as_array().unwrap().is_empty());

help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.100.0/index.html#assert_is_empty

help: use `assert_eq!` to show the value on failure

Suggestion: use `assert_eq!` to show the value on failure

MachineApplicable

--- "a/tests/metadata.rs"
+++ "b/tests/metadata.rs"
@@ -153,7 +153,7 @@
             if success { 0 } else { 101 }
         );
         if success {
-            assert!(json["findings"].as_array().unwrap().is_empty());
+            assert_eq!(json["findings"].as_array().unwrap().as_slice(), []);
         }
         for finding in json["findings"].as_array().unwrap() {
             assert_url(&f.report(), finding["url"].as_str().unwrap());
Rendered diagnostic (text)
warning: used `assert!` to check that a value is empty
   --> tests/metadata.rs:156:13
    |
156 |             assert!(json["findings"].as_array().unwrap().is_empty());
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.100.0/index.html#assert_is_empty
help: use `assert_eq!` to show the value on failure
    |
156 -             assert!(json["findings"].as_array().unwrap().is_empty());
156 +             assert_eq!(json["findings"].as_array().unwrap().as_slice(), []);
    |