style: cargo fmt
All checks were successful
CI / Check / Test (push) Successful in 3m1s
Architecture Docs / Generate diagrams (push) Successful in 2m43s

This commit is contained in:
2026-06-17 13:44:19 +02:00
parent a24dc572bd
commit 009c821f48
14 changed files with 1834 additions and 51 deletions

View File

@@ -97,7 +97,11 @@ fn render_module(graph: &CodeGraph) -> String {
}
for (src, tgt) in graph.module_edges().keys() {
lines.push(format!("{} -> {}", sanitize_identifier(src), sanitize_identifier(tgt)));
lines.push(format!(
"{} -> {}",
sanitize_identifier(src),
sanitize_identifier(tgt)
));
}
lines.join("\n")
@@ -113,7 +117,11 @@ fn render_project(graph: &CodeGraph) -> String {
let mod_id = sanitize_identifier(module);
lines.push(format!("{mod_id}: {{"));
for el in elements {
lines.push(format!(" {}: {}", sanitize_identifier(el.name()), el.name()));
lines.push(format!(
" {}: {}",
sanitize_identifier(el.name()),
el.name()
));
}
lines.push("}".to_string());
}

View File

@@ -2,9 +2,7 @@ use std::collections::HashMap;
use serde::Serialize;
use archlens_domain::{
CodeGraph, DomainError, RenderOutput, RenderedFile, ports::DiagramRenderer,
};
use archlens_domain::{CodeGraph, DomainError, RenderOutput, RenderedFile, ports::DiagramRenderer};
use archlens_rendering_primitives::non_import_rels;
pub struct HtmlRenderer;

View File

@@ -1,6 +1,4 @@
use archlens_domain::{
Relationship, RelationshipKind,
};
use archlens_domain::{Relationship, RelationshipKind};
use archlens_rendering_primitives::{non_import_rels, sanitize_identifier};
fn rel(src: &str, tgt: &str, kind: RelationshipKind) -> Relationship {
@@ -16,7 +14,11 @@ fn non_import_rels_excludes_import_relationships() {
];
let filtered: Vec<_> = non_import_rels(&rels).collect();
assert_eq!(filtered.len(), 2);
assert!(filtered.iter().all(|r| r.kind() != RelationshipKind::Import));
assert!(
filtered
.iter()
.all(|r| r.kind() != RelationshipKind::Import)
);
}
#[test]

View File

@@ -35,9 +35,7 @@ const RUST_PRIMITIVES: &[&str] = &[
"Self",
];
use archlens_domain::{
CodeElement, CodeElementKind, Relationship, RelationshipKind, Visibility,
};
use archlens_domain::{CodeElement, CodeElementKind, Relationship, RelationshipKind, Visibility};
use crate::extraction_context::ExtractionContext;
use crate::language_extractor::LanguageExtractor;

View File

@@ -26,7 +26,8 @@ impl<'a> DiffDiagram<'a> {
let current = rendered.files().first().map(|f| f.content()).unwrap_or("");
let current_lines: std::collections::HashSet<&str> = current.lines().collect();
let existing_lines: std::collections::HashSet<&str> = self.existing_content.lines().collect();
let existing_lines: std::collections::HashSet<&str> =
self.existing_content.lines().collect();
let added: Vec<String> = current_lines
.difference(&existing_lines)

View File

@@ -30,7 +30,11 @@ fn project_level_returns_project_analyzer_graph() {
};
let result = use_case
.execute(Path::new("."), &AnalysisConfig::default(), DiagramLevel::Project)
.execute(
Path::new("."),
&AnalysisConfig::default(),
DiagramLevel::Project,
)
.unwrap();
assert_eq!(result.graph.elements().len(), 1);
@@ -47,7 +51,11 @@ fn project_level_without_analyzer_returns_error() {
};
let err = use_case
.execute(Path::new("."), &AnalysisConfig::default(), DiagramLevel::Project)
.execute(
Path::new("."),
&AnalysisConfig::default(),
DiagramLevel::Project,
)
.unwrap_err();
assert!(err.to_string().contains("no project analyzer"));
@@ -63,13 +71,15 @@ fn type_level_uses_source_analyzer_not_project() {
let analyzer = FakeSourceAnalyzer::new().with_result(
"src/order.rs",
AnalysisResult::new(
vec![CodeElement::new(
"Order",
CodeElementKind::Struct,
FilePath::new("src/order.rs").unwrap(),
1,
)
.unwrap()],
vec![
CodeElement::new(
"Order",
CodeElementKind::Struct,
FilePath::new("src/order.rs").unwrap(),
1,
)
.unwrap(),
],
vec![],
vec![],
),
@@ -93,7 +103,11 @@ fn type_level_uses_source_analyzer_not_project() {
};
let result = use_case
.execute(Path::new("."), &AnalysisConfig::default(), DiagramLevel::Type)
.execute(
Path::new("."),
&AnalysisConfig::default(),
DiagramLevel::Type,
)
.unwrap();
// Source element present, project element NOT merged (Type level skips merge)
@@ -110,7 +124,11 @@ fn module_level_without_project_analyzer_succeeds() {
};
let result = use_case
.execute(Path::new("."), &AnalysisConfig::default(), DiagramLevel::Module)
.execute(
Path::new("."),
&AnalysisConfig::default(),
DiagramLevel::Module,
)
.unwrap();
assert!(result.graph.elements().is_empty());
@@ -128,12 +146,14 @@ fn warnings_from_source_analysis_are_propagated() {
AnalysisResult::new(
vec![],
vec![],
vec![AnalysisWarning::new(
FilePath::new("src/broken.rs").unwrap(),
5,
"unparseable block",
)
.unwrap()],
vec![
AnalysisWarning::new(
FilePath::new("src/broken.rs").unwrap(),
5,
"unparseable block",
)
.unwrap(),
],
),
);
@@ -144,7 +164,11 @@ fn warnings_from_source_analysis_are_propagated() {
};
let result = use_case
.execute(Path::new("."), &AnalysisConfig::default(), DiagramLevel::Module)
.execute(
Path::new("."),
&AnalysisConfig::default(),
DiagramLevel::Module,
)
.unwrap();
assert_eq!(result.warnings.len(), 1);

View File

@@ -1,7 +1,7 @@
mod fakes;
use archlens_domain::{CodeGraph, NormalizedGraph, ports::DiagramRenderer};
use archlens_application::use_cases::check_freshness::CheckFreshness;
use archlens_domain::{CodeGraph, NormalizedGraph, ports::DiagramRenderer};
use fakes::FakeDiagramRenderer;
fn empty_graph() -> NormalizedGraph {

View File

@@ -1,7 +1,7 @@
mod fakes;
use archlens_domain::{CodeGraph, NormalizedGraph, ports::DiagramRenderer};
use archlens_application::use_cases::diff_diagram::DiffDiagram;
use archlens_domain::{CodeGraph, NormalizedGraph, ports::DiagramRenderer};
use fakes::FakeDiagramRenderer;
fn empty_graph() -> NormalizedGraph {

View File

@@ -12,7 +12,9 @@ impl FakeProjectAnalyzer {
}
pub fn empty() -> Self {
Self { graph: CodeGraph::new() }
Self {
graph: CodeGraph::new(),
}
}
}

View File

@@ -24,13 +24,15 @@ fn graph_with_one_module() -> NormalizedGraph {
let analyzer = FakeSourceAnalyzer::new().with_result(
"/p/src/orders/order.rs",
AnalysisResult::new(
vec![CodeElement::new(
"Order",
CodeElementKind::Struct,
FilePath::new("/p/src/orders/order.rs").unwrap(),
1,
)
.unwrap()],
vec![
CodeElement::new(
"Order",
CodeElementKind::Struct,
FilePath::new("/p/src/orders/order.rs").unwrap(),
1,
)
.unwrap(),
],
vec![],
vec![],
),
@@ -44,12 +46,22 @@ fn graph_with_one_module() -> NormalizedGraph {
fn graph_with_violation() -> NormalizedGraph {
let mut cg = CodeGraph::new();
let a = CodeElement::new("A", CodeElementKind::Struct, FilePath::new("a.rs").unwrap(), 1)
.unwrap()
.with_module(ModuleName::new("Alpha").unwrap());
let b = CodeElement::new("B", CodeElementKind::Struct, FilePath::new("b.rs").unwrap(), 1)
.unwrap()
.with_module(ModuleName::new("Beta").unwrap());
let a = CodeElement::new(
"A",
CodeElementKind::Struct,
FilePath::new("a.rs").unwrap(),
1,
)
.unwrap()
.with_module(ModuleName::new("Alpha").unwrap());
let b = CodeElement::new(
"B",
CodeElementKind::Struct,
FilePath::new("b.rs").unwrap(),
1,
)
.unwrap()
.with_module(ModuleName::new("Beta").unwrap());
cg.add_element(a);
cg.add_element(b);
cg.add_relationship(Relationship::new("A", "B", RelationshipKind::Composition).unwrap());

View File

@@ -3,9 +3,7 @@ mod cli;
use anyhow::{Result, bail};
use archlens_application::use_cases::{
build_code_graph::BuildCodeGraph,
check_freshness::CheckFreshness,
diff_diagram::DiffDiagram,
build_code_graph::BuildCodeGraph, check_freshness::CheckFreshness, diff_diagram::DiffDiagram,
generate_diagram::GenerateDiagram,
};
use archlens_ascii::AsciiRenderer;
@@ -96,7 +94,11 @@ pub fn run(args: Cli) -> Result<()> {
Ok(())
}
fn write_diagram_output(output: &RenderOutput, output_path: Option<&str>, split: bool) -> Result<()> {
fn write_diagram_output(
output: &RenderOutput,
output_path: Option<&str>,
split: bool,
) -> Result<()> {
if split {
let dir = std::path::PathBuf::from(output_path.unwrap_or("."));
std::fs::create_dir_all(&dir)?;