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

Function inspect

atomic-audit/src/substantive/mod.rs:87–159  ·  view source on GitHub ↗
(
    language: Language,
    path: &str,
    source: &str,
    nodes: &[Node<'_>],
    issues: &mut Vec<StructuralIssue>,
)

Source from the content-addressed store, hash-verified

85}
86
87pub(crate) fn inspect(
88 language: Language,
89 path: &str,
90 source: &str,
91 nodes: &[Node<'_>],
92 issues: &mut Vec<StructuralIssue>,
93) -> Result<Vec<String>, &'static str> {
94 let promise_shadowed = nodes.iter().any(|node| {
95 node.child_by_field_name("name")
96 .or_else(|| node.child_by_field_name("pattern"))
97 .is_some_and(|name| tokens::text(name, source) == "Promise")
98 || (node.kind() == "identifier"
99 && tokens::text(*node, source) == "Promise"
100 && node.parent().is_some_and(|parent| {
101 matches!(
102 parent.kind(),
103 "required_parameter"
104 | "optional_parameter"
105 | "import_specifier"
106 | "import_clause"
107 )
108 }))
109 });
110 let mut functions = BTreeMap::<(usize, String), Vec<Node<'_>>>::new();
111 for &node in nodes.iter().filter(|node| node.kind() == "function_item") {
112 if let (Some(parent), Some(name)) = (node.parent(), node.child_by_field_name("name")) {
113 functions
114 .entry((parent.id(), tokens::text(name, source).into()))
115 .or_default()
116 .push(node);
117 }
118 }
119 let mut subjects = BTreeMap::<String, usize>::new();
120 for &node in nodes
121 .iter()
122 .filter(|node| languages::callable(**node, language))
123 {
124 let (subject, stable) = languages::qualified(node, source, language);
125 if stable {
126 *subjects.entry(subject).or_default() += 1;
127 }
128 }
129 let mut context = Context {
130 source,
131 path,
132 language,
133 remaining: 32 * 1024 * 1024,
134 promise_shadowed,
135 subjects,
136 };
137 for &node in nodes {
138 if matches!(
139 language,
140 Language::Rust | Language::TypeScript | Language::Tsx
141 ) {
142 branching::inspect(node, &mut context, issues)?;
143 }
144 if language == Language::Rust {

Calls 12

manageabilityFunction · 0.85
parentMethod · 0.80
textFunction · 0.50
callableFunction · 0.50
qualifiedFunction · 0.50
iterMethod · 0.45
kindMethod · 0.45
pushMethod · 0.45
idMethod · 0.45
lenMethod · 0.45
collectMethod · 0.45
into_iterMethod · 0.45