MCPcopy Create free account
hub / github.com/dmtcp/dmtcp / Check

Method Check

util/cpplint.py:1033–1059  ·  view source on GitHub ↗

Report if too many lines in function body. Args: error: The function to call with any errors found. filename: The name of the current file. linenum: The number of the line to check.

(self, error, filename, linenum)

Source from the content-addressed store, hash-verified

1031 self.lines_in_function += 1
1032
1033 def Check(self, error, filename, linenum):
1034 """Report if too many lines in function body.
1035
1036 Args:
1037 error: The function to call with any errors found.
1038 filename: The name of the current file.
1039 linenum: The number of the line to check.
1040 """
1041 if not self.in_a_function:
1042 return
1043
1044 if Match(r'T(EST|est)', self.current_function):
1045 base_trigger = self._TEST_TRIGGER
1046 else:
1047 base_trigger = self._NORMAL_TRIGGER
1048 trigger = base_trigger * 2**_VerboseLevel()
1049
1050 if self.lines_in_function > trigger:
1051 error_level = int(math.log(self.lines_in_function / base_trigger, 2))
1052 # 50 => 0, 100 => 1, 200 => 2, 400 => 3, 800 => 4, 1600 => 5, ...
1053 if error_level > 5:
1054 error_level = 5
1055 error(filename, linenum, 'readability/fn_size', error_level,
1056 'Small and focused functions are preferred:'
1057 ' %s has %d non-comment lines'
1058 ' (error triggered by exceeding %d lines).' % (
1059 self.current_function, self.lines_in_function, trigger))
1060
1061 def End(self):
1062 """Stop analyzing function body."""

Callers 1

CheckForFunctionLengthsFunction · 0.80

Calls 3

MatchFunction · 0.85
_VerboseLevelFunction · 0.85
errorFunction · 0.85

Tested by

no test coverage detected