Home | History | Annotate | Download | only in tools

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.
725 ' %s has %d non-comment lines'
726 ' (error triggered by exceeding %d lines).' % (
933 def FindNextMultiLineCommentStart(lines, lineix):
935 while lineix < len(lines):
936 if lines[lineix].strip().startswith('/*'):
938 if lines[lineix].strip().find('*/', 2) < 0:
941 return len(lines)
944 def FindNextMultiLineCommentEnd(lines, lineix):
946 while lineix < len(lines):
947 if lines[lineix].strip().endswith('*/'):
950 return len(lines)
953 def RemoveMultiLineCommentsFromRange(lines, begin, end):
954 """Clears a range of lines for multi-line comments."""
955 # Having // dummy comments makes the lines non-empty, so we will not get
958 lines[i] = '// dummy'
961 def RemoveMultiLineComments(filename, lines, error):
962 """Removes multiline (c-style) comments from lines."""
964 while lineix < len(lines):
965 lineix_begin = FindNextMultiLineCommentStart(lines, lineix)
966 if lineix_begin >= len(lines):
968 lineix_end = FindNextMultiLineCommentEnd(lines, lineix_begin)
969 if lineix_end >= len(lines):
973 RemoveMultiLineCommentsFromRange(lines, lineix_begin, lineix_end + 1)
994 """Holds 3 copies of all lines with different preprocessing applied to them.
996 1) elided member contains lines without strings and comments,
997 2) lines member contains lines without comments, and
998 3) raw_lines member contains all the lines without processing.
1002 def __init__(self, lines):
1004 self.lines = []
1005 self.raw_lines = lines
1006 self.num_lines = len(lines)
1007 for linenum in range(len(lines)):
1008 self.lines.append(CleanseComments(lines[linenum]))
1009 elided = self._CollapseStrings(lines[linenum])
1013 """Returns the number of lines represented."""
1064 If lines[linenum][pos] points to a '(' or '{' or '[', finds the
1074 (line, len(lines), -1) if we never find a close. Note we ignore
1105 def CheckForCopyright(filename, lines, error):
1110 for line in xrange(1, min(len(lines), 11)):
1111 if re.search(r'Copyright', lines[line], re.I): break
1142 def CheckForHeaderGuard(filename, lines, error):
1150 lines: An array of strings, each representing a line of the file.
1161 for linenum, line in enumerate(lines):
1195 ParseNolintSuppressions(filename, lines[ifndef_linenum], ifndef_linenum,
1211 ParseNolintSuppressions(filename, lines[endif_linenum], endif_linenum,
1217 def CheckForUnicodeReplacementCharacters(filename, lines, error):
1227 lines: An array of strings, each representing a line of the file.
1230 for linenum, line in enumerate(lines):
1236 def CheckForNewlineAtEOF(filename, lines, error):
1241 lines: An array of strings, each representing a line of the file.
1245 # The array lines() was created by adding two newlines to the
1248 # last-but-two element of lines() exists and is empty.
1249 if len(lines) < 3 or lines[-2]:
1250 error(filename, len(lines) - 2, 'whitespace/ending_newline', 5,
1260 lines, as long as a line continuation character (backslash)
1446 # Check how many lines is enclosed in this namespace. Don't issue
1448 # lines. However, do apply checks if there is already an end of
1550 to #endif. We still perform lint checks on these lines, but
1742 Call this when all lines in a file have been processed.
1787 line = clean_lines.lines[linenum]
1961 Blank/comment lines are not counted so as to avoid encouraging the removal
1969 function_state: Current function name and lines in body so far.
1972 lines = clean_lines.lines
1973 line = lines[linenum]
1992 start_line = lines[start_linenum]
2016 function_state.Count() # Count non-blank/non-comment lines.
2123 # it's probably a few lines later if we look for it, so just
2146 # Exhausted all remaining lines and still no matching angle bracket.
2205 # Exhausted all earlier lines and still no matching angle bracket.
2216 after public/protected/private, don't have too many blank lines in a row.
2232 # blank lines at the end of a function (ie, right before a line like '}'
2282 # Ignore blank lines at the end of a block in a long if-else
2321 # but some lines are exceptions -- e.g. if they're big
2344 # many lines (not that this is behavior that I approve of...)
2356 # check non-include lines for spacing around < and >.
2511 # Skip checks if the class is small, where small means 25 lines or less.
2512 # 25 lines seems like a good cutoff since that's the usual height of
2526 matched = Match(r'\s*(public|protected|private):', clean_lines.lines[linenum])
2536 prev_line = clean_lines.lines[linenum - 1]
2546 if Search(r'\{\s*$', clean_lines.lines[i]):
2611 # However, we have to worry about "else if" that spans multiple lines!
2629 'Else clause should never be on same line as else (use 2 lines)')
2665 # do-while-loops, since those lines should start with closing brace.
2759 # Avoid preprocessor lines
2870 # #include lines and header guards can be long, since there's no clean way to
2884 'Lines should very rarely be longer than 100 characters')
2887 'Lines should be <= 80 characters long')
2890 # for loops are allowed two ;'s (and may run over two lines).
3029 """Check rules that are applicable to #include lines.
3031 Strings on #include lines are NOT removed from elided line, to make
3033 applicable to #include lines in CheckLanguage must be put here.
3044 line = clean_lines.lines[linenum]
3100 Given a string of lines and a regular expression string, retrieve all the text
3109 text: The lines to extract text. Its comments and strings must be elided.
3110 It can be single line and can span multiple lines.
3180 # next lines, for more effective checking of code that may span more than one
3240 # Try a bit harder to catch gmock lines: the only place where
3244 # multiple lines (for example http://go/hrfhr ), so we only need
3453 # macros are typically OK, so we allow use of "namespace {" on lines
3714 if not '<' in line: # Reduces the cpu time usage by skipping lines.
3758 # All the lines have been processed, report the errors found.
3804 function_state: A _FunctionState instance which counts function lines, etc.
3831 def ProcessFileData(filename, file_extension, lines, error,
3838 lines: An array of strings, each representing a line of the file, with the
3846 lines = (['// marker so line numbers and indices both start at 1'] + lines +
3855 CheckForCopyright(filename, lines, error)
3858 CheckForHeaderGuard(filename, lines, error)
3860 RemoveMultiLineComments(filename, lines, error)
3861 clean_lines = CleansedLines(lines)
3871 # lines rather than "cleaned" lines.
3872 CheckForUnicodeReplacementCharacters(filename, lines, error)
3874 CheckForNewlineAtEOF(filename, lines, error)
3895 # (which codecs doesn't support anyway), so the resulting lines do
3904 lines = codecs.StreamReaderWriter(sys.stdin,
3909 lines = codecs.open(filename, 'r', 'utf8', 'replace').read().split('\n')
3913 for linenum in range(len(lines)):
3914 if lines[linenum].endswith('\r'):
3915 lines[linenum] = lines[linenum].rstrip('\r')
3932 ProcessFileData(filename, file_extension, lines, Error,
3936 # several lines.