1212
1313import python
1414
15-
1615predicate deprecated_module ( string name , string instead , int major , int minor ) {
1716 name = "posixfile" and instead = "email" and major = 1 and minor = 5
1817 or
@@ -34,40 +33,44 @@ predicate deprecated_module(string name, string instead, int major, int minor) {
3433 or
3534 name = "rotor" and instead = "no replacement" and major = 2 and minor = 4
3635 or
37- name = "statcache" and instead = "no replacement" and major = 2 and minor = 2
36+ name = "statcache" and instead = "no replacement" and major = 2 and minor = 2
3837 or
39- name = "mpz" and instead = "a third party" and major = 2 and minor = 2
38+ name = "mpz" and instead = "a third party" and major = 2 and minor = 2
4039 or
4140 name = "xreadlines" and instead = "no replacement" and major = 2 and minor = 3
4241 or
4342 name = "multifile" and instead = "email" and major = 2 and minor = 5
4443 or
45- name = "sets" and instead = "builtins" and major = 2 and minor = 6
44+ name = "sets" and instead = "builtins" and major = 2 and minor = 6
4645 or
4746 name = "buildtools" and instead = "no replacement" and major = 2 and minor = 3
4847 or
49- name = "cfmfile" and instead = "no replacement" and major = 2 and minor = 4
48+ name = "cfmfile" and instead = "no replacement" and major = 2 and minor = 4
5049 or
5150 name = "macfs" and instead = "no replacement" and major = 2 and minor = 3
5251 or
53- name = "md5" and instead = "hashlib" and major = 2 and minor = 5
52+ name = "md5" and instead = "hashlib" and major = 2 and minor = 5
5453 or
55- name = "sha" and instead = "hashlib" and major = 2 and minor = 5
54+ name = "sha" and instead = "hashlib" and major = 2 and minor = 5
5655}
5756
5857string deprecation_message ( string mod ) {
59- exists ( int major , int minor | deprecated_module ( mod , _, major , minor ) |
60- result = "The " + mod + " module was deprecated in version " + major .toString ( ) + "." + minor .toString ( ) + "." )
58+ exists ( int major , int minor | deprecated_module ( mod , _, major , minor ) |
59+ result = "The " + mod + " module was deprecated in version " + major .toString ( ) + "." +
60+ minor .toString ( ) + "."
61+ )
6162}
6263
6364string replacement_message ( string mod ) {
64- exists ( string instead | deprecated_module ( mod , instead , _, _) |
65- result = " Use " + instead + " module instead." and not instead = "no replacement"
66- or
67- result = "" and instead = "no replacement"
68- )
65+ exists ( string instead | deprecated_module ( mod , instead , _, _) |
66+ result = " Use " + instead + " module instead." and not instead = "no replacement"
67+ or
68+ result = "" and instead = "no replacement"
69+ )
6970}
7071
7172from ImportExpr imp , Stmt s , Expr e
72- where s .getASubExpression ( ) = e and ( e = imp or e .contains ( imp ) )
73+ where
74+ s .getASubExpression ( ) = e and
75+ ( e = imp or e .contains ( imp ) )
7376select s , deprecation_message ( imp .getName ( ) ) + replacement_message ( imp .getName ( ) )
0 commit comments