Menu

[r2]: / trunk / rules / cpp_rule_call.py  Maximize  Restore  History

Download this file

34 lines (27 with data), 1.4 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
29
30
31
32
33
34
from rules import CSCRuleBase
import re
class rule_call_no_space_before_after_parentheses(CSCRuleBase):
rule_re = re.compile("[A-Z][a-z]+")
def name(self):
return self.__class__.__name__
def description(self):
return "There should no space before/after parenthese when call function."
def category(self):
return "call_function"
def execute(self, item_name, line, column, source, ext_param):
c_left = source.find("(")
issue_records = []
if c_left != -1:
if source[c_left - 1] == " " or source[c_left + 1] == " ":
self._logger.error("Find exception: (%d) " % c_left)
#self.db().report_issue(file_name, line, c_left, self.name(), source)
issue_record = (line, c_left, self.name(), source, CSCRuleBase.rule_errorlevel_low, "")
issue_records.append(issue_record)
c_right = source.find(")")
if c_right != -1:
if source[c_right - 1] == " ":
self._logger.error("Find exception: (%d) " % c_right)
#self.db().report_issue(file_name, line, c_right, self.name(), source)
issue_record = (line, c_right, self.name(), source, CSCRuleBase.rule_errorlevel_low, "")
issue_records.append(issue_record)
return issue_records
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.