Make collect_call_path return an Option (#3849)

This commit is contained in:
Charlie Marsh 2023-04-01 22:29:32 -04:00 committed by GitHub
parent d822e08111
commit 08e5b3fa61
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
21 changed files with 158 additions and 138 deletions

View file

@ -43,9 +43,11 @@ impl LoggingLevel {
/// ```
pub fn is_logger_candidate(context: &Context, func: &Expr) -> bool {
if let ExprKind::Attribute { value, .. } = &func.node {
let call_path = context
let Some(call_path) = context
.resolve_call_path(value)
.unwrap_or_else(|| collect_call_path(value));
.or_else(|| collect_call_path(value)) else {
return false;
};
if let Some(tail) = call_path.last() {
if tail.starts_with("log") || tail.ends_with("logger") || tail.ends_with("logging") {
return true;