Python: fix ql alerts

This commit is contained in:
Rasmus Lerchedahl Petersen
2023-09-26 20:33:24 +02:00
parent d10b181d89
commit d25b93d944
2 changed files with 3 additions and 3 deletions

View File

@@ -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()
) )

View File

@@ -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
) )