-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Expand file tree
/
Copy pathNonSelf.ql
More file actions
31 lines (29 loc) · 820 Bytes
/
NonSelf.ql
File metadata and controls
31 lines (29 loc) · 820 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/**
* @name First parameter of a method is not named 'self'
* @description By the PEP8 style guide, the first parameter of a normal method should be named `self`.
* @kind problem
* @tags maintainability
* readability
* convention
* quality
* @problem.severity recommendation
* @sub-severity high
* @precision very-high
* @id py/not-named-self
*/
import python
import MethodArgNames
from Function f, string message
where
firstArgShouldBeNamedSelfAndIsnt(f) and
(
if exists(f.getArgName(0))
then
message =
"Normal methods should have 'self', rather than '" + f.getArgName(0) +
"', as their first parameter."
else
message =
"Normal methods should have at least one parameter (the first of which should be 'self')."
)
select f, message