I managed to fix the code by adding an extra escape in misra.py. This way we don't try to access s[0] after the cond.E.split
def misra_20_9(self, cfg):
for cond in cfg.preprocessor_if_conditions:
if cond.E is (None or u""):
continue
I found it also strange that misra_20_8 is not flagging this line. bad_define is assinged no value. So how can cond.result evaluate to 0 or 1. (0 in this case)
To get the attention I added some extra condition to set misra_20_8, which is probably not totally correct.
def misra_20_8(self, cfg):
for cond in cfg.preprocessor_if_conditions:
if cond.E is (None or u""):
self.reportError(cond, 20, 8)
if cond.result and cond.result not in (0,1):
self.reportError(cond, 20, 8)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
when you have the following in the code, the misra check crashes in the misra_20_9 check
I managed to fix the code by adding an extra escape in misra.py. This way we don't try to access s[0] after the cond.E.split
I found it also strange that misra_20_8 is not flagging this line. bad_define is assinged no value. So how can cond.result evaluate to 0 or 1. (0 in this case)
To get the attention I added some extra condition to set misra_20_8, which is probably not totally correct.
Feel free to create a PR. I will not do any more active work on misra.py.. but will be happy to review/merge PRs that fix misra.py bugs.
We provide better Misra checking in Cppcheck Premium.