MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / regions

Function regions

libatomic/src/review/presentation.rs:58–186  ·  view source on GitHub ↗
(graph: &ReviewGraph)

Source from the content-addressed store, hash-verified

56}
57
58pub(super) fn regions(graph: &ReviewGraph) -> Vec<Region> {
59 let mut regions = BTreeMap::new();
60 let metrics: Vec<_> = graph
61 .nodes
62 .iter()
63 .filter(|node| node.kind == "metric")
64 .collect();
65 for node in &metrics {
66 let Some(path) = node.properties["path"].as_str() else {
67 continue;
68 };
69 let change = node.properties["change"].as_str().unwrap_or("");
70 let side = if metric_location(node, "after").0.is_some()
71 || metric_location(node, "before").0.is_none()
72 {
73 "after"
74 } else {
75 "before"
76 };
77 let (start, end) = metric_location(node, side);
78 let region = at(&mut regions, change, path, side, start, end);
79 region.metrics.insert(node.id.clone());
80 if let Some(subject) = node.properties["observation"]["subject"].as_str() {
81 region.subjects.insert(subject_label(subject).into());
82 }
83 }
84 for finding in &graph.findings {
85 for location in &finding.finding.locations {
86 let side = match location.side {
87 SourceSide::Before => "before",
88 SourceSide::After => "after",
89 };
90 at(
91 &mut regions,
92 &finding.finding.change,
93 &location.path,
94 side,
95 Some(location.start_line),
96 Some(location.end_line),
97 )
98 .findings
99 .insert(finding.number);
100 }
101 }
102 if let Some(risk) = &graph.risk {
103 for report in &risk.impact {
104 for function in &report.changed_functions {
105 for (side, location) in [
106 ("before", function.before.as_ref()),
107 ("after", function.after.as_ref()),
108 ] {
109 if let Some(location) = location {
110 let region = at(
111 &mut regions,
112 &report.change,
113 &location.path,
114 side,
115 Some(location.start_line),

Calls 13

metric_locationFunction · 0.85
atFunction · 0.85
is_noneMethod · 0.80
as_refMethod · 0.80
subject_labelFunction · 0.70
collectMethod · 0.45
iterMethod · 0.45
as_strMethod · 0.45
insertMethod · 0.45
cloneMethod · 0.45
pushMethod · 0.45
is_emptyMethod · 0.45