Using compiled regular expressions for DACA2 functions (#1209)
The method “match” was used as a module-level function in for loops of implementations for DACA2 functions so far. Use compiled regular expression objects instead. Delete a duplicate element from an alternation. Link: https://trac.cppcheck.net/ticket/8553 Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
This commit is contained in:
parent
78e1474f55
commit
bd6173be6e
|
@ -94,6 +94,7 @@ for severity in ['error', 'warning', 'style', 'portability', 'performance']:
|
||||||
categories[severity] = []
|
categories[severity] = []
|
||||||
|
|
||||||
daca2 = daca2folder
|
daca2 = daca2folder
|
||||||
|
pattern = re.compile(r'.*: (error|warning|style|performance|portability):.* \[([a-zA-Z0-9_\\-]+)\]')
|
||||||
for lib in (False, True):
|
for lib in (False, True):
|
||||||
for a in "0123456789abcdefghijklmnopqrstuvwxyz":
|
for a in "0123456789abcdefghijklmnopqrstuvwxyz":
|
||||||
if lib:
|
if lib:
|
||||||
|
@ -120,7 +121,7 @@ for lib in (False, True):
|
||||||
datestr = ''
|
datestr = ''
|
||||||
|
|
||||||
for line in data.split('\n'):
|
for line in data.split('\n'):
|
||||||
res = re.match(r'.*: (error|warning|style|performance|style|portability):.* \[([a-zA-Z0-9_\\-]+)\]', line)
|
res = pattern.match(line)
|
||||||
if res is None:
|
if res is None:
|
||||||
continue
|
continue
|
||||||
severity = res.group(1)
|
severity = res.group(1)
|
||||||
|
|
|
@ -53,10 +53,10 @@ def doSearch(path,arguments):
|
||||||
|
|
||||||
def summary(path, arguments):
|
def summary(path, arguments):
|
||||||
count = {}
|
count = {}
|
||||||
|
pattern = re.compile(r'.*: (error|warning|style|performance|portability):.*\[([a-zA-Z0-9]+)\]$')
|
||||||
for g in getfiles(path, arguments):
|
for g in getfiles(path, arguments):
|
||||||
for line in readlines(g):
|
for line in readlines(g):
|
||||||
line = trimline(line)
|
res = pattern.match(trimline(line))
|
||||||
res = re.match(r'.*: (error|warning|style|performance|portability):.*\[([a-zA-Z0-9]+)\]$', line)
|
|
||||||
if res is None:
|
if res is None:
|
||||||
continue
|
continue
|
||||||
id = res.group(2)
|
id = res.group(2)
|
||||||
|
|
Loading…
Reference in New Issue