patch upper-case acronyms to be PascalCase

This commit is contained in:
Erik Krogh Kristensen
2022-03-11 11:10:33 +01:00
parent e3a15792fa
commit 69353bb014
422 changed files with 3532 additions and 2244 deletions

View File

@@ -7,7 +7,7 @@ import javascript
/**
* Gets an opaque integer value encoding the type of AST node `nd`.
*/
private int kindOf(ASTNode nd) {
private int kindOf(AstNode nd) {
// map expression kinds to even non-negative numbers
result = nd.(Expr).getKind() * 2
or
@@ -25,7 +25,7 @@ private int kindOf(ASTNode nd) {
/**
* Holds if `nd` has the given `kind`, and its number of children is `arity`.
*/
private predicate kindAndArity(ASTNode nd, int kind, int arity) {
private predicate kindAndArity(AstNode nd, int kind, int arity) {
kindOf(nd) = kind and arity = nd.getNumChild()
}
@@ -35,7 +35,7 @@ private predicate kindAndArity(ASTNode nd, int kind, int arity) {
*
* Every AST node has at most one value.
*/
private string valueOf(ASTNode nd) {
private string valueOf(AstNode nd) {
result = nd.(Literal).getRawValue() or
result = nd.(TemplateElement).getRawValue() or
result = nd.(Identifier).getName()
@@ -47,18 +47,18 @@ private string valueOf(ASTNode nd) {
* Clients must override the `candidate()` method to identify the
* nodes for which structural comparison will be interesting.
*/
abstract class StructurallyCompared extends ASTNode {
abstract class StructurallyCompared extends AstNode {
/**
* Gets a candidate node that we may want to structurally compare this node to.
*/
abstract ASTNode candidate();
abstract AstNode candidate();
/**
* Gets a node that structurally corresponds to this node, either because it is
* a candidate node, or because it is at the same position relative to a
* candidate node as this node.
*/
ASTNode candidateInternal() {
AstNode candidateInternal() {
// in order to correspond, nodes need to have the same kind and shape
exists(int kind, int numChildren | kindAndArity(this, kind, numChildren) |
result = this.candidateKind(kind, numChildren)
@@ -71,18 +71,18 @@ abstract class StructurallyCompared extends ASTNode {
* Gets a node that structurally corresponds to the parent node of this node,
* where this node is the `i`th child of its parent.
*/
private ASTNode getAStructuralUncle(int i) {
private AstNode getAStructuralUncle(int i) {
exists(StructurallyCompared parent | this = parent.getChild(i) |
result = parent.candidateInternal()
)
}
private ASTNode candidateKind(int kind, int numChildren) {
private AstNode candidateKind(int kind, int numChildren) {
result = this.candidate() and kindAndArity(result, kind, numChildren)
}
pragma[noinline]
private ASTNode uncleKind(int kind, int numChildren) {
private AstNode uncleKind(int kind, int numChildren) {
exists(int i | result = this.getAStructuralUncle(i).getChild(i)) and
kindAndArity(result, kind, numChildren)
}
@@ -92,7 +92,7 @@ abstract class StructurallyCompared extends ASTNode {
* rooted at node `that`, where `that` structurally corresponds to `this` as
* determined by `candidateInternal`.
*/
private predicate sameInternal(ASTNode that) {
private predicate sameInternal(AstNode that) {
that = this.candidateInternal() and
/*
* Check that `this` and `that` bind to the same variable, if any.
@@ -120,7 +120,7 @@ abstract class StructurallyCompared extends ASTNode {
* rooted at node `that`, which must be a candidate node as determined by
* `candidate`.
*/
predicate same(ASTNode that) {
predicate same(AstNode that) {
that = this.candidate() and
this.sameInternal(that)
}
@@ -132,7 +132,7 @@ abstract class StructurallyCompared extends ASTNode {
private class InternalCandidate extends StructurallyCompared {
InternalCandidate() { exists(this.getParent().(StructurallyCompared).candidateInternal()) }
override ASTNode candidate() { none() }
override AstNode candidate() { none() }
}
/**

View File

@@ -24,7 +24,7 @@ private import semmle.javascript.DefensiveProgramming
* Besides the usual comparison operators, `switch` statements are also considered to be comparisons,
* with the switched-on expression being the right operand and all case labels the left operands.
*/
predicate comparisonOperands(ASTNode nd, Expr left, Expr right) {
predicate comparisonOperands(AstNode nd, Expr left, Expr right) {
exists(Comparison cmp | cmp = nd | left = cmp.getLeftOperand() and right = cmp.getRightOperand())
or
exists(SwitchStmt switch | switch = nd |
@@ -45,7 +45,7 @@ predicate hasImplicitConversionMethod(DefiniteAbstractValue av) {
/**
* Gets a type of `operand`, which is an operand of the strict equality test `eq`.
*/
InferredType strictEqualityOperandType(ASTNode eq, DataFlow::AnalyzedNode operand) {
InferredType strictEqualityOperandType(AstNode eq, DataFlow::AnalyzedNode operand) {
// strict equality tests do no conversion at all
operand.asExpr() = eq.(StrictEqualityTest).getAChildExpr() and result = operand.getAType()
or
@@ -60,7 +60,7 @@ InferredType strictEqualityOperandType(ASTNode eq, DataFlow::AnalyzedNode operan
* Holds if `operand` is an operand of the non-strict equality test or relational
* operator `parent`, and may have a `toString` or `valueOf` method.
*/
predicate implicitlyConvertedOperand(ASTNode parent, DataFlow::AnalyzedNode operand) {
predicate implicitlyConvertedOperand(AstNode parent, DataFlow::AnalyzedNode operand) {
(parent instanceof NonStrictEqualityTest or parent instanceof RelationalComparison) and
operand.asExpr() = parent.getAChildExpr() and
hasImplicitConversionMethod(operand.getAValue())
@@ -70,7 +70,7 @@ predicate implicitlyConvertedOperand(ASTNode parent, DataFlow::AnalyzedNode oper
* Gets a type of `operand`, which is an operand of the non-strict equality test or
* relational operator `parent`.
*/
InferredType nonStrictOperandType(ASTNode parent, DataFlow::AnalyzedNode operand) {
InferredType nonStrictOperandType(AstNode parent, DataFlow::AnalyzedNode operand) {
// non-strict equality tests perform conversions
operand.asExpr() = parent.(NonStrictEqualityTest).getAChildExpr() and
exists(InferredType tp | tp = operand.getAValue().getType() |
@@ -109,7 +109,7 @@ InferredType nonStrictOperandType(ASTNode parent, DataFlow::AnalyzedNode operand
* Gets a type that `operand`, which is an operand of comparison `parent`,
* could be converted to at runtime.
*/
InferredType convertedOperandType(ASTNode parent, DataFlow::AnalyzedNode operand) {
InferredType convertedOperandType(AstNode parent, DataFlow::AnalyzedNode operand) {
result = strictEqualityOperandType(parent, operand)
or
// if `operand` might have `toString`/`valueOf`, just assume it could
@@ -125,7 +125,7 @@ InferredType convertedOperandType(ASTNode parent, DataFlow::AnalyzedNode operand
* common type they coerce to.
*/
predicate isHeterogeneousComparison(
ASTNode cmp, DataFlow::AnalyzedNode left, DataFlow::AnalyzedNode right, string leftTypes,
AstNode cmp, DataFlow::AnalyzedNode left, DataFlow::AnalyzedNode right, string leftTypes,
string rightTypes
) {
comparisonOperands(cmp, left.asExpr(), right.asExpr()) and
@@ -188,7 +188,7 @@ predicate isInitialParameterUse(Expr e) {
predicate whitelist(Expr e) { isInitialParameterUse(e) }
from
ASTNode cmp, DataFlow::AnalyzedNode left, DataFlow::AnalyzedNode right, string leftTypes,
AstNode cmp, DataFlow::AnalyzedNode left, DataFlow::AnalyzedNode right, string leftTypes,
string rightTypes, string leftExprDescription, string rightExprDescription, int leftTypeCount,
int rightTypeCount, string leftTypeDescription, string rightTypeDescription
where

View File

@@ -41,7 +41,7 @@ where
propName = any(AccessorMethodDeclaration amd).getName()
) and
// exclude DOM properties
not isDOMProperty(e.(PropAccess).getPropertyName()) and
not isDomProperty(e.(PropAccess).getPropertyName()) and
// exclude self-assignments that have been inserted to satisfy the TypeScript JS-checker
not e.getAssignment().getParent().(ExprStmt).getDocumentation().getATag().getTitle() = "type" and
// exclude self-assignments in speculatively parsed template files

View File

@@ -83,9 +83,9 @@ private predicate isBoundInMethod(MethodDeclaration method) {
* Gets an event handler attribute (onClick, onTouch, ...).
*/
private DOM::AttributeDefinition getAnEventHandlerAttribute() {
exists(ReactComponent c, JSXNode rendered, string attributeName |
exists(ReactComponent c, JsxNode rendered, string attributeName |
c.getRenderMethod().getAReturnedExpr().flow().getALocalSource().asExpr() = rendered and
result = rendered.getABodyElement*().(JSXElement).getAttributeByName(attributeName) and
result = rendered.getABodyElement*().(JsxElement).getAttributeByName(attributeName) and
attributeName.regexpMatch("on[A-Z][a-zA-Z]+") // camelCased with 'on'-prefix
)
}