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

Function forwarding_wrapper

atomic-audit/src/substantive/rust.rs:152–317  ·  view source on GitHub ↗
(
    node: Node<'_>,
    functions: &BTreeMap<(usize, String), Vec<Node<'_>>>,
    context: &mut Context<'_>,
    issues: &mut Vec<StructuralIssue>,
)

Source from the content-addressed store, hash-verified

150}
151
152fn forwarding_wrapper(
153 node: Node<'_>,
154 functions: &BTreeMap<(usize, String), Vec<Node<'_>>>,
155 context: &mut Context<'_>,
156 issues: &mut Vec<StructuralIssue>,
157) -> Result<(), &'static str> {
158 let Some(parent) = node
159 .parent()
160 .filter(|parent| matches!(parent.kind(), "source_file" | "declaration_list"))
161 else {
162 return Ok(());
163 };
164 if parent.kind() == "declaration_list"
165 && !parent
166 .parent()
167 .is_some_and(|owner| owner.kind() == "mod_item")
168 {
169 return Ok(());
170 }
171 if !attributes(node).is_empty()
172 || node.prev_named_sibling().is_some_and(tokens::comment)
173 || tokens::named(node).iter().any(|child| {
174 matches!(
175 child.kind(),
176 "visibility_modifier" | "function_modifiers" | "type_parameters" | "where_clause"
177 )
178 })
179 {
180 return Ok(());
181 }
182 let (Some(name), Some(parameters), Some(body)) = (
183 node.child_by_field_name("name"),
184 node.child_by_field_name("parameters"),
185 node.child_by_field_name("body"),
186 ) else {
187 return Ok(());
188 };
189 if code_children(body).len() != 1 {
190 return Ok(());
191 }
192 let call = tail(body);
193 if call.kind() != "call_expression" {
194 return Ok(());
195 }
196 let (Some(target), Some(arguments)) = (
197 call.child_by_field_name("function"),
198 call.child_by_field_name("arguments"),
199 ) else {
200 return Ok(());
201 };
202 if target.kind() != "identifier"
203 || tokens::text(target, context.source) == tokens::text(name, context.source)
204 {
205 return Ok(());
206 }
207 let params = code_children(parameters);
208 let args = code_children(arguments);
209 if params.len() != args.len() {

Callers 1

inspectFunction · 0.85

Calls 15

attributesFunction · 0.85
code_childrenFunction · 0.85
tailFunction · 0.85
parentMethod · 0.80
issueMethod · 0.80
getMethod · 0.65
namedFunction · 0.50
textFunction · 0.50
kindMethod · 0.45
is_emptyMethod · 0.45
iterMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected