Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
29 lines (27 loc) · 925 Bytes

File metadata and controls

29 lines (27 loc) · 925 Bytes
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/**
* @name 'break' or 'return' statement in finally
* @description Using a Break or Return statement in a finally block causes the
* Try-finally block to exit, discarding the exception.
* @kind problem
* @tags quality
* reliability
* error-handling
* correctness
* external/cwe/cwe-584
* @problem.severity warning
* @sub-severity low
* @precision medium
* @id py/exit-from-finally
*/
import python
from Stmt s, string kind
where
s instanceof Return and kind = "return" and exists(Try t | t.getFinalbody().contains(s))
or
s instanceof Break and
kind = "break" and
exists(Try t | t.getFinalbody().contains(s) |
not exists(For loop | loop.contains(s) and t.getFinalbody().contains(loop)) and
not exists(While loop | loop.contains(s) and t.getFinalbody().contains(loop))
)
select s, "'" + kind + "' in a finally block will swallow any exceptions raised."
Morty Proxy This is a proxified and sanitized view of the page, visit original site.