#[non_exhaustive]pub struct MetricsOptions { /* private fields */ }Expand description
Per-traversal options for analyze / Ast::metrics.
Marked #[non_exhaustive] so future option fields can land
additively. Downstream callers must construct via the builder
methods rather than struct-literal syntax (rustc rejects external
struct literals on non-exhaustive types with E0639, including the
..Default::default() spread form). The defaults preserve every
metric value emitted by the pre-#182 analyze entry point.
use big_code_analysis::MetricsOptions;
let opts = MetricsOptions::default().with_exclude_tests(true);Implementations§
Source§impl MetricsOptions
impl MetricsOptions
Sourcepub fn with_exclude_tests(self, exclude_tests: bool) -> Self
pub fn with_exclude_tests(self, exclude_tests: bool) -> Self
Builder-style setter for MetricsOptions::exclude_tests.
Provided because MetricsOptions is #[non_exhaustive] — the
struct-literal form is unavailable to downstream crates, so
external callers chain MetricsOptions::default() .with_exclude_tests(true) instead.
Sourcepub fn with_count_cyclomatic_try(self, count: bool) -> Self
pub fn with_count_cyclomatic_try(self, count: bool) -> Self
Builder-style setter for MetricsOptions::count_cyclomatic_try.
Pass false to stop Rust’s ? operator from contributing to
cyclomatic complexity (standard and modified). The default is
true, which keeps every published metric value unchanged
(#409). Inert for non-Rust languages, none of which emit the
try_expression grammar node.
Sourcepub fn with_only(self, metrics: &[Metric]) -> Self
pub fn with_only(self, metrics: &[Metric]) -> Self
Restrict computation to the given metrics. Metrics outside
this set are skipped during the walk; their Stats fields on
CodeMetrics remain at their Default value and are
elided from the Serialize output. Pass an empty slice to
disable every metric (the walker still runs and produces the
space tree, but no metric values are populated).
§Dependencies
Derived metrics implicitly pull in the inputs they require:
Metric::MiaddsMetric::Loc,Metric::Cyclomatic,Metric::Halstead.Metric::WmcaddsMetric::CyclomaticandMetric::Nom.
This auto-resolution is silent: a caller asking for Mi
alone gets a populated Mi value, not a zero. See
Metric::dependencies for the source of truth.
§Examples
use big_code_analysis::{Metric, MetricsOptions};
// Compute LoC only.
let _opts = MetricsOptions::default().with_only(&[Metric::Loc]);
// Compute Mi: Loc + Cyclomatic + Halstead are auto-added.
let _opts = MetricsOptions::default().with_only(&[Metric::Mi]);Sourcepub fn with_metric_set(self, metrics: MetricSet) -> Self
pub fn with_metric_set(self, metrics: MetricSet) -> Self
Restrict computation to the metrics in metrics, closing the
set under Metric::dependencies before storing it.
Like MetricsOptions::with_only, a derived metric pulls in
the inputs it needs: passing MetricSet::empty().with(Metric::Mi)
also selects Metric::Loc, Metric::Cyclomatic, and
Metric::Halstead, so the maintainability index is computed
from real inputs rather than zero-valued defaults (#743). The
resolution is idempotent: an already-closed set is stored
unchanged.
Use this builder when you already hold a MetricSet; reach
for MetricsOptions::with_only when you have a &[Metric].
§Examples
use big_code_analysis::{Metric, MetricSet, MetricsOptions};
// `Mi` alone — Loc + Cyclomatic + Halstead are auto-added so the
// resulting MI value is meaningful.
let set = MetricSet::empty().with(Metric::Mi);
let _opts = MetricsOptions::default().with_metric_set(set);Trait Implementations§
Source§impl Clone for MetricsOptions
impl Clone for MetricsOptions
Source§fn clone(&self) -> MetricsOptions
fn clone(&self) -> MetricsOptions
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for MetricsOptions
Source§impl Debug for MetricsOptions
impl Debug for MetricsOptions
Source§impl Default for MetricsOptions
impl Default for MetricsOptions
impl Eq for MetricsOptions
Source§impl PartialEq for MetricsOptions
impl PartialEq for MetricsOptions
Source§fn eq(&self, other: &MetricsOptions) -> bool
fn eq(&self, other: &MetricsOptions) -> bool
self and other values to be equal, and is used by ==.impl StructuralPartialEq for MetricsOptions
Auto Trait Implementations§
impl Freeze for MetricsOptions
impl RefUnwindSafe for MetricsOptions
impl Send for MetricsOptions
impl Sync for MetricsOptions
impl Unpin for MetricsOptions
impl UnsafeUnpin for MetricsOptions
impl UnwindSafe for MetricsOptions
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.