Fix MISRA 58
This commit is contained in:
parent
8846077caa
commit
8755023c1c
|
@ -236,6 +236,8 @@ class Scope:
|
|||
classEndId = None
|
||||
classEnd = None
|
||||
className = None
|
||||
nestedInId = None
|
||||
nestedIn = None
|
||||
type = None
|
||||
|
||||
def __init__(self, element):
|
||||
|
|
|
@ -41,3 +41,10 @@ void misra56() {
|
|||
void misra57() {
|
||||
continue; // 57
|
||||
}
|
||||
|
||||
void misra58() {
|
||||
while (1) {
|
||||
if(x)
|
||||
break; // 58
|
||||
}
|
||||
}
|
||||
|
|
|
@ -409,7 +409,14 @@ def misra57(data):
|
|||
# 58 The break statement shall not be used, except to terminate the cases of a switch statement
|
||||
# STATUS: TODO
|
||||
def misra58(data):
|
||||
return
|
||||
for token in data.tokenlist:
|
||||
if token.str != "break":
|
||||
continue
|
||||
s = token.scope
|
||||
while s and s.type == 'If':
|
||||
s = s.nestedIn
|
||||
if s and s.type in ['While', 'For']:
|
||||
reportError(token, 'style', '58 The break statement shall not be used, except to terminate the cases of a switch statement')
|
||||
|
||||
# 59 The statements forming the body of an if, else, else if, .. shall always be enclosed in braces
|
||||
# STATUS: TODO
|
||||
|
|
Loading…
Reference in New Issue