Python: Modernise py/local-shadows-builtin

+ moved `scope instanceof Function` so it makes more sense :)
This commit is contained in:
Rasmus Wriedt Larsen
2019-12-12 16:12:39 +01:00
parent 6a73479ea3
commit 9f4088413a

View File

@@ -11,10 +11,11 @@
* @precision medium
* @id py/local-shadows-builtin
*/
import python
import Shadowing
import semmle.python.types.Builtins
predicate white_list(string name) {
/* These are rarely used and thus unlikely to be confusing */
name = "iter" or
@@ -43,10 +44,11 @@ predicate white_list(string name) {
}
predicate shadows(Name d, string name, Scope scope, int line) {
exists(LocalVariable l | d.defines(l) and scope instanceof Function and
exists(LocalVariable l | d.defines(l) and
l.getId() = name and
exists(Object::builtin(l.getId()))
exists(Builtin::builtin(l.getId()))
) and
scope instanceof Function and
d.getScope() = scope and
d.getLocation().getStartLine() = line and
not white_list(name) and