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

Method misra_2_7

addons/misra.py:1772–1805  ·  view source on GitHub ↗
(self, data)

Source from the content-addressed store, hash-verified

1770 cppcheckdata.reportSummary(dumpfile, 'MisraMacro', list(unused_macro.values()))
1771
1772 def misra_2_7(self, data):
1773 for func in data.functions:
1774 # Skip function with no parameter
1775 if len(func.argument) == 0:
1776 continue
1777 # Setup list of function parameters
1778 func_param_list = []
1779 for arg in func.argument:
1780 func_arg = func.argument[arg]
1781 if func_arg.typeStartToken and func_arg.typeStartToken.str == '...':
1782 continue
1783 func_param_list.append(func_arg)
1784 # Search for scope of current function
1785 for scope in data.scopes:
1786 if (scope.type == "Function") and (scope.function == func):
1787 # Search function body: remove referenced function parameter from list
1788 token = scope.bodyStart
1789 while token.next is not None and token != scope.bodyEnd and len(func_param_list) > 0:
1790 if token.variable is not None and token.variable in func_param_list:
1791 func_param_list.remove(token.variable)
1792 token = token.next
1793 # Emit a warning for each unused variable, but no more that one warning per line
1794 reported_linenrs = set()
1795 for func_param in func_param_list:
1796 if func_param.nameToken:
1797 linenr = func_param.nameToken
1798 if linenr not in reported_linenrs:
1799 self.reportError(func_param.nameToken, 2, 7)
1800 reported_linenrs.add(linenr)
1801 else:
1802 linenr = func.tokenDef.linenr
1803 if linenr not in reported_linenrs:
1804 self.reportError(func.tokenDef, 2, 7)
1805 reported_linenrs.add(linenr)
1806
1807 def misra_3_1(self, rawTokens):
1808 for token in rawTokens:

Callers

nothing calls this directly

Calls 3

reportErrorMethod · 0.95
setFunction · 0.85
addMethod · 0.45

Tested by

no test coverage detected