forge_lint/sol/low/
incorrect_modifier.rs1use super::IncorrectModifier;
2use crate::{
3 linter::{LateLintPass, LintContext},
4 sol::{Severity, SolLint, analysis::block_outcome},
5};
6use solar::{
7 ast::FunctionKind,
8 sema::{Gcx, hir::Function},
9};
10
11declare_forge_lint!(
12 INCORRECT_MODIFIER,
13 Severity::Low,
14 "incorrect-modifier",
15 "modifier can finish without executing the modified function"
16);
17
18impl<'gcx> LateLintPass<'gcx> for IncorrectModifier {
19 fn check_function(&mut self, ctx: &LintContext, gcx: Gcx<'gcx>, func: &'gcx Function<'gcx>) {
20 if func.kind == FunctionKind::Modifier
21 && func.body.is_some_and(|body| block_outcome(gcx, body).can_skip_placeholder())
22 {
23 ctx.emit(&INCORRECT_MODIFIER, func.span);
24 }
25 }
26}