Expand heuristic for detecting logging calls (#2279)
This commit is contained in:
10
resources/test/fixtures/tryceratops/TRY400.py
vendored
10
resources/test/fixtures/tryceratops/TRY400.py
vendored
@@ -28,6 +28,16 @@ def bad():
|
||||
logger.error("Context message here")
|
||||
|
||||
|
||||
def bad():
|
||||
try:
|
||||
a = 1
|
||||
except Exception:
|
||||
log.error("Context message here")
|
||||
|
||||
if True:
|
||||
log.error("Context message here")
|
||||
|
||||
|
||||
def bad():
|
||||
try:
|
||||
a = 1
|
||||
|
||||
@@ -1010,7 +1010,7 @@ pub fn is_logger_candidate(func: &Expr) -> bool {
|
||||
if let ExprKind::Attribute { value, .. } = &func.node {
|
||||
let call_path = collect_call_path(value);
|
||||
if let Some(tail) = call_path.last() {
|
||||
if *tail == "logging" || tail.ends_with("logger") {
|
||||
if tail.starts_with("log") || tail.ends_with("logger") || tail.ends_with("logging") {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ expression: diagnostics
|
||||
column: 8
|
||||
end_location:
|
||||
row: 35
|
||||
column: 49
|
||||
column: 41
|
||||
fix: ~
|
||||
parent: ~
|
||||
- kind:
|
||||
@@ -59,6 +59,26 @@ expression: diagnostics
|
||||
column: 12
|
||||
end_location:
|
||||
row: 38
|
||||
column: 45
|
||||
fix: ~
|
||||
parent: ~
|
||||
- kind:
|
||||
ErrorInsteadOfException: ~
|
||||
location:
|
||||
row: 45
|
||||
column: 8
|
||||
end_location:
|
||||
row: 45
|
||||
column: 49
|
||||
fix: ~
|
||||
parent: ~
|
||||
- kind:
|
||||
ErrorInsteadOfException: ~
|
||||
location:
|
||||
row: 48
|
||||
column: 12
|
||||
end_location:
|
||||
row: 48
|
||||
column: 53
|
||||
fix: ~
|
||||
parent: ~
|
||||
|
||||
Reference in New Issue
Block a user