MCPcopy Create free account
hub / github.com/apache/mesos / Check

Method Check

support/cpplint.py:1064–1090  ·  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

1062 self.lines_in_function += 1
1063
1064 def Check(self, error, filename, linenum):
1065 """Report if too many lines in function body.
1066
1067 Args:
1068 error: The function to call with any errors found.
1069 filename: The name of the current file.
1070 linenum: The number of the line to check.
1071 """
1072 if not self.in_a_function:
1073 return
1074
1075 if Match(r'T(EST|est)', self.current_function):
1076 base_trigger = self._TEST_TRIGGER
1077 else:
1078 base_trigger = self._NORMAL_TRIGGER
1079 trigger = base_trigger * 2**_VerboseLevel()
1080
1081 if self.lines_in_function > trigger:
1082 error_level = int(math.log(self.lines_in_function / base_trigger, 2))
1083 # 50 => 0, 100 => 1, 200 => 2, 400 => 3, 800 => 4, 1600 => 5, ...
1084 if error_level > 5:
1085 error_level = 5
1086 error(filename, linenum, 'readability/fn_size', error_level,
1087 'Small and focused functions are preferred:'
1088 ' %s has %d non-comment lines'
1089 ' (error triggered by exceeding %d lines).' % (
1090 self.current_function, self.lines_in_function, trigger))
1091
1092 def End(self):
1093 """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