MCPcopy Create free account
hub / github.com/tensorflow/tfjs / Check

Method Check

tfjs-backend-wasm/tools/cpplint.py:1059–1085  ·  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

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

Callers 1

CheckForFunctionLengthsFunction · 0.80

Calls 4

MatchFunction · 0.85
_VerboseLevelFunction · 0.85
logMethod · 0.65
intFunction · 0.50

Tested by

no test coverage detected