Skip to main content

CodeQualityAnalyzer

Struct CodeQualityAnalyzer 

Source
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

Source

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.

Source

pub fn with_cache_only(self, cache_only: bool) -> Self

Select a cache-only pass. The analyzer keeps parsing cached responses through the normal schema path; only the backend request is forbidden.

Source

pub fn chain(&self) -> &ProviderChain

The provider chain, for a caller reporting which providers served.

Source

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.

Source

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.

Source

pub async fn analyze_files_live(&self, by_file: &[&[Hunk]]) -> AnalysisResult

Analyze selected cache misses without rebuilding the provider chain.

Push-gate mode uses this after its cache-only pass, preserving sticky demotion and backend diagnostics while avoiding a second pass over every cache hit in the diff.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more