Skip to main content

enya_analyzer/
lib.rs

1//! Metrics instrumentation indexer for source code.
2//!
3//! This crate provides functionality to scan source code repositories
4//! and build an index of metric instrumentation points.
5//!
6//! # Architecture
7//!
8//! - [`scanner`]: Language-agnostic scanner framework with trait-based extensibility
9//! - [`parser`]: Tree-sitter parsing utilities for Rust
10//! - [`repo`]: Git operations (clone, fetch, update)
11//! - [`index`]: In-memory index of discovered instrumentation
12//! - [`diff`]: Diff parsing and semantic extraction
13
14#![forbid(unsafe_code)]
15#![deny(clippy::all)]
16#![deny(clippy::unwrap_used)]
17#![warn(clippy::pedantic)]
18
19pub mod diff;
20pub mod index;
21pub mod parser;
22pub mod repo;
23pub mod scanner;
24
25pub use diff::extract_semantics;
26pub use index::{CodebaseIndex, IndexProgress, build_index_with_progress};
27pub use parser::ParseError;
28#[allow(deprecated)]
29pub use repo::{
30    CommitInfo, DiffSemantics, ProgressCallback, count_commits, fetch_all_commits,
31    fetch_all_commits_with_diffs_batch, fetch_all_commits_with_diffs_parallel, fetch_commit_diff,
32    fetch_commit_history, fetch_recent_commits, fetch_recent_commits_with_diffs, get_head_commit,
33    get_head_commit_message,
34};
35pub use scanner::{AlertRule, MetricInstrumentation, MetricKind, Scanner, ScannerRegistry};
36
37/// Get the current Unix timestamp in seconds.
38#[inline]
39#[must_use]
40#[allow(clippy::cast_possible_wrap, clippy::disallowed_types)]
41pub fn now_unix_secs() -> i64 {
42    std::time::SystemTime::now()
43        .duration_since(std::time::UNIX_EPOCH)
44        .map(|d| d.as_secs() as i64)
45        .unwrap_or(0)
46}