| Crates.io | issun-analyzer |
| lib.rs | issun-analyzer |
| version | 0.6.0 |
| created_at | 2025-11-24 09:18:14.474591+00 |
| updated_at | 2025-11-24 09:31:27.465969+00 |
| description | Static analysis tools for ISSUN game framework code |
| homepage | https://github.com/ynishi/issun |
| repository | https://github.com/ynishi/issun |
| max_upload_size | |
| id | 1947563 |
| size | 108,402 |
Static analysis tool for ISSUN EventBus and Hook systems.
issun-analyzer is a Rust static analysis library that extracts and visualizes the structure of event-driven plugin systems. It analyzes:
EventReader<E>) and publications (EventBus::publish<E>())on_*can_*before_*, after_*calculate_*generate_*.mmd files for https://mermaid.liveAdd to your Cargo.toml:
[dependencies]
issun-analyzer = { path = "crates/issun-analyzer" }
use issun_analyzer::prelude::*;
use std::path::PathBuf;
let analyzer = Analyzer::new(".");
let mut result = AnalysisResult::new();
// Analyze a system file
let system_path = PathBuf::from("crates/issun/src/plugin/combat/system.rs");
let file_analysis = analyzer.analyze_file(&system_path)?;
result.add_file(file_analysis);
// Print subscriptions
for sub in result.all_subscriptions() {
println!("System {} subscribes to {}", sub.subscriber, sub.event_type);
}
use issun_analyzer::prelude::*;
let graph_gen = EventFlowGraphGenerator::new(&result);
let mermaid_graph = graph_gen.generate();
std::fs::write("event_flow.mmd", mermaid_graph)?;
println!("Graph saved! View at https://mermaid.live");
use issun_analyzer::prelude::*;
let validator = Validator::new(&result);
let validation = validator.validate();
validation.print_report();
if validation.has_high_severity_warnings() {
println!("⚠️ High severity warnings found!");
}
Run the included examples from the project root:
# Analyze Combat plugin events
cargo run -p issun-analyzer --example analyze_combat
# Analyze all systems
cargo run -p issun-analyzer --example analyze_systems
# Analyze all plugins
cargo run -p issun-analyzer --example analyze_plugins
# Analyze hooks in detail
cargo run -p issun-analyzer --example analyze_hooks
# Generate event flow graph
cargo run -p issun-analyzer --example generate_event_flow
# Generate hook flow graph
cargo run -p issun-analyzer --example generate_hook_flow
# Generate combined event + hook graph
cargo run -p issun-analyzer --example generate_combined_flow
# Validate event flow consistency
cargo run -p issun-analyzer --example validate_event_flow
flowchart TD
CombatStartRequested["📨 CombatStartRequested"]
style CombatStartRequested fill:#e1f5ff
process_start_requests["process_start_requests"]
CombatStartRequested -->|subscribe| process_start_requests
flowchart TD
subgraph combat["combat Plugin"]
combat_CombatSystem["⚙️ CombatSystem"]
combat_CombatHook["🪝 CombatHook"]
style combat_CombatHook fill:#fff4e6
combat_CombatSystem -.->|uses| combat_CombatHook
combat_CombatHook_methods["📋 5 methods (3 notif, 1 valid)"]
combat_CombatHook -.-> combat_CombatHook_methods
end
The validator reports three severity levels:
Example output:
⚠️ Validation Warnings (2)
🟡 Medium Severity (1):
⚠️ Event 'FooEvent' is subscribed but never published
Subscribers: SystemA, SystemB
🟢 Low Severity (1):
⚠️ Event 'BarEvent' is published but never subscribed
Publishers: SystemC
issun-analyzer/
├── src/
│ ├── analyzer.rs # Core analysis orchestration
│ ├── event_extractor.rs # Event subscription/publication extraction
│ ├── system_extractor.rs # System implementation analysis
│ ├── plugin_extractor.rs # Plugin directory structure inference
│ ├── hook_extractor.rs # Hook trait analysis
│ ├── graph_generator.rs # Mermaid graph generation
│ ├── validator.rs # Event flow validation
│ ├── types.rs # Core data structures
│ └── error.rs # Error types
└── examples/
├── analyze_combat.rs
├── analyze_systems.rs
├── analyze_plugins.rs
├── analyze_hooks.rs
├── generate_event_flow.rs
├── generate_hook_flow.rs
├── generate_combined_flow.rs
└── validate_event_flow.rs
cargo test -p issun-analyzer
Current test coverage:
Arc<dyn Hook>)bus.publish(event) without ::<Type> is not detectedThis project is part of the ISSUN game framework.