-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRule1.py
More file actions
28 lines (22 loc) · 1.04 KB
/
Rule1.py
File metadata and controls
28 lines (22 loc) · 1.04 KB
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
from Rule import Rule
import re
class Rule1(Rule):
def __init__(self):
Rule.__init__(self, 1, "All Class member variables must start with underscore '_'")
def check(self, xml):
dumps = xml.findall("./dump")
for d in dumps:
for scope in d.findall("./scopes/scope"):
if scope.attrib.get('type') == 'Class':
self.log.debug(scope.attrib)
for var in scope.findall("./varlist/var"):
id = var.attrib.get('id')
varData = self.getVar(id, xml)
tokData = self.getToken(varData.attrib.get('nameToken'), xml)
name = tokData.attrib.get('str')
file = tokData.attrib.get('file')
line = tokData.attrib.get('linenr')
if not re.match('^_\w+', name):
self.raiseError(file, line, name)
#print(varData.attrib)
#print(tokData.attrib)