Home | History | Annotate | Download | only in scripts

Lines Matching refs:lines

675   """Tracks current function name and the number of lines in its body."""
701 """Report if too many lines in function body.
721 ' %s has %d non-comment lines'
722 ' (error triggered by exceeding %d lines).' % (
926 def FindNextMultiLineCommentStart(lines, lineix):
928 while lineix < len(lines):
929 if lines[lineix].strip().startswith('/*'):
931 if lines[lineix].strip().find('*/', 2) < 0:
934 return len(lines)
937 def FindNextMultiLineCommentEnd(lines, lineix):
939 while lineix < len(lines):
940 if lines[lineix].strip().endswith('*/'):
943 return len(lines)
946 def RemoveMultiLineCommentsFromRange(lines, begin, end):
947 """Clears a range of lines for multi-line comments."""
948 # Having // dummy comments makes the lines non-empty, so we will not get
951 lines[i] = '// dummy'
954 def RemoveMultiLineComments(filename, lines, error):
955 """Removes multiline (c-style) comments from lines."""
957 while lineix < len(lines):
958 lineix_begin = FindNextMultiLineCommentStart(lines, lineix)
959 if lineix_begin >= len(lines):
961 lineix_end = FindNextMultiLineCommentEnd(lines, lineix_begin)
962 if lineix_end >= len(lines):
966 RemoveMultiLineCommentsFromRange(lines, lineix_begin, lineix_end + 1)
987 """Holds 3 copies of all lines with different preprocessing applied to them.
989 1) elided member contains lines without strings and comments,
990 2) lines member contains lines without comments, and
991 3) raw_lines member contains all the lines without processing.
995 def __init__(self, lines):
997 self.lines = []
998 self.raw_lines = lines
999 self.num_lines = len(lines)
1000 for linenum in range(len(lines)):
1001 self.lines.append(CleanseComments(lines[linenum]))
1002 elided = self._CollapseStrings(lines[linenum])
1006 """Returns the number of lines represented."""
1057 If lines[linenum][pos] points to a '(' or '{' or '[', finds the
1067 (line, len(lines), -1) if we never find a close. Note we ignore
1098 def CheckForCopyright(filename, lines, error):
1103 for line in xrange(1, min(len(lines), 11)):
1104 if re.search(r'Copyright', lines[line], re.I): break
1135 def CheckForHeaderGuard(filename, lines, error):
1143 lines: An array of strings, each representing a line of the file.
1154 for linenum, line in enumerate(lines):
1188 ParseNolintSuppressions(filename, lines[ifndef_linenum], ifndef_linenum,
1204 ParseNolintSuppressions(filename, lines[endif_linenum], endif_linenum,
1210 def CheckForUnicodeReplacementCharacters(filename, lines, error):
1220 lines: An array of strings, each representing a line of the file.
1223 for linenum, line in enumerate(lines):
1229 def CheckForNewlineAtEOF(filename, lines, error):
1234 lines: An array of strings, each representing a line of the file.
1238 # The array lines() was created by adding two newlines to the
1241 # last-but-two element of lines() exists and is empty.
1242 if len(lines) < 3 or lines[-2]:
1243 error(filename, len(lines) - 2, 'whitespace/ending_newline', 5,
1253 lines, as long as a line continuation character (backslash)
1439 # Check how many lines is enclosed in this namespace. Don't issue
1441 # lines. However, do apply checks if there is already an end of
1543 to #endif. We still perform lint checks on these lines, but
1735 Call this when all lines in a file have been processed.
1780 line = clean_lines.lines[linenum]
1951 Blank/comment lines are not counted so as to avoid encouraging the removal
1959 function_state: Current function name and lines in body so far.
1962 lines = clean_lines.lines
1963 line = lines[linenum]
1982 start_line = lines[start_linenum]
2006 function_state.Count() # Count non-blank/non-comment lines.
2113 # it's probably a few lines later if we look for it, so just
2136 # Exhausted all remaining lines and still no matching angle bracket.
2195 # Exhausted all earlier lines and still no matching angle bracket.
2206 after public/protected/private, don't have too many blank lines in a row.
2222 # blank lines at the end of a function (ie, right before a line like '}'
2272 # Ignore blank lines at the end of a block in a long if-else
2311 # but some lines are exceptions -- e.g. if they're big
2334 # many lines (not that this is behavior that I approve of...)
2346 # check non-include lines for spacing around < and >.
2501 # Skip checks if the class is small, where small means 25 lines or less.
2502 # 25 lines seems like a good cutoff since that's the usual height of
2516 matched = Match(r'\s*(public|protected|private):', clean_lines.lines[linenum])
2526 prev_line = clean_lines.lines[linenum - 1]
2536 if Search(r'\{\s*$', clean_lines.lines[i]):
2601 # However, we have to worry about "else if" that spans multiple lines!
2619 'Else clause should never be on same line as else (use 2 lines)')
2655 # do-while-loops, since those lines should start with closing brace.
2749 # Avoid preprocessor lines
2860 # #include lines and header guards can be long, since there's no clean way to
2874 'Lines should very rarely be longer than 100 characters')
2877 'Lines should be <= 80 characters long')
2880 # for loops are allowed two ;'s (and may run over two lines).
3019 """Check rules that are applicable to #include lines.
3021 Strings on #include lines are NOT removed from elided line, to make
3023 applicable to #include lines in CheckLanguage must be put here.
3034 line = clean_lines.lines[linenum]
3090 Given a string of lines and a regular expression string, retrieve all the text
3099 text: The lines to extract text. Its comments and strings must be elided.
3100 It can be single line and can span multiple lines.
3170 # next lines, for more effective checking of code that may span more than one
3223 # Try a bit harder to catch gmock lines: the only place where
3227 # multiple lines (for example http://go/hrfhr ), so we only need
3436 # macros are typically OK, so we allow use of "namespace {" on lines
3697 if not '<' in line: # Reduces the cpu time usage by skipping lines.
3741 # All the lines have been processed, report the errors found.
3787 function_state: A _FunctionState instance which counts function lines, etc.
3814 def ProcessFileData(filename, file_extension, lines, error,
3821 lines: An array of strings, each representing a line of the file, with the
3829 lines = (['// marker so line numbers and indices both start at 1'] + lines +
3838 CheckForCopyright(filename, lines, error)
3841 CheckForHeaderGuard(filename, lines, error)
3843 RemoveMultiLineComments(filename, lines, error)
3844 clean_lines = CleansedLines(lines)
3854 # lines rather than "cleaned" lines.
3855 CheckForUnicodeReplacementCharacters(filename, lines, error)
3857 CheckForNewlineAtEOF(filename, lines, error)
3878 # (which codecs doesn't support anyway), so the resulting lines do
3887 lines = codecs.StreamReaderWriter(sys.stdin,
3892 lines = codecs.open(filename, 'r', 'utf8', 'replace').read().split('\n')
3896 for linenum in range(len(lines)):
3897 if lines[linenum].endswith('\r'):
3898 lines[linenum] = lines[linenum].rstrip('\r')
3915 ProcessFileData(filename, file_extension, lines, Error,
3919 # several lines.