pub struct CodeQualityAnalyzer { /* private fields */ }Expand description
The code-quality analyzer.
Built once per process. The chain and the cache are both passed in
rather than constructed here: they are process-wide resources. The chain in
particular carries the concurrency limiter for each provider and the
record of which providers have been demoted, so a second chain would both
double the in-flight requests against one endpoint and re-discover a dead
provider the first one already knew about.
The model and temperature are not duplicated onto this struct. They belong to the provider that ends up answering, which is not known until the chain has run, and a second copy is exactly what lets a request go to one model while the cache key names another.
Implementations§
Source§impl CodeQualityAnalyzer
impl CodeQualityAnalyzer
Sourcepub fn new(chain: ProviderChain, cache: Cache) -> Self
pub fn new(chain: ProviderChain, cache: Cache) -> Self
Build from a provider chain and a shared cache.
Infallible: ProviderChain::new has already rejected an empty or
misconfigured chain, so there is nothing left for this to validate.
cache is a parameter rather than constructed here so the key stays
independent of the Cache root (see Cache::key) and a test can
point it at a TempDir.
Sourcepub fn chain(&self) -> &ProviderChain
pub fn chain(&self) -> &ProviderChain
The provider chain, for a caller reporting which providers served.
Sourcepub async fn analyze_file(&self, hunks: &[Hunk]) -> AnalysisResult
pub async fn analyze_file(&self, hunks: &[Hunk]) -> AnalysisResult
Analyze one file’s hunks.
Returns an AnalysisResult populated with whatever the file
produced: findings, a failure marker, or both. The result is never a
bare Vec<Finding>; the failure axis is part of the return type so
the caller cannot forget it.
Sourcepub async fn analyze_files(&self, by_file: &[Vec<Hunk>]) -> AnalysisResult
pub async fn analyze_files(&self, by_file: &[Vec<Hunk>]) -> AnalysisResult
Analyze many files concurrently, bounded by the limiter.
Each entry of by_file is one file’s hunks; the limiter bounds the
in-flight requests, so we spawn them all and let it queue. The
per-file results are merged with AnalysisResult::merge.