feat: implement all P1/P2/P3/P4 improvements from issue backlog
P1 correctness: - filter test files by default (--include-tests to opt in) - per-module diagrams show cross-module dependency arrows - qualified type names (Module::TypeName) fix false edges from duplicate names P2 output richness: - method parameter types and return types in class diagrams (Rust + Python) - Python pyproject.toml project analyzer (--level project for monorepos) P3 unique value: - boundary rules in archlens.toml ([rules] allow/deny, --strict enforcement) P4 nice to have: - dependency weight labels on module arrows (--no-weights to disable) - --watch mode with 500ms debounce - D2 renderer adapter (--format d2) - interactive self-contained HTML viewer (--format html) - git-aware incremental analysis (--since <ref>)
This commit is contained in:
@@ -7,6 +7,14 @@ use archlens_domain::{
|
||||
AnalysisConfig, DiagramLevel, DomainError, OutputConfig, ports::ConfigLoader,
|
||||
};
|
||||
|
||||
#[derive(Debug, Deserialize, Default)]
|
||||
struct RawRules {
|
||||
#[serde(default)]
|
||||
allow: Vec<String>,
|
||||
#[serde(default)]
|
||||
deny: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Default)]
|
||||
struct RawConfig {
|
||||
#[serde(default)]
|
||||
@@ -15,6 +23,8 @@ struct RawConfig {
|
||||
output: RawOutput,
|
||||
#[serde(default)]
|
||||
modules: HashMap<String, String>,
|
||||
#[serde(default)]
|
||||
rules: RawRules,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Default)]
|
||||
@@ -68,6 +78,10 @@ impl ConfigLoader for TomlConfigLoader {
|
||||
Ok(config)
|
||||
}
|
||||
|
||||
fn load_rules(&self) -> (Vec<String>, Vec<String>) {
|
||||
(self.raw.rules.allow.clone(), self.raw.rules.deny.clone())
|
||||
}
|
||||
|
||||
fn load_output_config(&self) -> Result<OutputConfig, DomainError> {
|
||||
let mut config =
|
||||
OutputConfig::default().with_split_by_module(self.raw.output.split_by_module);
|
||||
|
||||
@@ -66,3 +66,27 @@ fn missing_file_returns_defaults() {
|
||||
assert!(!output.split_by_module());
|
||||
assert!(output.output_path().is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn loads_boundary_rules_from_toml_file() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let config_path = dir.path().join("archlens.toml");
|
||||
fs::write(
|
||||
&config_path,
|
||||
r#"
|
||||
[rules]
|
||||
allow = ["Application --> Domain", "Adapters --> Domain"]
|
||||
deny = ["Domain --> Adapters"]
|
||||
"#,
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let loader = TomlConfigLoader::from_path(&config_path).unwrap();
|
||||
let (allow, deny) = loader.load_rules();
|
||||
|
||||
assert_eq!(allow.len(), 2);
|
||||
assert_eq!(deny.len(), 1);
|
||||
assert!(allow.iter().any(|r| r == "Application --> Domain"));
|
||||
assert!(allow.iter().any(|r| r == "Adapters --> Domain"));
|
||||
assert!(deny.iter().any(|r| r == "Domain --> Adapters"));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user