bevy_lint/lints/suspicious/
mod.rs

1//! Lints that checks for suspicious, potentially incorrect code.
2//!
3//! Unlike [`correctness`](super::correctness) lints, these may have false positives that you need
4//! to `#[allow(...)]`.
5//!
6//! These lints are **warn** by default.
7
8use rustc_lint::{Level, Lint, LintStore};
9
10use crate::lint::LintGroup;
11
12pub mod insert_message_resource;
13pub mod iter_current_update_messages;
14pub mod unit_in_bundle;
15
16pub(crate) struct Suspicious;
17
18impl LintGroup for Suspicious {
19    const NAME: &str = "bevy::suspicious";
20    const LEVEL: Level = Level::Warn;
21    const LINTS: &[&Lint] = &[
22        insert_message_resource::INSERT_MESSAGE_RESOURCE,
23        iter_current_update_messages::ITER_CURRENT_UPDATE_MESSAGES,
24        unit_in_bundle::UNIT_IN_BUNDLE,
25    ];
26
27    fn register_passes(store: &mut LintStore) {
28        store.register_late_pass(|_| Box::new(insert_message_resource::InsertMessageResource));
29        store.register_late_pass(|_| {
30            Box::new(iter_current_update_messages::IterCurrentUpdateMessages)
31        });
32        store.register_late_pass(|_| Box::new(unit_in_bundle::UnitInBundle));
33    }
34
35    fn register_lints(store: &mut LintStore) {
36        store.register_lints(Self::LINTS);
37
38        // These help users migrate from v0.4.0 to v0.5.0. These lines should be removed before
39        // v0.6.0 is released.
40        store.register_renamed(
41            "bevy::insert_event_resource",
42            "bevy::insert_message_resource",
43        );
44        store.register_renamed(
45            "bevy::iter_current_update_events",
46            "bevy::iter_current_update_messages",
47        );
48    }
49}