Skip to content

Commit 1608758

Browse files
tausbnfelicitymayRasmusWL
authored
Python: Apply suggestions from documentation review.
Co-authored-by: Felicity Chapman <[email protected]> Co-authored-by: Rasmus Wriedt Larsen <[email protected]>
1 parent 9f06e13 commit 1608758

File tree

6 files changed

+15
-16
lines changed

6 files changed

+15
-16
lines changed

python/ql/src/Expressions/CallArgs.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/** INTERNAL - Methods used for queries relating to the correct invocation of functions. */
1+
/** INTERNAL - Methods used by queries that test whether functions are invoked correctly. */
22

33
import python
44
import Testing.Mox

python/ql/src/Expressions/Formatting/AdvancedFormatting.qll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ library class PossibleAdvancedFormatString extends StrConst {
5252
predicate isExplicitlyNumbered() { exists(this.fieldId(_, _).toInt()) }
5353
}
5454

55-
/** Holds if there is a sequence of `{` braces in `fmt` of length `len` beginning at index `index`. */
55+
/** Holds if the formatting string `fmt` contains a sequence of braces `{` of length `len`, beginning at index `index`. */
5656
predicate brace_sequence(PossibleAdvancedFormatString fmt, int index, int len) {
5757
exists(string text | text = fmt.getText() |
5858
text.charAt(index) = "{" and not text.charAt(index - 1) = "{" and len = 1
@@ -63,12 +63,12 @@ predicate brace_sequence(PossibleAdvancedFormatString fmt, int index, int len) {
6363
)
6464
}
6565

66-
/** Holds if index `index` in the format string `fmt` contains an escaped `{`. */
66+
/** Holds if index `index` in the format string `fmt` contains an escaped brace `{`. */
6767
predicate escaped_brace(PossibleAdvancedFormatString fmt, int index) {
6868
exists(int len | brace_sequence(fmt, index, len) | len % 2 = 0)
6969
}
7070

71-
/** Holds if index `index` in the format string `fmt` contains a left curly brace that acts as an escape. */
71+
/** Holds if index `index` in the format string `fmt` contains a left brace `{` that acts as an escape character. */
7272
predicate escaping_brace(PossibleAdvancedFormatString fmt, int index) {
7373
escaped_brace(fmt, index + 1)
7474
}
@@ -114,7 +114,7 @@ class AdvancedFormatString extends PossibleAdvancedFormatString {
114114
AdvancedFormatString() { advanced_format_call(_, this, _) }
115115
}
116116

117-
/** A string formatting operation using the `format` method. */
117+
/** A string formatting operation that uses the `format` method. */
118118
class AdvancedFormattingCall extends Call {
119119
AdvancedFormattingCall() { advanced_format_call(this, _, _) }
120120

python/ql/src/Expressions/IsComparisons.qll

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
/** INTERNAL - Helper predicates for queries concerning comparison of objects using `is`. */
1+
/** INTERNAL - Helper predicates for queries that inspect the comparison of objects using `is`. */
22

33
import python
44

5-
/** Holds if `comp` uses `is` or `is not` (represented as `op`) to compare its `left` and `right` arguments. */
5+
/** Holds if the comparison `comp` uses `is` or `is not` (represented as `op`) to compare its `left` and `right` arguments. */
66
predicate comparison_using_is(Compare comp, ControlFlowNode left, Cmpop op, ControlFlowNode right) {
77
exists(CompareNode fcomp | fcomp = comp.getAFlowNode() |
88
fcomp.operands(left, op, right) and
@@ -41,7 +41,7 @@ predicate invalid_to_use_is_portably(ClassValue c) {
4141
not probablySingleton(c)
4242
}
4343

44-
/** Holds if `f` points to either `True`, `False`, or `None`. */
44+
/** Holds if the control flow node `f` points to either `True`, `False`, or `None`. */
4545
predicate simple_constant(ControlFlowNode f) {
4646
exists(Value val | f.pointsTo(val) |
4747
val = Value::named("True") or val = Value::named("False") or val = Value::named("None")
@@ -102,8 +102,7 @@ private predicate comparison_one_type(Compare comp, Cmpop op, ClassValue cls) {
102102
}
103103

104104
/**
105-
* Holds if the comparison `comp` (with operator `op`) is an invalid comparison using `is` or `is not`
106-
* when applied to instances of the class `cls`.
105+
* Holds if using `is` or `is not` as the operator `op` in the comparison `comp` would be invalid when applied to the class `cls`.
107106
*/
108107
predicate invalid_portable_is_comparison(Compare comp, Cmpop op, ClassValue cls) {
109108
// OK to use 'is' when defining '__eq__'

python/ql/src/Expressions/RedundantComparison.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/** Helper functions for queries having to do with redundant comparisons. */
1+
/** Helper functions for queries that test redundant comparisons. */
22

33
import python
44

@@ -11,7 +11,7 @@ class RedundantComparison extends Compare {
1111
)
1212
}
1313

14-
/** Holds if this comparison could be due to a missing `self.`, for example
14+
/** Holds if this comparison could be redundant due to a missing `self.`, for example
1515
* ```python
1616
* foo == foo
1717
* ```

python/ql/src/Resources/FileOpen.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ predicate function_should_close_parameter(Function func) {
130130
)
131131
}
132132

133-
/** Holds if `f` opens a file, either directly or indirectly. */
133+
/** Holds if the function `f` opens a file, either directly or indirectly. */
134134
predicate function_opens_file(FunctionValue f) {
135135
f = Value::named("open")
136136
or
@@ -145,7 +145,7 @@ predicate function_opens_file(FunctionValue f) {
145145
)
146146
}
147147

148-
/** Holds if `v` refers to a file opened at `open` which is subsequently returned from a function. */
148+
/** Holds if the variable `v` refers to a file opened at `open` which is subsequently returned from a function. */
149149
predicate file_is_returned(EssaVariable v, ControlFlowNode open) {
150150
exists(NameNode n, Return ret |
151151
var_is_open(v, open) and

python/ql/src/semmle/python/Class.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,10 @@ class Class extends Class_, Scope, AstNode {
119119
/** Gets the name used to define this class */
120120
override string getName() { result = Class_.super.getName() }
121121

122-
/** Whether this expression may have a side effect (as determined purely from its syntax). */
122+
/** Holds if this expression may have a side effect (as determined purely from its syntax). */
123123
predicate hasSideEffects() { any() }
124124

125-
/** Whether this is probably a mixin (has 'mixin' or similar in name or docstring) */
125+
/** Holds if this is probably a mixin (has 'mixin' or similar in name or docstring) */
126126
predicate isProbableMixin() {
127127
(
128128
this.getName().toLowerCase().matches("%mixin%")

0 commit comments

Comments
 (0)