mirror of
https://github.com/github/codeql.git
synced 2025-12-21 19:26:31 +01:00
Python: fix ql alerts
This commit is contained in:
@@ -167,7 +167,7 @@ class StringPart extends StringPart_, AstNode {
|
|||||||
* Gets the length of the content, that is the text between the prefix and the quote.
|
* Gets the length of the content, that is the text between the prefix and the quote.
|
||||||
* See `context` for obtaining the prefix and the quote.
|
* See `context` for obtaining the prefix and the quote.
|
||||||
*/
|
*/
|
||||||
int getContentLenght() {
|
int getContentLength() {
|
||||||
exists(string prefix, string quote | this.context(prefix, quote) |
|
exists(string prefix, string quote | this.context(prefix, quote) |
|
||||||
result = this.getText().length() - prefix.length() - quote.length()
|
result = this.getText().length() - prefix.length() - quote.length()
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -230,7 +230,7 @@ module Impl implements RegexTreeViewSig {
|
|||||||
index > 0 and
|
index > 0 and
|
||||||
exists(int previousOffset | previousOffset = this.getPartOffset(index - 1) |
|
exists(int previousOffset | previousOffset = this.getPartOffset(index - 1) |
|
||||||
result =
|
result =
|
||||||
previousOffset + re.(StrConst).getImplicitlyConcatenatedPart(index - 1).getContentLenght()
|
previousOffset + re.(StrConst).getImplicitlyConcatenatedPart(index - 1).getContentlength()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -245,7 +245,7 @@ module Impl implements RegexTreeViewSig {
|
|||||||
// Example:
|
// Example:
|
||||||
// re.compile('...' r"""...this..""")
|
// re.compile('...' r"""...this..""")
|
||||||
// - `start` is the offset from `(` to `this` as counted after concatenating all parts.
|
// - `start` is the offset from `(` to `this` as counted after concatenating all parts.
|
||||||
// - we subtract the lenght of the previous `StringPart`s, `'...'`, to know how far into this `StringPart` we go.
|
// - we subtract the length of the previous `StringPart`s, `'...'`, to know how far into this `StringPart` we go.
|
||||||
// - as the prefix 'r"""' is part of the `StringPart`, `this` is found that much further in.
|
// - as the prefix 'r"""' is part of the `StringPart`, `this` is found that much further in.
|
||||||
localOffset = start - this.getPartOffset(index) + prefixLength
|
localOffset = start - this.getPartOffset(index) + prefixLength
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user