Python: Autoformat all .ql files.

This commit is contained in:
Taus Brock-Nannestad
2020-03-30 11:59:10 +02:00
parent b4fbfa029e
commit 87a9f51c78
491 changed files with 2649 additions and 2747 deletions

View File

@@ -6,7 +6,7 @@
* builtin
* object
*/
import python
from Expr e, string name

View File

@@ -5,7 +5,7 @@
* @tags call
* function
*/
import python
from Value len, CallNode call

View File

@@ -6,11 +6,11 @@
* try
* exception
*/
import python
from ExceptStmt ex, ClassValue cls
where
where
cls.getName() = "MyExceptionClass" and
ex.getType().pointsTo(cls)
select ex

View File

@@ -11,7 +11,8 @@
import python
from IfExp e, ClassObject cls1, ClassObject cls2
where
e.getBody().refersTo(_, cls1, _) and e.getOrelse().refersTo(_, cls2, _) and
where
e.getBody().refersTo(_, cls1, _) and
e.getOrelse().refersTo(_, cls2, _) and
cls1 != cls2
select e
select e

View File

@@ -6,7 +6,7 @@
* block
* statement
*/
import python
from StmtList blk

View File

@@ -1,7 +1,7 @@
/**
* @id py/examples/emptythen
* @name If statements with empty then branch
* @description Finds 'if' statements where the "then" branch
* @description Finds 'if' statements where the "then" branch
* consists entirely of Pass statements
* @tags if
* then
@@ -9,13 +9,13 @@
* conditional
* branch
*/
import python
from If i
where
not exists(Stmt s |
i.getStmt(_) = s and
i.getStmt(_) = s and
not s instanceof Pass
)
select i

View File

@@ -6,7 +6,7 @@
* test
* boolean
*/
import python
from Compare eq

View File

@@ -6,7 +6,7 @@
* equality
* expression statement
*/
import python
from ExprStmt e, Compare eq

View File

@@ -9,11 +9,11 @@
* subtype
* supertype
*/
import python
from ClassObject sub, ClassObject base
where
where
base.getName() = "MyClass" and
sub.getABaseType() = base
select sub

View File

@@ -4,7 +4,7 @@
* @description Finds files called `spam.py`
* @tags file
*/
import python
from File f

View File

@@ -10,4 +10,4 @@ import python
from Function f
where f.isGenerator()
select f
select f

View File

@@ -5,7 +5,7 @@
* @tags integer
* literal
*/
import python
from IntegerLiteral literal

View File

@@ -5,11 +5,11 @@
* @tags call
* method
*/
import python
from AstNode call, PythonFunctionValue method
where
where
method.getQualifiedName() = "MyClass.methodName" and
method.getACall().getNode() = call
select call

View File

@@ -6,7 +6,7 @@
* constructor
* new
*/
import python
from Call new, ClassValue cls

View File

@@ -5,7 +5,7 @@
* @tags method
* override
*/
import python
from FunctionObject override, FunctionObject base

View File

@@ -4,11 +4,11 @@
* @description Find print statements or calls to the builtin function 'print'
* @tags print
*/
import python
from AstNode print
where
where
/* Python 2 without `from __future__ import print_function` */
print instanceof Print
or

View File

@@ -1,19 +1,20 @@
/**
* @id py/examples/private-access
* @name Private access
* @description Find accesses to "private" attributes (those starting with an underscore)
* @description Find accesses to "private" attributes (those starting with an underscore)
* @tags access
* private
*/
import python
predicate is_private(Attribute a) {
a.getName().matches("\\_%") and
a.getName().matches("\\_%") and
not a.getName().matches("\\_\\_%\\_\\_")
}
from Attribute access
where is_private(access) and
not access.getObject().(Name).getId() = "self"
where
is_private(access) and
not access.getObject().(Name).getId() = "self"
select access

View File

@@ -6,13 +6,11 @@
* raise
* exception
*/
import python
from Raise raise, ClassValue ex
where
ex.getName() = "AnException" and
(
raise.getException().pointsTo(ex.getASuperType())
)
raise.getException().pointsTo(ex.getASuperType())
select raise, "Don't raise instances of 'AnException'"

View File

@@ -1,11 +1,11 @@
/**
* @id py/examples/raw-string
* @name Raw string literals
* @description Finds string literals with an 'r' prefix
* @description Finds string literals with an 'r' prefix
* @tags string
* raw
*/
import python
from StrConst s

View File

@@ -8,11 +8,11 @@
* collection
* add
*/
import python
from SubscriptNode store
where
where
store.isStore() and
store.getIndex().pointsTo(Value::named("None"))
select store

View File

@@ -10,6 +10,7 @@
import python
from Try t
where exists(t.getFinalbody())
and not exists(t.getAHandler())
where
exists(t.getFinalbody()) and
not exists(t.getAHandler())
select t