Skip to content

[Query Create]: #1

@apsscolari

Description

@apsscolari

Target Language

python

Query Name (Optional)

Bare Except

Query Type

Code Quality

Query Description

Bare except: (overly broad exception handling)

Why it’s a quality problem
Catching everything (including KeyboardInterrupt, SystemExit, etc.) can:

hide real bugs,
make failures harder to debug,
lead to incorrect behavior by swallowing critical exceptions.

Expected Severity

Medium

Code Examples

//should be detected
def parse_int(s: str) -> int:
try:
return int(s)
except: # <- too broad
return 0

//should NOT be detected
def parse_int(s: str) -> int:
try:
return int(s)
except ValueError:
return 0

CWE/CVE Reference (Optional)

No response

References (Optional)

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions