MCPcopy Create free account
hub / github.com/alibaba/GraphScope / Check

Method Check

analytical_engine/misc/cpplint.py:1516–1542  ·  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

1514 self.lines_in_function += 1
1515
1516 def Check(self, error, filename, linenum):
1517 """Report if too many lines in function body.
1518
1519 Args:
1520 error: The function to call with any errors found.
1521 filename: The name of the current file.
1522 linenum: The number of the line to check.
1523 """
1524 if not self.in_a_function:
1525 return
1526
1527 if Match(r'T(EST|est)', self.current_function):
1528 base_trigger = self._TEST_TRIGGER
1529 else:
1530 base_trigger = self._NORMAL_TRIGGER
1531 trigger = base_trigger * 2**_VerboseLevel()
1532
1533 if self.lines_in_function > trigger:
1534 error_level = int(math.log(self.lines_in_function / base_trigger, 2))
1535 # 50 => 0, 100 => 1, 200 => 2, 400 => 3, 800 => 4, 1600 => 5, ...
1536 if error_level > 5:
1537 error_level = 5
1538 error(filename, linenum, 'readability/fn_size', error_level,
1539 'Small and focused functions are preferred:'
1540 ' %s has %d non-comment lines'
1541 ' (error triggered by exceeding %d lines).' % (
1542 self.current_function, self.lines_in_function, trigger))
1543
1544 def End(self):
1545 """Stop analyzing function body."""

Callers 1

CheckForFunctionLengthsFunction · 0.80

Calls 3

_VerboseLevelFunction · 0.85
MatchFunction · 0.70
logMethod · 0.45

Tested by

no test coverage detected