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

Function sources

libatomic/src/review/html.rs:165–358  ·  view source on GitHub ↗
(
    repo: &Repository,
    report: &IncrementalReport,
    regions: &[presentation::Region],
)

Source from the content-addressed store, hash-verified

163}
164
165fn sources(
166 repo: &Repository,
167 report: &IncrementalReport,
168 regions: &[presentation::Region],
169) -> Vec<Snapshot> {
170 let graph = report.graph.as_ref().expect("resolved review graph");
171 let mut requests = collect_requests(graph, regions)
172 .into_iter()
173 .collect::<Vec<_>>();
174 let reviewed: BTreeSet<_> = report
175 .changes
176 .iter()
177 .filter(|change| change.selected_root)
178 .flat_map(|change| {
179 change
180 .paths
181 .iter()
182 .map(|path| (change.hash.clone(), path.clone()))
183 })
184 .chain(report.view_snapshot.iter().flat_map(|snapshot| {
185 snapshot
186 .paths
187 .iter()
188 .map(|path| (snapshot.source_ref.clone(), path.clone()))
189 }))
190 .chain(report.view_comparison.iter().flat_map(|comparison| {
191 comparison.files.iter().flat_map(|file| {
192 std::iter::once(file.path.as_str())
193 .chain(file.before_path.as_deref())
194 .chain(file.after_path.as_deref())
195 .map(|path| (file.source_ref.clone(), path.to_owned()))
196 })
197 }))
198 .chain(report.view_comparison.iter().flat_map(|comparison| {
199 comparison
200 .files
201 .iter()
202 .flat_map(|file| file.before_path.iter().chain(&file.after_path))
203 .map(|path| (comparison.source_ref.clone(), path.clone()))
204 }))
205 .collect();
206 requests.sort_by(|(left, a), (right, b)| {
207 b.findings
208 .cmp(&a.findings)
209 .then(reviewed.contains(right).cmp(&reviewed.contains(left)))
210 .then(b.known.len().cmp(&a.known.len()))
211 .then(left.cmp(right))
212 });
213 let config = atomic_audit::extract::ExtractionConfig::default();
214 let mut bytes = config.max_total_bytes;
215 let mut files = 0;
216 let mut result = Vec::new();
217 for ((change, path), request) in requests {
218 let reviewed_root = reviewed.contains(&(change.clone(), path.clone()));
219 let comparison_file = report
220 .view_comparison
221 .as_ref()
222 .and_then(|comparison| comparison.file(&change));

Callers 1

render_with_decisionFunction · 0.70

Calls 15

collect_requestsFunction · 0.85
source_textFunction · 0.85
read_sourceFunction · 0.85
loadFunction · 0.85
as_refMethod · 0.80
is_noneMethod · 0.80
is_vault_pathFunction · 0.50
unavailableFunction · 0.50
into_iterMethod · 0.45
collectMethod · 0.45
iterMethod · 0.45

Tested by

no test coverage detected