mirror of
https://github.com/github/codeql.git
synced 2026-04-30 19:26:02 +02:00
JavaScript: ignore self-assignments with a JSDoc comment
This commit is contained in:
@@ -152,7 +152,14 @@ class SelfAssignment extends StructurallyCompared {
|
||||
}
|
||||
|
||||
override Expr candidate() {
|
||||
result = getParent().(AssignExpr).getRhs()
|
||||
result = getAssignment().getRhs()
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the enclosing assignment.
|
||||
*/
|
||||
AssignExpr getAssignment() {
|
||||
result.getLhs() = this
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -43,5 +43,7 @@ where e.same(_) and
|
||||
propName = any(AccessorMethodDeclaration amd).getName()
|
||||
) and
|
||||
// exclude DOM properties
|
||||
not isDOMProperty(e.(PropAccess).getPropertyName())
|
||||
select e.getParent(), "This expression assigns " + dsc + " to itself."
|
||||
not isDOMProperty(e.(PropAccess).getPropertyName()) and
|
||||
// exclude self-assignments with a JSDoc comment
|
||||
not exists(e.getAssignment().getParent().(ExprStmt).getDocumentation().getATag())
|
||||
select e.getParent(), "This expression assigns " + dsc + " to itself."
|
||||
|
||||
Reference in New Issue
Block a user