Skip to content

Commit 26a0bfa

Browse files
committed
refactor js/suspicious-method-name-declaration to use isSynthetic predicate
1 parent 1e2aad5 commit 26a0bfa

File tree

1 file changed

+3
-13
lines changed

1 file changed

+3
-13
lines changed

javascript/ql/src/Declarations/SuspiciousMethodNameDeclaration.ql

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,6 @@ predicate isSuspisousMethodName(string name, ClassOrInterface container) {
2626
name = "new" and container instanceof ClassDefinition
2727
}
2828

29-
/**
30-
* Holds if the beginning of the location is before the end.
31-
*/
32-
predicate isRealLocation(Location l) {
33-
l.getEndLine() > l.getStartLine() or
34-
(l.getStartLine() = l.getEndLine() and l.getEndColumn() > l.getStartColumn())
35-
}
36-
3729
from MethodDeclaration member, ClassOrInterface container, string suffixMsg
3830
where
3931
container.getLocation().getFile().getFileType().isTypeScript() and
@@ -44,11 +36,9 @@ where
4436
not (
4537
member.getName() = "new" and
4638
container instanceof ClassDefinition and
47-
exists(MemberDeclaration constructor |
39+
exists(ConstructorDeclaration constructor |
4840
container.getAMember() = constructor and
49-
constructor.getName() = "constructor" and
50-
// Test that it is not an implicitly declared constructor.
51-
isRealLocation(constructor.getLocation())
41+
not constructor.isSynthetic()
5242
)
5343
) and
5444

@@ -66,7 +56,7 @@ where
6656
member.getName() = "function" and
6757
exists(MethodDeclaration other | other = container.getMethod(_) |
6858
other.getName() != "function" and
69-
isRealLocation(other.getLocation())
59+
not other.(ConstructorDeclaration).isSynthetic()
7060
)
7161
) and
7262

0 commit comments

Comments
 (0)