aboutsummaryrefslogtreecommitdiff
path: root/mingling_cli/src/linter/mlint_report.rs
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2026-07-21 15:38:00 +0800
committer魏曹先生 <1992414357@qq.com>2026-07-21 15:38:00 +0800
commit0056e1095e75b34f39cde7de87ce6be2cd301ff1 (patch)
tree5a79e51a8a42a7d1f40e8eab388c7b71f279b1a2 /mingling_cli/src/linter/mlint_report.rs
parenta4780f04172b3ef9fb11af5f7bc8abd7139cbe54 (diff)
feat(mlint): support RenderResult::default and ::from detection
Extend the `unnecessary_render_result_creation` lint to also flag uses of `RenderResult::default()` and `RenderResult::from(...)`, and add `#[derive(Default)]` to `MlintReport` and `MlintLevel` to simplify struct instantiation
Diffstat (limited to 'mingling_cli/src/linter/mlint_report.rs')
-rw-r--r--mingling_cli/src/linter/mlint_report.rs12
1 files changed, 5 insertions, 7 deletions
diff --git a/mingling_cli/src/linter/mlint_report.rs b/mingling_cli/src/linter/mlint_report.rs
index 3c52828..07fc5c1 100644
--- a/mingling_cli/src/linter/mlint_report.rs
+++ b/mingling_cli/src/linter/mlint_report.rs
@@ -14,6 +14,7 @@ use crate::Next;
use crate::metadata::setup::ResUsingJson;
/// Complete structure of a Lint report, containing inspection results and associated metadata.
+#[derive(Default)]
pub struct MlintReport {
/// Source file name
pub file_name: String,
@@ -50,11 +51,12 @@ pub struct MlintReport {
}
/// Report severity level, indicating the seriousness of the Lint result.
-#[derive(Clone, Copy, PartialEq, Eq)]
+#[derive(Default, Clone, Copy, PartialEq, Eq)]
pub enum MlintLevel {
+ #[default]
+ Note,
Error,
Warning,
- Note,
Help,
}
@@ -228,17 +230,13 @@ impl MlintReport {
group = group.element(msg);
}
- // 添加 note: `#[mlint(level([code]))]` on by default
if !self.lint_code.is_empty() {
let level_name = match self.level {
MlintLevel::Error => "deny",
MlintLevel::Warning => "warn",
MlintLevel::Note | MlintLevel::Help => "allow",
};
- let note_text = format!(
- "`#[mlint({level_name}([{}]))]` on by default",
- self.lint_code
- );
+ let note_text = format!("`#[mlint({level_name}({}))]` on by default", self.lint_code);
let note_msg = NOTE.clone().message(note_text);
group = group.element(note_msg);
}