Skip to main content

luaur_analysis/functions/
emit_warning.rs

1use crate::records::lint_context::LintContext;
2use alloc::string::String;
3use luaur_ast::records::location::Location;
4use luaur_common::functions::vformat::vformat;
5use luaur_config::enums::code::Code;
6use luaur_config::records::lint_warning::LintWarning;
7
8pub fn emit_warning(
9    context: &mut LintContext,
10    code: Code,
11    location: Location,
12    args: core::fmt::Arguments<'_>,
13) {
14    if !context.warning_enabled(code) {
15        return;
16    }
17
18    let message: String = vformat(args);
19    let warning = LintWarning {
20        code,
21        location,
22        text: message,
23    };
24    context.result.push(warning);
25}