Skip to main content

Engine

Struct Engine 

Source
pub struct Engine { /* private fields */ }
Expand description

Everything a run needs, built once and shared across workers.

Implementations§

Source§

impl Engine

Source

pub fn prepare( config: &Config, project_root: &Path, rules_root: RuleRoot, config_path: &Path, registry: &LanguageRegistry, typescript: Arc<dyn Language>, javascript: Arc<dyn Language>, ) -> Result<Self, RunError>

Prepare a run.

Everything that can fail on a rule’s own contents fails here, before any file is read — a run that dies halfway through because rule seventeen has a typo has already wasted the work.

§Errors

Returns RunError for an invalid query, gate, or language reference.

Source

pub const fn without_cache(self) -> Self

Turn the cache off, for --no-cache and for tests that need a cold run.

Source

pub const fn profiling(self) -> Self

Collect per-rule timings.

Off by default because measuring costs a clock read per handler invocation, and the path a warm run takes is the one place that matters most.

Source

pub const fn reporting_unused_suppressions(self) -> Self

Report suppressions that silenced nothing.

Off by default because it is hygiene rather than correctness: a suppression whose violation no longer exists is debt, and debt is worth surfacing on request rather than in everyone’s inner loop.

Source

pub const fn with_today(self, today: Date) -> Self

Fix the date expires: is compared against.

For tests, which otherwise could not assert anything about expiry without waiting.

Source

pub const fn without_reduce(self) -> Self

Skip every reduce phase.

For a run over a deliberately partial corpus. A cross-file rule consumes facts from every file, so running one over a subset does not give a smaller answer — it gives a wrong one. no-unused-exports over three changed files would report every export in them as unused, because the importers were never looked at.

Skipping is therefore the only sound option, and the caller that narrowed the corpus is the one that has to say so to the user.

Source

pub fn discover(&self) -> Vec<FilePath>

The files discovery selects, before any gate.

For a caller narrowing the corpus: intersecting with this is what keeps include and exclude in force, so --staged cannot check a file the config excluded.

Source

pub fn rule_count(&self) -> usize

How many rules will actually run. Rules set to off are dropped at preparation.

Source

pub fn rules(&self) -> impl Iterator<Item = &RuleSpec>

The rules that will run, in the order the config declared them.

The specs rather than a rendered listing: what a listing should look like is the reporter’s problem, and an engine that decided it would have to be changed for every new output format.

Source

pub fn run(&self) -> Result<Outcome, RunError>

Run over the whole corpus.

§Errors

Returns the first RunError any worker produced. Rayon’s reduction is not order-dependent, so which of several simultaneous failures surfaces is arbitrary — but every one of them aborts the run, so the choice does not change the outcome.

Source

pub fn run_over(&self, files: &[FilePath]) -> Result<Outcome, RunError>

Run over an explicit file list, for --since and --staged.

§Errors

As Engine::run.

Trait Implementations§

Source§

impl Debug for Engine

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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, 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> ParallelSend for T

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, 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.