MCPcopy Create free account
hub / github.com/4paradigm/OpenMLDB / GetPreviousNonBlankLine

Function GetPreviousNonBlankLine

steps/cpplint.py:4222–4242  ·  view source on GitHub ↗

Return the most recent non-blank line and its line number. Args: clean_lines: A CleansedLines instance containing the file contents. linenum: The number of the line to check. Returns: A tuple with two elements. The first element is the contents of the last non-blank line befor

(clean_lines, linenum)

Source from the content-addressed store, hash-verified

4220
4221
4222def GetPreviousNonBlankLine(clean_lines, linenum):
4223 """Return the most recent non-blank line and its line number.
4224
4225 Args:
4226 clean_lines: A CleansedLines instance containing the file contents.
4227 linenum: The number of the line to check.
4228
4229 Returns:
4230 A tuple with two elements. The first element is the contents of the last
4231 non-blank line before the current line, or the empty string if this is the
4232 first non-blank line. The second is the line number of that line, or -1
4233 if this is the first non-blank line.
4234 """
4235
4236 prevlinenum = linenum - 1
4237 while prevlinenum >= 0:
4238 prevline = clean_lines.elided[prevlinenum]
4239 if not IsBlankLine(prevline): # if not a blank line...
4240 return (prevline, prevlinenum)
4241 prevlinenum -= 1
4242 return ('', -1)
4243
4244
4245def CheckBraces(filename, clean_lines, linenum, error):

Callers 3

CheckBracesFunction · 0.85
CheckTrailingSemicolonFunction · 0.85
CheckStyleFunction · 0.85

Calls 1

IsBlankLineFunction · 0.85

Tested by

no test coverage detected