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

Method misra_4_1

addons/misra.py:1824–1850  ·  view source on GitHub ↗
(self, rawTokens)

Source from the content-addressed store, hash-verified

1822 break
1823
1824 def misra_4_1(self, rawTokens):
1825 for token in rawTokens:
1826 if (token.str[0] != '"') and (token.str[0] != '\''):
1827 continue
1828 if len(token.str) < 3:
1829 continue
1830
1831 delimiter = token.str[0]
1832 symbols = token.str[1:-1]
1833
1834 # No closing delimiter. This will not compile.
1835 if token.str[-1] != delimiter:
1836 continue
1837
1838 if len(symbols) < 2:
1839 continue
1840
1841 if not hasNumericEscapeSequence(symbols):
1842 continue
1843
1844 # String literals that contains one or more escape sequences. All of them should be
1845 # terminated.
1846 for sequence in ['\\' + t for t in symbols.split('\\')][1:]:
1847 if (isHexEscapeSequence(sequence) or isOctalEscapeSequence(sequence) or
1848 isSimpleEscapeSequence(sequence)):
1849 continue
1850 self.reportError(token, 4, 1)
1851
1852 def misra_4_2(self, rawTokens):
1853 for token in rawTokens:

Callers

nothing calls this directly

Calls 5

reportErrorMethod · 0.95
hasNumericEscapeSequenceFunction · 0.85
isHexEscapeSequenceFunction · 0.85
isOctalEscapeSequenceFunction · 0.85
isSimpleEscapeSequenceFunction · 0.85

Tested by

no test coverage detected