Skip to content

Commit 86ec047

Browse files
author
alexey
committed
Rename files by style guide and change query metadata
1 parent 96380f6 commit 86ec047

File tree

8 files changed

+28
-19
lines changed

8 files changed

+28
-19
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-
| 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. |
13+
| Use of 'return' or 'yield' outside a function (`py/return-or-yield-outside-function`) | 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.py renamed to python/ql/src/Statements/ReturnOrYieldOutsideFunction.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# invalid class with return outside of a function
1+
# invalid class with return outside a function
22
class InvalidClass1(object):
33
if [1, 2, 3]:
44
return "Exists"
55

6-
# invalid statement with yield outside of a function
6+
# invalid statement with yield outside a function
77
for i in [1, 2, 3]:
88
yield i

python/ql/src/Statements/ReturnOrYieldOutsideOfFunction.qhelp renamed to python/ql/src/Statements/ReturnOrYieldOutsideFunction.qhelp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Consequently, it is not possible to suggest a general fix.</p>
1818
<p>In this example, a <code>return</code> statement is used outside a class method in a class and
1919
a <code>yield</code> statement is used outside a function in a scope of a module which would result
2020
in a <code>SyntaxError</code> when running this code.</p>
21-
<sample src="ReturnOrYieldOutsideOfFunction.py" />
21+
<sample src="ReturnOrYieldOutsideFunction.py" />
2222
</example>
2323

2424
<references>

python/ql/src/Statements/ReturnOrYieldOutsideOfFunction.ql renamed to python/ql/src/Statements/ReturnOrYieldOutsideFunction.ql

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
/**
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.
2+
* @name Use of 'return' or 'yield' outside a function
3+
* @description Using 'return' or 'yield' outside a function causes a 'SyntaxError' at runtime.
44
* @kind problem
55
* @tags reliability
66
* correctness
77
* @problem.severity error
88
* @sub-severity low
9-
* @precision very-high
10-
* @id py/return-or-yield-outside-of-function
9+
* @precision medium
10+
* @id py/return-or-yield-outside-function
1111
*/
1212

1313
import python
@@ -22,4 +22,4 @@ where
2222
or
2323
node instanceof YieldFrom and kind = "yield from"
2424
)
25-
select node, "'" + kind + "' is used outside of a function."
25+
select node, "'" + kind + "' is used outside a function."
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
| ReturnOrYieldOutsideFunction_test.py:31:9:31:23 | Return | 'return' is used outside a function. |
2+
| ReturnOrYieldOutsideFunction_test.py:36:9:36:15 | Yield | 'yield' is used outside a function. |
3+
| ReturnOrYieldOutsideFunction_test.py:41:9:41:25 | YieldFrom | 'yield from' is used outside a function. |
4+
| ReturnOrYieldOutsideFunction_test.py:45:5:45:12 | Return | 'return' is used outside a function. |
5+
| ReturnOrYieldOutsideFunction_test.py:49:5:49:11 | Yield | 'yield' is used outside a function. |
6+
| ReturnOrYieldOutsideFunction_test.py:53:5:53:16 | YieldFrom | 'yield from' is used outside a function. |
7+
| ReturnOrYieldOutsideFunction_test.py:57:1:57:14 | YieldFrom | 'yield from' is used outside a function. |
8+
| ReturnOrYieldOutsideFunction_test.py:60:1:60:12 | Return | 'return' is used outside a function. |
9+
| ReturnOrYieldOutsideFunction_test.py:63:1:63:11 | Yield | 'yield' is used outside a function. |
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Statements/ReturnOrYieldOutsideFunction.ql

python/ql/test/query-tests/Statements/ReturnOrYieldOutsideOfFunction/ReturnOrYieldOutsideOfFunction_test.py renamed to python/ql/test/query-tests/Statements/ReturnOrYieldOutsideFunction/ReturnOrYieldOutsideFunction_test.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,39 +25,39 @@ def valid_func2():
2525
def valid_func3():
2626
yield from [1, 2]
2727

28-
# invalid class with return outside of a function
28+
# invalid class with return outside a function
2929
class InvalidClass1(object):
3030
if [1, 2, 3]:
3131
return "Exists"
3232

33-
# invalid class with yield outside of a function
33+
# invalid class with yield outside a function
3434
class InvalidClass2(object):
3535
while True:
3636
yield 1
3737

38-
# invalid class with yield from outside of a function
38+
# invalid class with yield from outside a function
3939
class InvalidClass3(object):
4040
while True:
4141
yield from [1, 2]
4242

43-
# invalid statement with return outside of a function
43+
# invalid statement with return outside a function
4444
for i in [1, 2, 3]:
4545
return i
4646

47-
# invalid statement with yield outside of a function
47+
# invalid statement with yield outside a function
4848
for i in [1, 2, 3]:
4949
yield i
5050

51-
# invalid statement with yield from outside of a function
51+
# invalid statement with yield from outside a function
5252
for i in [1, 2, 3]:
5353
yield from i
5454

55-
# invalid statement with yield from outside of a function
55+
# invalid statement with yield from outside a function
5656
var = [1,2,3]
5757
yield from var
5858

59-
# invalid statement with return outside of a function
59+
# invalid statement with return outside a function
6060
return False
6161

62-
# invalid statement with yield outside of a function
62+
# invalid statement with yield outside a function
6363
yield False

python/ql/test/query-tests/Statements/ReturnOrYieldOutsideOfFunction/ReturnOrYieldOutsideOfFunction.qlref

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)