Skip to content

Commit 96380f6

Browse files
author
alexey
committed
Edit query metadata and help and add new entry to the change-notes 1.21
1 parent 8168c0e commit 96380f6

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

change-notes/1.21/analysis-python.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
| **Query** | **Tags** | **Purpose** |
1111
|-----------|----------|-------------|
1212
| Accepting unknown SSH host keys when using Paramiko (`py/paramiko-missing-host-key-validation`) | security, external/cwe/cwe-295 | Finds instances where Paramiko is configured to accept unknown host keys. Results are shown on LGTM by default. |
13-
13+
| Using `return`, `yield`, or `yield from` outside a function or a class method | reliability, correctness | Finds instances where `return`, `yield`, and `yield from` are used outside a function. Results are not shown on LGTM by default. |
1414

1515
## Changes to existing queries
1616

python/ql/src/Statements/ReturnOrYieldOutsideOfFunction.qhelp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,20 @@
44
<qhelp>
55

66
<overview>
7-
<p>In Python, <code>return</code> and <code>yield</code> statements as well as <code>yield from</code>
8-
expression can only be used within a function. Having them placed outside of a function or a class
9-
method will raise a <code>SyntaxError</code> at runtime.</p>
7+
<p>In Python, <code>return</code> and <code>yield</code> statements and the <code>yield from</code>
8+
expression can only be used within a function. Using them outside a function or a class
9+
method results in a <code>SyntaxError</code> at runtime.</p>
1010
</overview>
1111

1212
<recommendation>
13-
<p>The presence of <code>return</code> and <code>yield</code> statements or <code>yield from</code>
14-
expression outside of a function or a class method suggests a logical error, so it is not possible
15-
to suggest a general fix.</p>
13+
<p>Using these elements outside a function or a class method usually indicates an error in the logic.
14+
Consequently, it is not possible to suggest a general fix.</p>
1615
</recommendation>
1716

1817
<example>
19-
<p>In this example, a <code>return</code> statement is used outside of a class method in a class and
20-
a <code>yield</code> statement is used outside of a function in a scope of a module.</p>
18+
<p>In this example, a <code>return</code> statement is used outside a class method in a class and
19+
a <code>yield</code> statement is used outside a function in a scope of a module which would result
20+
in a <code>SyntaxError</code> when running this code.</p>
2121
<sample src="ReturnOrYieldOutsideOfFunction.py" />
2222
</example>
2323

python/ql/src/Statements/ReturnOrYieldOutsideOfFunction.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
2-
* @name return or yield are used outside of a function
3-
* @description return and yield statements should be used only within a function.
2+
* @name Using 'return' or 'yield' outside a function causes a 'SyntaxError' at runtime
3+
* @description Statements 'return' and 'yield' should be used only within a function.
44
* @kind problem
55
* @tags reliability
66
* correctness

0 commit comments

Comments
 (0)