mirror of
https://github.com/github/codeql.git
synced 2025-12-18 01:33:15 +01:00
Rename files by style guide and change query metadata
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
# invalid class with return outside of a function
|
||||
# invalid class with return outside a function
|
||||
class InvalidClass1(object):
|
||||
if [1, 2, 3]:
|
||||
return "Exists"
|
||||
|
||||
# invalid statement with yield outside of a function
|
||||
# invalid statement with yield outside a function
|
||||
for i in [1, 2, 3]:
|
||||
yield i
|
||||
@@ -18,7 +18,7 @@ Consequently, it is not possible to suggest a general fix.</p>
|
||||
<p>In this example, a <code>return</code> statement is used outside a class method in a class and
|
||||
a <code>yield</code> statement is used outside a function in a scope of a module which would result
|
||||
in a <code>SyntaxError</code> when running this code.</p>
|
||||
<sample src="ReturnOrYieldOutsideOfFunction.py" />
|
||||
<sample src="ReturnOrYieldOutsideFunction.py" />
|
||||
</example>
|
||||
|
||||
<references>
|
||||
@@ -1,13 +1,13 @@
|
||||
/**
|
||||
* @name Using 'return' or 'yield' outside a function causes a 'SyntaxError' at runtime
|
||||
* @description Statements 'return' and 'yield' should be used only within a function.
|
||||
* @name Use of 'return' or 'yield' outside a function
|
||||
* @description Using 'return' or 'yield' outside a function causes a 'SyntaxError' at runtime.
|
||||
* @kind problem
|
||||
* @tags reliability
|
||||
* correctness
|
||||
* @problem.severity error
|
||||
* @sub-severity low
|
||||
* @precision very-high
|
||||
* @id py/return-or-yield-outside-of-function
|
||||
* @precision medium
|
||||
* @id py/return-or-yield-outside-function
|
||||
*/
|
||||
|
||||
import python
|
||||
@@ -22,4 +22,4 @@ where
|
||||
or
|
||||
node instanceof YieldFrom and kind = "yield from"
|
||||
)
|
||||
select node, "'" + kind + "' is used outside of a function."
|
||||
select node, "'" + kind + "' is used outside a function."
|
||||
Reference in New Issue
Block a user