diff --git a/csharp/ql/lib/printAst.ql b/csharp/ql/lib/printAst.ql index 380f4b4024bb..85820796a881 100644 --- a/csharp/ql/lib/printAst.ql +++ b/csharp/ql/lib/printAst.ql @@ -18,8 +18,8 @@ external string selectedSourceFile(); class PrintAstConfigurationOverride extends PrintAstConfiguration { /** - * Holds if the location matches the selected file in the VS Code extension and - * the element is `fromSource`. + * Holds if the location `l` matches the selected file in the VS Code extension and + * the element is `e` is `fromSource`. */ override predicate shouldPrint(Element e, Location l) { super.shouldPrint(e, l) and diff --git a/csharp/ql/lib/semmle/code/csharp/Assignable.qll b/csharp/ql/lib/semmle/code/csharp/Assignable.qll index d4f8d9974f08..3c7170a6f846 100644 --- a/csharp/ql/lib/semmle/code/csharp/Assignable.qll +++ b/csharp/ql/lib/semmle/code/csharp/Assignable.qll @@ -583,7 +583,7 @@ module AssignableDefinitions { } /** - * Holds if the `ref` assignment to `aa` via call `c` is uncertain. + * Holds if the `ref` assignment to `arg` via call `c` is uncertain. */ // Not in the cached module `Cached`, as that would introduce a dependency // on the CFG construction, and effectively collapse too many stages into one diff --git a/csharp/ql/lib/semmle/code/csharp/Callable.qll b/csharp/ql/lib/semmle/code/csharp/Callable.qll index 6384f4582769..7e17f853913a 100644 --- a/csharp/ql/lib/semmle/code/csharp/Callable.qll +++ b/csharp/ql/lib/semmle/code/csharp/Callable.qll @@ -708,7 +708,7 @@ class TrueOperator extends UnaryOperator { * * Either an addition operator (`AddOperator`), a checked addition operator * (`CheckedAddOperator`) a subtraction operator (`SubOperator`), a checked - * substraction operator (`CheckedSubOperator`), a multiplication operator + * subtraction operator (`CheckedSubOperator`), a multiplication operator * (`MulOperator`), a checked multiplication operator (`CheckedMulOperator`), * a division operator (`DivOperator`), a checked division operator * (`CheckedDivOperator`), a remainder operator (`RemOperator`), an and diff --git a/csharp/ql/lib/semmle/code/csharp/Member.qll b/csharp/ql/lib/semmle/code/csharp/Member.qll index 3427d4ea0893..a196d3b3fc70 100644 --- a/csharp/ql/lib/semmle/code/csharp/Member.qll +++ b/csharp/ql/lib/semmle/code/csharp/Member.qll @@ -491,7 +491,7 @@ class Parameterizable extends Declaration, @parameterizable { final Parameter getARawParameter() { result = this.getRawParameter(_) } /** - * Gets the type of the parameter, possibly prefixed + * Gets the type of the `i`th parameter, possibly prefixed * with `out`, `ref`, or `params`, where appropriate. */ private string parameterTypeToString(int i) { diff --git a/csharp/ql/lib/semmle/code/csharp/PrintAst.qll b/csharp/ql/lib/semmle/code/csharp/PrintAst.qll index fd4bf1cb86b0..1ac96c85e788 100644 --- a/csharp/ql/lib/semmle/code/csharp/PrintAst.qll +++ b/csharp/ql/lib/semmle/code/csharp/PrintAst.qll @@ -523,11 +523,9 @@ final class AttributeNode extends ElementNode { * A node representing a `TypeParameter`. */ final class TypeParameterNode extends ElementNode { - TypeParameter typeParameter; - TypeParameterNode() { - typeParameter = element and - not isNotNeeded(typeParameter.getDeclaringGeneric()) + element = + any(TypeParameter typeParameter | not isNotNeeded(typeParameter.getDeclaringGeneric())) } override ElementNode getChild(int childIndex) { none() } diff --git a/csharp/ql/lib/semmle/code/csharp/controlflow/internal/Completion.qll b/csharp/ql/lib/semmle/code/csharp/controlflow/internal/Completion.qll index 6fed45cdf84d..a3bf97945964 100644 --- a/csharp/ql/lib/semmle/code/csharp/controlflow/internal/Completion.qll +++ b/csharp/ql/lib/semmle/code/csharp/controlflow/internal/Completion.qll @@ -310,10 +310,8 @@ private class Overflowable extends UnaryOperation { /** A control flow element that is inside a `try` block. */ private class TriedControlFlowElement extends ControlFlowElement { - TryStmt try; - TriedControlFlowElement() { - this = try.getATriedElement() and + this = any(TryStmt try).getATriedElement() and not this instanceof NonReturningCall } diff --git a/csharp/ql/lib/semmle/code/csharp/dataflow/SSA.qll b/csharp/ql/lib/semmle/code/csharp/dataflow/SSA.qll index f17317af83be..4c9f64de4b9e 100644 --- a/csharp/ql/lib/semmle/code/csharp/dataflow/SSA.qll +++ b/csharp/ql/lib/semmle/code/csharp/dataflow/SSA.qll @@ -451,10 +451,9 @@ module Ssa { * An SSA definition that corresponds to an explicit assignable definition. */ class ExplicitDefinition extends Definition, SsaImpl::WriteDefinition { - SourceVariable sv; AssignableDefinition ad; - ExplicitDefinition() { SsaImpl::explicitDefinition(this, sv, ad) } + ExplicitDefinition() { SsaImpl::explicitDefinition(this, _, ad) } /** * Gets an underlying assignable definition. The result is always unique, diff --git a/csharp/ql/lib/semmle/code/csharp/dataflow/internal/SsaImpl.qll b/csharp/ql/lib/semmle/code/csharp/dataflow/internal/SsaImpl.qll index d1490c849163..397225deb8c1 100644 --- a/csharp/ql/lib/semmle/code/csharp/dataflow/internal/SsaImpl.qll +++ b/csharp/ql/lib/semmle/code/csharp/dataflow/internal/SsaImpl.qll @@ -150,7 +150,7 @@ private module SourceVariableImpl { } /** - * Gets an `out`/`ref` definition of the same source variable as the `out`/`ref` + * Gets an `out`/`ref` definition of the same source variable `v` as the `out`/`ref` * definition `def`, belonging to the same call, at a position after `def`. */ OutRefDefinition getASameOutRefDefAfter(Ssa::SourceVariable v, OutRefDefinition def) { diff --git a/csharp/ql/lib/semmle/code/csharp/security/dataflow/UnsafeDeserializationQuery.qll b/csharp/ql/lib/semmle/code/csharp/security/dataflow/UnsafeDeserializationQuery.qll index 27f6ab6935f7..5b2bd407a5ce 100644 --- a/csharp/ql/lib/semmle/code/csharp/security/dataflow/UnsafeDeserializationQuery.qll +++ b/csharp/ql/lib/semmle/code/csharp/security/dataflow/UnsafeDeserializationQuery.qll @@ -874,7 +874,7 @@ private predicate isStrongTypeFsPicklerCall(MethodCall mc, Method m) { ( m instanceof FsPicklerSerializerClassDeserializeMethod or m instanceof FsPicklerSerializerClassDeserializeSequenceMethod or - m instanceof FsPicklerSerializerClasDeserializeSiftedMethod or + m instanceof FsPicklerSerializerClassDeserializeSiftedMethod or m instanceof FsPicklerSerializerClassUnPickleMethod or m instanceof FsPicklerSerializerClassUnPickleSiftedMethod or m instanceof CsPicklerSerializerClassDeserializeMethod or diff --git a/csharp/ql/lib/semmle/code/csharp/serialization/Deserializers.qll b/csharp/ql/lib/semmle/code/csharp/serialization/Deserializers.qll index aeb341222844..f7c6ade96eaf 100644 --- a/csharp/ql/lib/semmle/code/csharp/serialization/Deserializers.qll +++ b/csharp/ql/lib/semmle/code/csharp/serialization/Deserializers.qll @@ -560,9 +560,15 @@ class FsPicklerSerializerClassDeserializeSequenceMethod extends Method, UnsafeDe } } +/** + * DEPRECATED: Use `FsPicklerSerializerClassDeserializeSiftedMethod` instead. + */ +deprecated class FsPicklerSerializerClasDeserializeSiftedMethod = + FsPicklerSerializerClassDeserializeSiftedMethod; + /** `MBrace.FsPickler.FsPicklerSerializer.DeserializeSifted` method */ -class FsPicklerSerializerClasDeserializeSiftedMethod extends Method, UnsafeDeserializer { - FsPicklerSerializerClasDeserializeSiftedMethod() { +class FsPicklerSerializerClassDeserializeSiftedMethod extends Method, UnsafeDeserializer { + FsPicklerSerializerClassDeserializeSiftedMethod() { this.getDeclaringType().getBaseClass*() instanceof FsPicklerSerializerClass and this.hasUndecoratedName("DeserializeSifted") } diff --git a/csharp/ql/src/Bad Practices/Magic Constants/MagicConstants.qll b/csharp/ql/src/Bad Practices/Magic Constants/MagicConstants.qll index 73b82c14700a..8c3e0562d395 100644 --- a/csharp/ql/src/Bad Practices/Magic Constants/MagicConstants.qll +++ b/csharp/ql/src/Bad Practices/Magic Constants/MagicConstants.qll @@ -113,7 +113,7 @@ private predicate valueOccurrenceCount(string value, int n) { n > 20 } -private predicate occurenceCount(Literal lit, string value, int n) { +private predicate occurrenceCount(Literal lit, string value, int n) { valueOccurrenceCount(value, n) and value = lit.getValue() and relevantLiteral(lit, value) @@ -127,7 +127,7 @@ private predicate check(Literal lit, string value, int n, File f) { // Check that the literal is nontrivial not trivial(lit) and // Check that it is repeated a number of times - occurenceCount(lit, value, n) and + occurrenceCount(lit, value, n) and n > 20 and f = lit.getFile() } diff --git a/csharp/ql/src/Language Abuse/UselessUpcast.ql b/csharp/ql/src/Language Abuse/UselessUpcast.ql index 827d16038b21..a06dc60cc7ab 100644 --- a/csharp/ql/src/Language Abuse/UselessUpcast.ql +++ b/csharp/ql/src/Language Abuse/UselessUpcast.ql @@ -75,15 +75,16 @@ private class ConstructorCall extends Call { /** An explicit upcast. */ class ExplicitUpcast extends ExplicitCast { - ValueOrRefType src; ValueOrRefType dest; ExplicitUpcast() { - src = this.getSourceType() and - dest = this.getTargetType() and - (src instanceof RefType or src instanceof Struct) and - src.isImplicitlyConvertibleTo(dest) and - src != dest // Handled by `cs/useless-cast-to-self` + exists(ValueOrRefType src | + src = this.getSourceType() and + dest = this.getTargetType() and + (src instanceof RefType or src instanceof Struct) and + src.isImplicitlyConvertibleTo(dest) and + src != dest // Handled by `cs/useless-cast-to-self` + ) } pragma[nomagic] diff --git a/csharp/ql/src/Telemetry/DatabaseQuality.qll b/csharp/ql/src/Telemetry/DatabaseQuality.qll index fa6c70dbc51f..ca2ab3e7e165 100644 --- a/csharp/ql/src/Telemetry/DatabaseQuality.qll +++ b/csharp/ql/src/Telemetry/DatabaseQuality.qll @@ -12,7 +12,7 @@ module CallTargetStats implements StatsSig { private predicate isNoSetterPropertyCallInConstructor(PropertyCall c) { exists(Property p, Constructor ctor | p = c.getProperty() and - not exists(Setter a | a = p.getAnAccessor()) and + not p.getAnAccessor() instanceof Setter and c.getEnclosingCallable() = ctor and ( c.hasThisQualifier() @@ -25,7 +25,7 @@ module CallTargetStats implements StatsSig { private predicate isNoSetterPropertyInitialization(PropertyCall c) { exists(Property p, AssignExpr assign | p = c.getProperty() and - not exists(Setter a | a = p.getAnAccessor()) and + not p.getAnAccessor() instanceof Setter and assign = c.getParent() and assign.getLValue() = c and assign.getParent() instanceof Property