Skip to main content

AdapterMeta

Struct AdapterMeta 

Source
pub struct AdapterMeta {
Show 15 fields pub tool_name: &'static str, pub display_name: &'static str, pub tool_version: &'static str, pub long_version: &'static str, pub about: &'static str, pub long_about: &'static str, pub after_help: &'static str, pub coverage_hint: &'static str, pub extensions: &'static [&'static str], pub tool_info_uri: &'static str, pub rule_help_uri: &'static str, pub config_file_name: &'static str, pub default_excludes: &'static [&'static str], pub forced_excludes: &'static [&'static str], pub default_metric: ComplexityMetric,
}
Expand description

Adapter-supplied runtime metadata that crap-core threads through parse_args, run, and the reporter call sites.

All fields are &'static because every production caller supplies env!(...) / build.rs-stamped literals or const &[&str] slices. Tests construct from &'static str literals too. The lifetime parameter was dropped in #161 — no caller ever needed non-static metadata, and the <'a> ripple polluted 15 function signatures for no payoff. The struct stays Copy so threading is trivial.

Reporters keep a flat (tool_name, tool_version) call boundary — the struct only travels through orchestration code.

Fields§

§tool_name: &'static str

Adapter binary name (e.g., "crap4rs", "crap4ts"). Drives clap’s --version output, the name field in SARIF, and the header line in table/markdown/html reporters.

§display_name: &'static str

Human-readable adapter label (e.g., "Rust", "TypeScript"). Surfaced in the HTML reporter’s per-adapter footer row so end users read “Rust · cognitive complexity” instead of the binary name. Production binaries supply the language name; tests use a synthetic label. Distinct from tool_name because the binary’s package name is the wrong granularity for the adapter-provenance footer.

§tool_version: &'static str

Short version string (e.g., "0.5.0"). Threaded to every reporter alongside tool_name.

§long_version: &'static str

Long version string for --version --long (e.g., "0.5.0 (abc1234 2026-05-09)").

§about: &'static str

Short adapter-flavored help text (one-line, shown by --help).

§long_about: &'static str

Long adapter-flavored help text (multi-paragraph, shown by --help in full mode).

§after_help: &'static str

after_help block with adapter-specific examples (crap4rs --coverage lcov.info ... etc.). May be empty.

§coverage_hint: &'static str

Coverage-tool hint shown when --coverage points at a file with no SF: / DA: records. Adapter-specific because the remediation depends on the coverage toolchain (Rust: cargo llvm-cov --lcov; TS: c8 --reporter=lcov).

§extensions: &'static [&'static str]

File extensions the walker should pick up (e.g., &["rs"] for crap4rs; &["ts","tsx","js","jsx","mjs","cjs"] for crap4ts). Adapter binaries supply a const &[&str]; copied into AnalyzeOptions.extensions at the orchestration boundary.

§tool_info_uri: &'static str

Adapter repo URL spliced into SARIF’s runs[0].tool.driver.informationUri. Adapter-specific so crap4ts SARIF output links to crap4ts’s repo, not crap4rs’s.

§rule_help_uri: &'static str

Adapter rule-help URL spliced into SARIF’s runs[0].tool.driver.rules[0].helpUri. Adapter-specific for the same reason as tool_info_uri.

§config_file_name: &'static str

Conventional config file name the adapter binary auto-discovers in the working directory (e.g., "crap4rs.toml" for the Rust adapter; "crap4ts.toml" for the TS adapter). Threaded through to discover_config and surfaced in --view <preset> error hints so users see the right file name to create.

§default_excludes: &'static [&'static str]

Commented-out exclude patterns emitted by init into the generated config (e.g., &["tests/**", "benches/**", "examples/**"] for Rust; &["node_modules/**", "dist/**", "coverage/**"] for TS). Adapter-specific because the convention for “where tests and ignorable artifacts live” differs per ecosystem. May be empty — init then emits the # exclude = [ … ] block without per-language entries.

This field is init-template only — it does NOT affect the analyzer’s effective exclude list at runtime. The runtime exclude list is built from cli.filter.exclude plus the user’s crap4ts.toml/crap4rs.toml exclude entries, with adapter- mandated patterns prepended via forced_excludes (below).

§forced_excludes: &'static [&'static str]

Adapter-mandated exclude patterns prepended to every analysis run, regardless of CLI flags or user config. Use for files that are structurally never source for the adapter’s language — e.g. crap4ts sets &["**/*.d.ts"] because TypeScript declaration files contain only ambient types, never executable code. crap4rs has no such suffix today and sets &[].

Distinct from default_excludes (above): forced excludes are load-bearing at analysis time and cannot be turned off by the operator, whereas default_excludes is init-template scaffolding. If an operator genuinely needs .d.ts files in their report, the path is forking the adapter or filing a follow-up to add an opt-out — not a config knob (crap-rs#253).

§default_metric: ComplexityMetric

The default complexity metric the adapter binary uses when neither CLI nor config file specifies one. crap4rs sets Cognitive; crap4ts sets Cyclomatic (the only metric crap4ts currently supports per CrapError::MetricNotSupported). Threaded through merge_effective_inputs so the binary’s default flips per adapter without re-litigating the shared CLI fallthrough. See ADR (d) adr-adapter-meta-default-metric.md for the design rationale (per-adapter defaults surface through AdapterMeta, not crap-core configuration).

Implementations§

Source§

impl AdapterMeta

Source

pub fn extensions_owned(&self) -> Vec<String>

Allocate an owned Vec<String> from extensions for inclusion in AnalyzeOptions (which owns its config rather than borrowing from the meta, decoupling analysis lifetime from CLI lifetime).

Trait Implementations§

Source§

impl Clone for AdapterMeta

Source§

fn clone(&self) -> AdapterMeta

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for AdapterMeta

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Copy for AdapterMeta

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.