pedant_core/lib.rs
1//! Analysis engine for pedant: IR extraction, style checks, and capability detection.
2//!
3//! `pedant-core` provides the core analysis pipeline without CLI dependencies.
4//! Parse Rust source, extract an intermediate representation, run style checks,
5//! and detect capability usage — all without pulling in `clap` or output formatting.
6//!
7//! # Quick start
8//!
9//! ```
10//! use pedant_core::{lint_str, Config};
11//!
12//! let config = Config::default();
13//! let result = lint_str("fn f() { if true { if false {} } }", &config).unwrap();
14//! assert!(!result.violations.is_empty());
15//! ```
16
17/// Violations + capabilities produced by a single analysis run.
18pub mod analysis_result;
19/// Path-based capability detection over extracted IR facts.
20pub mod capabilities;
21/// `.pedant.toml` schema, loading, and per-path override resolution.
22pub mod check_config;
23/// Check catalog: metadata, rationale, and the `ViolationType` enum.
24pub mod checks;
25/// Security gate rules that fire on suspicious capability combinations.
26pub mod gate;
27/// BFS and pairwise-edge helpers for type-relationship graphs.
28pub(crate) mod graph;
29/// SHA-256 hashing of source contents for attestation.
30pub mod hash;
31/// Intermediate representation extracted from the AST in one pass.
32pub mod ir;
33/// JSON serialization for machine-readable violation output.
34pub mod json_format;
35/// High-level analysis entry points and error types.
36pub mod lint;
37/// Glob and wildcard matching for AST node text and file paths.
38pub mod pattern;
39/// Whole-workspace structural checks over the file tree and Cargo metadata.
40pub mod project;
41/// Style checks that consume IR facts and produce violations.
42pub mod style;
43/// The `Violation` type, display formatting, and check rationale.
44pub mod violation;
45/// Cargo workspace member expansion helpers shared by CLI consumers.
46pub mod workspace;
47
48pub use analysis_result::AnalysisResult;
49pub use check_config::{
50 CheckConfig as Config, ConfigFile, GateConfig, GateRuleOverride, NamingCheck, PatternCheck,
51 PatternOverride,
52};
53pub use checks::{ALL_CHECKS, CheckInfo};
54pub use gate::{
55 GateInputSummary, GateRuleInfo, GateSeverity, GateVerdict, all_gate_rules, evaluate_gate_rules,
56};
57pub use lint::{
58 LintError, analyze, analyze_build_script, analyze_build_script_with_shape,
59 analyze_with_build_script, analyze_with_shape, determine_analysis_tier, discover_build_script,
60 discover_crate_root, discover_workspace_root, lint_file, lint_str,
61};
62pub use violation::{CheckRationale, Violation, ViolationType, lookup_rationale};
63pub use workspace::{WorkspaceMemberError, resolve_workspace_members};
64
65/// Alias for `syn::Error`, used by consumers that call [`analyze`] directly.
66pub use syn::Error as ParseError;
67
68#[cfg(feature = "semantic")]
69pub use ir::semantic::FunctionAnalysisSummary;
70pub use ir::semantic::{SemanticContext, SemanticFileAnalysis};