MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / misra_20_9

Method misra_20_9

addons/misra.py:3810–3828  ·  view source on GitHub ↗
(self, cfg)

Source from the content-addressed store, hash-verified

3808 self.reportError(cond, 20, 8)
3809
3810 def misra_20_9(self, cfg):
3811 for cond in cfg.preprocessor_if_conditions:
3812 if cond.E is None:
3813 continue
3814 defined = []
3815 for directive in cfg.directives:
3816 if directive.file == cond.file and directive.linenr == cond.linenr:
3817 for name in re.findall(r'[^_a-zA-Z0-9]defined[ ]*\([ ]*([_a-zA-Z0-9]+)[ ]*\)', directive.str):
3818 defined.append(name)
3819 for name in re.findall(r'[^_a-zA-Z0-9]defined[ ]*([_a-zA-Z0-9]+)', directive.str):
3820 defined.append(name)
3821 break
3822 for s in cond.E.split(' '):
3823 if (s[0] >= 'A' and s[0] <= 'Z') or (s[0] >= 'a' and s[0] <= 'z'):
3824 if isKeyword(s, cfg.standards.c):
3825 continue
3826 if s in defined:
3827 continue
3828 self.reportError(cond, 20, 9)
3829
3830 def misra_20_10(self, data):
3831 for directive in data.directives:

Callers

nothing calls this directly

Calls 2

reportErrorMethod · 0.95
isKeywordFunction · 0.70

Tested by

no test coverage detected