Skip to content

Commit

Permalink
refactor: only depend on templaters function and name
Browse files Browse the repository at this point in the history
  • Loading branch information
benfdking committed Nov 23, 2024
1 parent 5aaf36c commit 2f1564f
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions crates/lib/src/core/linter/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@ use crate::core::linter::linting_result::LintingResult;
use crate::core::rules::base::{ErasedRule, LintPhase, RulePack};
use crate::core::rules::noqa::IgnoreMask;
use crate::rules::get_ruleset;
use crate::templaters::placeholder::PlaceholderTemplater;
use crate::templaters::raw::RawTemplater;
use crate::templaters::Templater;
use crate::templaters::{templaters, Templater};

pub struct Linter {
config: FluffConfig,
Expand All @@ -52,10 +51,14 @@ impl Linter {
None => {
let templater = config.get("templater", "core").as_string();
match templater {
Some("placeholder") => Arc::<PlaceholderTemplater>::default(),
Some("raw") => Arc::<RawTemplater>::default(),
Some(templater) => {
let templaters = templaters();
match templaters.into_iter().find(|t| t.name() == templater) {
Some(t) => t.into(),
None => panic!("Unknown templater: {}", templater),
}
}
None => Arc::<RawTemplater>::default(),
_ => panic!("Unknown templater: {}", templater.unwrap()),
}
}
};
Expand Down

0 comments on commit 2f1564f

Please sign in to comment.