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/// Style checks that consume IR facts and produce violations.
40pub mod style;
41/// The `Violation` type, display formatting, and check rationale.
42pub mod violation;
43
44pub use analysis_result::AnalysisResult;
45pub use check_config::{
46 CheckConfig as Config, ConfigFile, GateConfig, GateRuleOverride, NamingCheck, PatternCheck,
47 PatternOverride,
48};
49pub use checks::{ALL_CHECKS, CheckInfo};
50pub use gate::{GateRuleInfo, GateSeverity, GateVerdict, all_gate_rules, evaluate_gate_rules};
51pub use lint::{
52 LintError, analyze, analyze_build_script, analyze_with_build_script, determine_analysis_tier,
53 discover_build_script, discover_workspace_root, lint_file, lint_str,
54};
55pub use violation::{CheckRationale, Violation, ViolationType, lookup_rationale};
56
57/// Alias for `syn::Error`, used by consumers that call [`analyze`] directly.
58pub use syn::Error as ParseError;
59
60pub use ir::semantic::SemanticContext;