Misra: Refactoring with simpleMatch
This commit is contained in:
parent
e840d67f03
commit
33df403727
|
@ -407,22 +407,11 @@ def misra_15_6(rawTokens):
|
||||||
|
|
||||||
def misra_15_7(data):
|
def misra_15_7(data):
|
||||||
for token in data.tokenlist:
|
for token in data.tokenlist:
|
||||||
if token.str != 'if':
|
if not simpleMatch(token, 'if ('):
|
||||||
continue
|
continue
|
||||||
lpar = token.next
|
if not simpleMatch(token.next.link, ') {'):
|
||||||
if not lpar or lpar.str != '(':
|
|
||||||
continue
|
continue
|
||||||
rpar = lpar.link
|
if not simpleMatch(token.next.link.next.link, '} else'):
|
||||||
if not rpar or rpar.str != ')':
|
|
||||||
continue
|
|
||||||
brace1 = rpar.next
|
|
||||||
if not brace1 or brace1.str != '{':
|
|
||||||
continue
|
|
||||||
brace2 = brace1.link
|
|
||||||
if not brace2 or brace2.str != '}':
|
|
||||||
continue
|
|
||||||
else_ = brace2.next
|
|
||||||
if not else_ or else_.str != 'else':
|
|
||||||
reportError(token, 15, 7)
|
reportError(token, 15, 7)
|
||||||
|
|
||||||
# TODO add 16.1 rule
|
# TODO add 16.1 rule
|
||||||
|
|
Loading…
Reference in New Issue