Skip to content

Commit 7b877fb

Browse files
authored
Merge pull request #8336 from tausbn/python-fix-a-bunch-of-ql-warnings
Python: Fix a bunch of QL warnings
2 parents 17cec52 + 063a8bb commit 7b877fb

File tree

102 files changed

+399
-357
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+399
-357
lines changed

cpp/ql/test/TestUtilities/InlineExpectationsTest.qll

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,9 @@ abstract class InlineExpectationsTest extends string {
124124
abstract predicate hasActualResult(Location location, string element, string tag, string value);
125125

126126
/**
127-
* Like `hasActualResult`, but returns results that do not require a matching annotation.
127+
* Holds if there is an optional result on the specified location.
128+
*
129+
* This is similar to `hasActualResult`, but returns results that do not require a matching annotation.
128130
* A failure will still arise if there is an annotation that does not match any results, but not vice versa.
129131
* Override this predicate to specify optional results.
130132
*/

csharp/ql/test/TestUtilities/InlineExpectationsTest.qll

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,9 @@ abstract class InlineExpectationsTest extends string {
124124
abstract predicate hasActualResult(Location location, string element, string tag, string value);
125125

126126
/**
127-
* Like `hasActualResult`, but returns results that do not require a matching annotation.
127+
* Holds if there is an optional result on the specified location.
128+
*
129+
* This is similar to `hasActualResult`, but returns results that do not require a matching annotation.
128130
* A failure will still arise if there is an annotation that does not match any results, but not vice versa.
129131
* Override this predicate to specify optional results.
130132
*/

java/ql/test/TestUtilities/InlineExpectationsTest.qll

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,9 @@ abstract class InlineExpectationsTest extends string {
124124
abstract predicate hasActualResult(Location location, string element, string tag, string value);
125125

126126
/**
127-
* Like `hasActualResult`, but returns results that do not require a matching annotation.
127+
* Holds if there is an optional result on the specified location.
128+
*
129+
* This is similar to `hasActualResult`, but returns results that do not require a matching annotation.
128130
* A failure will still arise if there is an annotation that does not match any results, but not vice versa.
129131
* Override this predicate to specify optional results.
130132
*/

python/ql/lib/semmle/python/AstExtended.qll

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import python
22

3-
/** Syntactic node (Class, Function, Module, Expr, Stmt or Comprehension) corresponding to a flow node */
3+
/** A syntactic node (Class, Function, Module, Expr, Stmt or Comprehension) corresponding to a flow node */
44
abstract class AstNode extends AstNode_ {
55
/*
66
* Special comment for documentation generation.
@@ -61,31 +61,31 @@ abstract class AstNode extends AstNode_ {
6161
}
6262

6363
/* Parents */
64-
/** Internal implementation class */
64+
/** The parent of a `Function`. Internal implementation class */
6565
class FunctionParent extends FunctionParent_ { }
6666

67-
/** Internal implementation class */
67+
/** The parent of an `Arguments` node. Internal implementation class */
6868
class ArgumentsParent extends ArgumentsParent_ { }
6969

70-
/** Internal implementation class */
70+
/** The parent of an `ExprList`. Internal implementation class */
7171
class ExprListParent extends ExprListParent_ { }
7272

73-
/** Internal implementation class */
73+
/** The parent of an `ExprContext`. Internal implementation class */
7474
class ExprContextParent extends ExprContextParent_ { }
7575

76-
/** Internal implementation class */
76+
/** The parent of a `StmtList`. Internal implementation class */
7777
class StmtListParent extends StmtListParent_ { }
7878

79-
/** Internal implementation class */
79+
/** The parent of a `StrList`. Internal implementation class */
8080
class StrListParent extends StrListParent_ { }
8181

82-
/** Internal implementation class */
82+
/** The parent of an `Expr`. Internal implementation class */
8383
class ExprParent extends ExprParent_ { }
8484

85-
/** Internal implementation class */
85+
/** The parent of a `PatternList`. Internal implementation class */
8686
class PatternListParent extends PatternListParent_ { }
8787

88-
/** Internal implementation class */
88+
/** The parent of a `Pattern`. Internal implementation class */
8989
class PatternParent extends PatternParent_ { }
9090

9191
class DictItem extends DictItem_, AstNode {
@@ -120,7 +120,7 @@ class Comprehension extends Comprehension_, AstNode {
120120
class BytesOrStr extends BytesOrStr_ { }
121121

122122
/**
123-
* Part of a string literal formed by implicit concatenation.
123+
* A part of a string literal formed by implicit concatenation.
124124
* For example the string literal "abc" expressed in the source as `"a" "b" "c"`
125125
* would be composed of three `StringPart`s.
126126
*/

python/ql/lib/semmle/python/Comment.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class CommentBlock extends @py_comment {
5959
/** Gets a textual representation of this element. */
6060
string toString() { result = "Comment block" }
6161

62-
/** The length of this comment block (in comments) */
62+
/** Gets the length of this comment block (in comments) */
6363
int length() { result = max(int i | comment_block_part(this, _, i)) }
6464

6565
/**

python/ql/lib/semmle/python/Comparisons.qll

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,22 +76,22 @@ class CompareOp extends int {
7676
}
7777
}
7878

79-
/** The `CompareOp` for "equals". */
79+
/** Gets the `CompareOp` for "equals". */
8080
CompareOp eq() { result = 1 }
8181

82-
/** The `CompareOp` for "not equals". */
82+
/** Gets the `CompareOp` for "not equals". */
8383
CompareOp ne() { result = 2 }
8484

85-
/** The `CompareOp` for "less than". */
85+
/** Gets the `CompareOp` for "less than". */
8686
CompareOp lt() { result = 3 }
8787

88-
/** The `CompareOp` for "less than or equal to". */
88+
/** Gets the `CompareOp` for "less than or equal to". */
8989
CompareOp le() { result = 4 }
9090

91-
/** The `CompareOp` for "greater than". */
91+
/** Gets the `CompareOp` for "greater than". */
9292
CompareOp gt() { result = 5 }
9393

94-
/** The `CompareOp` for "greater than or equal to". */
94+
/** Gets the `CompareOp` for "greater than or equal to". */
9595
CompareOp ge() { result = 6 }
9696

9797
/* Workaround precision limits in floating point numbers */

python/ql/lib/semmle/python/Comprehensions.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import python
22

3-
/** Base class for list, set and dictionary comprehensions, and generator expressions. */
3+
/** The base class for list, set and dictionary comprehensions, and generator expressions. */
44
abstract class Comp extends Expr {
55
abstract Function getFunction();
66

python/ql/lib/semmle/python/Exprs.qll

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ class Ellipsis extends Ellipsis_ {
315315
}
316316

317317
/**
318-
* Immutable literal expressions (except tuples).
318+
* An immutable literal expression (except tuples).
319319
* Consists of string (both unicode and byte) literals and numeric literals.
320320
*/
321321
abstract class ImmutableLiteral extends Expr {
@@ -446,6 +446,8 @@ class Unicode extends StrConst {
446446
}
447447

448448
/**
449+
* Gets the quoted representation fo this string.
450+
*
449451
* The extractor puts quotes into the name of each string (to prevent "0" clashing with 0).
450452
* The following predicate help us match up a string/byte literals in the source
451453
* which the equivalent object.
@@ -685,7 +687,7 @@ class False extends BooleanLiteral {
685687
override boolean booleanValue() { result = false }
686688
}
687689

688-
/** `None` */
690+
/** The `None` constant. */
689691
class None extends NameConstant {
690692
/* syntax: None */
691693
None() { name_consts(this, "None") }
@@ -728,20 +730,20 @@ class Guard extends Guard_ {
728730
/** A context in which an expression used */
729731
class ExprContext extends ExprContext_ { }
730732

731-
/** Load context, the context of var in len(var) */
733+
/** The load context, the context of var in len(var) */
732734
class Load extends Load_ { }
733735

734-
/** Store context, the context of var in var = 0 */
736+
/** The store context, the context of var in var = 0 */
735737
class Store extends Store_ { }
736738

737-
/** Delete context, the context of var in del var */
739+
/** The delete context, the context of var in del var */
738740
class Del extends Del_ { }
739741

740-
/** This is an artifact of the Python grammar which includes an AugLoad context, even though it is never used. */
741-
library class AugLoad extends AugLoad_ { }
742+
/** The context of an augmented load. This is an artifact of the Python grammar which includes an AugLoad context, even though it is never used. */
743+
class AugLoad extends AugLoad_ { }
742744

743-
/** Augmented store context, the context of var in var += 1 */
745+
/** The augmented store context, the context of var in var += 1 */
744746
class AugStore extends AugStore_ { }
745747

746-
/** Parameter context, the context of var in def f(var): pass */
748+
/** The parameter context, the context of var in def f(var): pass */
747749
class Param extends Param_ { }

python/ql/lib/semmle/python/Flow.qll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ class ControlFlowNode extends @py_flow_node {
155155
/** Whether this flow node is the first in its scope */
156156
predicate isEntryNode() { py_scope_flow(this, _, -1) }
157157

158-
/** The value that this ControlFlowNode points-to. */
158+
/** Gets the value that this ControlFlowNode points-to. */
159159
predicate pointsTo(Value value) { this.pointsTo(_, value, _) }
160160

161161
/** Gets the value that this ControlFlowNode points-to. */
@@ -164,10 +164,10 @@ class ControlFlowNode extends @py_flow_node {
164164
/** Gets a value that this ControlFlowNode may points-to. */
165165
Value inferredValue() { this.pointsTo(_, result, _) }
166166

167-
/** The value and origin that this ControlFlowNode points-to. */
167+
/** Gets the value and origin that this ControlFlowNode points-to. */
168168
predicate pointsTo(Value value, ControlFlowNode origin) { this.pointsTo(_, value, origin) }
169169

170-
/** The value and origin that this ControlFlowNode points-to, given the context. */
170+
/** Gets the value and origin that this ControlFlowNode points-to, given the context. */
171171
predicate pointsTo(Context context, Value value, ControlFlowNode origin) {
172172
PointsTo::pointsTo(this, context, value, origin)
173173
}

python/ql/lib/semmle/python/Function.qll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ import python
55
* It is the syntactic entity that is compiled to a code object.
66
*/
77
class Function extends Function_, Scope, AstNode {
8-
/** The expression defining this function */
8+
/** Gets the expression defining this function */
99
CallableExpr getDefinition() { result = this.getParent() }
1010

1111
/**
12-
* The scope in which this function occurs, will be a class for a method,
12+
* Gets the scope in which this function occurs. This will be a class for a method,
1313
* another function for nested functions, generator expressions or comprehensions,
1414
* or a module for a plain function.
1515
*/
@@ -183,8 +183,8 @@ class FunctionDef extends Assign {
183183
override Stmt getLastStatement() { result = this.getDefinedFunction().getLastStatement() }
184184
}
185185

186+
/** A function that uses 'fast' locals, stored in the frame not in a dictionary. */
186187
class FastLocalsFunction extends Function {
187-
/** A function that uses 'fast' locals, stored in the frame not in a dictionary. */
188188
FastLocalsFunction() {
189189
not exists(ImportStar i | i.getScope() = this) and
190190
not exists(Exec e | e.getScope() = this)

0 commit comments

Comments
 (0)