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        // This helps users migrate to v0.4.0, but should be removed before v0.5.0 is released.
39        store.register_renamed("bevy::insert_unit_bundle", "bevy::unit_in_bundle");
40    }
41}