@@ -21,32 +21,34 @@ predicate is_type_method(FunctionValue fv) {
21
21
}
22
22
23
23
predicate used_in_defining_scope ( FunctionValue fv ) {
24
- exists ( Call c |
25
- c .getScope ( ) = fv .getScope ( ) .getScope ( ) and c .getFunc ( ) .pointsTo ( fv )
26
- )
24
+ exists ( Call c | c .getScope ( ) = fv .getScope ( ) .getScope ( ) and c .getFunc ( ) .pointsTo ( fv ) )
27
25
}
28
26
29
27
from Function f , FunctionValue fv , string message
30
28
where
31
- exists ( ClassValue cls , string name |
32
- cls .declaredAttribute ( name ) = fv and cls .isNewStyle ( ) and
33
- not name = "__new__" and
34
- not name = "__metaclass__" and
35
- /* declared in scope */
36
- f .getScope ( ) = cls .getScope ( )
37
- ) and
38
- not f .getArgName ( 0 ) = "self" and
39
- not is_type_method ( fv ) and
40
- fv .getScope ( ) = f and
41
- not f .getName ( ) = "lambda" and
42
- not used_in_defining_scope ( fv ) and
43
- (
44
- if exists ( f .getArgName ( 0 ) ) then
45
- message = "Normal methods should have 'self', rather than '" + f .getArgName ( 0 ) + "', as their first parameter."
46
- else
47
- message = "Normal methods should have at least one parameter (the first of which should be 'self')." and
48
- not f .hasVarArg ( )
49
- ) and
50
- not fv instanceof ZopeInterfaceMethodValue
51
-
29
+ exists ( ClassValue cls , string name |
30
+ cls .declaredAttribute ( name ) = fv and
31
+ cls .isNewStyle ( ) and
32
+ not name = "__new__" and
33
+ not name = "__metaclass__" and
34
+ /* declared in scope */
35
+ f .getScope ( ) = cls .getScope ( )
36
+ ) and
37
+ not f .getArgName ( 0 ) = "self" and
38
+ not is_type_method ( fv ) and
39
+ fv .getScope ( ) = f and
40
+ not f .getName ( ) = "lambda" and
41
+ not used_in_defining_scope ( fv ) and
42
+ (
43
+ (
44
+ if exists ( f .getArgName ( 0 ) )
45
+ then
46
+ message = "Normal methods should have 'self', rather than '" + f .getArgName ( 0 ) +
47
+ "', as their first parameter."
48
+ else
49
+ message = "Normal methods should have at least one parameter (the first of which should be 'self')."
50
+ ) and
51
+ not f .hasVarArg ( )
52
+ ) and
53
+ not fv instanceof ZopeInterfaceMethodValue
52
54
select f , message
0 commit comments