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

Function analyze_semantic

atomic-audit/src/impact/analysis.rs:79–305  ·  view source on GitHub ↗

Apply compatibility policy to already-parsed shared semantic source sets.

(before: SourceSet, after: SourceSet, paths: &[String])

Source from the content-addressed store, hash-verified

77
78/// Apply compatibility policy to already-parsed shared semantic source sets.
79pub fn analyze_semantic(before: SourceSet, after: SourceSet, paths: &[String]) -> ImpactReport {
80 let complete = before.complete && after.complete;
81 let mut report = ImpactReport {
82 source_selection_complete: Some(complete),
83 inspected_files_before: before.files.len(),
84 inspected_files_after: after.files.len(),
85 searched_files_before: before.searched_files,
86 searched_files_after: after.searched_files,
87 ..Default::default()
88 };
89 report
90 .gaps
91 .extend(before.gaps.iter().map(|gap| format!("before: {gap}")));
92 report
93 .gaps
94 .extend(after.gaps.iter().map(|gap| format!("after: {gap}")));
95 let inventory_complete = before.paths_complete && after.paths_complete;
96 let old = SourceGraph::new(before.files, before.paths, inventory_complete);
97 let new = SourceGraph::new(after.files, after.paths, inventory_complete);
98 let paths: BTreeSet<_> = paths
99 .iter()
100 .filter(|path| atomic_semantic::is_supported(path))
101 .map(String::as_str)
102 .collect();
103 let mut roots = BTreeSet::new();
104 for id in old
105 .symbols
106 .keys()
107 .chain(new.symbols.keys())
108 .collect::<BTreeSet<_>>()
109 {
110 let before = old.symbols.get(id);
111 let after = new.symbols.get(id);
112 let symbol = after.or(before).unwrap();
113 if !matches!(
114 symbol.entity.kind,
115 atomic_semantic::EntityKind::Function | atomic_semantic::EntityKind::Method
116 ) {
117 continue;
118 }
119 if after.is_none()
120 && new.paths.contains(&symbol.location.path)
121 && !new.files.contains_key(&symbol.location.path)
122 {
123 if paths.contains(symbol.location.path.as_str()) {
124 report.gaps.push(format!(
125 "{id}: after-source unavailable; deletion is not inferred"
126 ));
127 }
128 continue;
129 }
130 if old.ambiguous.contains(id) || new.ambiguous.contains(id) {
131 if paths.contains(symbol.location.path.as_str()) {
132 report.gaps.push(format!("{id}: ambiguous conditional/overloaded declaration; no root delta or caller verdict inferred"));
133 }
134 continue;
135 }
136 if !paths.contains(symbol.location.path.as_str())

Callers 3

analyzeFunction · 0.85
analyze_with_coverageFunction · 0.85
inspect_viewsFunction · 0.85

Calls 15

is_supportedFunction · 0.85
compatibleFunction · 0.85
extendMethod · 0.80
keysMethod · 0.80
is_noneMethod · 0.80
contains_keyMethod · 0.80
bind_callsMethod · 0.80
lastMethod · 0.80
sortMethod · 0.80
directFunction · 0.70
getMethod · 0.65
lenMethod · 0.45

Tested by

no test coverage detected