Skip to content

Commit

Permalink
Rust: Move the restriction to variableDecl.
Browse files Browse the repository at this point in the history
  • Loading branch information
geoffw0 committed Oct 9, 2024
1 parent a66f31d commit dfeb35f
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions rust/ql/lib/codeql/rust/elements/internal/VariableImpl.qll
Original file line number Diff line number Diff line change
Expand Up @@ -77,21 +77,20 @@ module Impl {
not exists(getOutermostEnclosingOrPat(p)) and
definingNode = p.getName()
) and
name = p.getName().getText()
name = p.getName().getText() and
// exclude for now anything starting with an uppercase character, which may be a reference to
// an enum constant (e.g. `None`). This excludes static and constant variables (UPPERCASE),
// which we don't appear to recognize yet anyway. This also assumes programmers follow the
// naming guidelines, which they generally do, but they're not enforced.
not name.charAt(0).isUppercase()
}

/** A variable. */
class Variable extends MkVariable {
private AstNode definingNode;
private string name;

Variable() {
this = MkVariable(definingNode, name) and
// exclude for now anything starting with an uppercase character, which may be an enum constant (e.g. `None`). This excludes
// static and constant variables (UPPERCASE), which we don't appear to recognize yet anyway. This also assumes programmers
// follow the naming guidelines, which they generally do, but they're not enforced.
not name.charAt(0).isUppercase()
}
Variable() { this = MkVariable(definingNode, name) }

/** Gets the name of this variable. */
string getName() { result = name }
Expand Down

0 comments on commit dfeb35f

Please sign in to comment.