Home | History | Annotate | Download | only in checkers

Lines Matching refs:lines

197 def _rfind_in_lines(regex, lines, start_position, not_found_position):
209 current_line = lines[start_position.row][:start_position.column]
219 current_line = lines[current_row]
395 """Converts multiple lines into a single line (with line breaks replaced by a
397 def __init__(self, lines, start_position, end_position):
401 lines: a list of multiple lines to combine into a single line.
402 start_position: offset within lines of where to start the single line.
406 trimmed_lines = lines[start_position.row:end_position.row + 1]
506 """Tracks current function name and the number of lines in its body.
577 """Report if too many lines in function body.
596 ' %s has %d non-comment lines'
597 ' (error triggered by exceeding %d lines).' % (
735 def find_next_multi_line_comment_start(lines, line_index):
737 while line_index < len(lines):
738 if lines[line_index].strip().startswith('/*'):
740 if lines[line_index].strip().find('*/', 2) < 0:
743 return len(lines)
746 def find_next_multi_line_comment_end(lines, line_index):
748 while line_index < len(lines):
749 if lines[line_index].strip().endswith('*/'):
752 return len(lines)
755 def remove_multi_line_comments_from_range(lines, begin, end):
756 """Clears a range of lines for multi-line comments."""
757 # Having // dummy comments makes the lines non-empty, so we will not get
760 lines[i] = '// dummy'
763 def remove_multi_line_comments(lines, error):
764 """Removes multiline (c-style) comments from lines."""
766 while line_index < len(lines):
767 line_index_begin = find_next_multi_line_comment_start(lines, line_index)
768 if line_index_begin >= len(lines):
770 line_index_end = find_next_multi_line_comment_end(lines, line_index_begin)
771 if line_index_end >= len(lines):
775 remove_multi_line_comments_from_range(lines, line_index_begin, line_index_end + 1)
796 """Holds 3 copies of all lines with different preprocessing applied to them.
798 1) elided member contains lines without strings and comments,
799 2) lines member contains lines without comments, and
800 3) raw member contains all the lines without processing.
804 def __init__(self, lines):
806 self.lines = []
807 lines
808 self._num_lines = len(lines)
809 for line_number in range(len(lines)):
810 self.lines.append(cleanse_comments(lines[line_number]))
811 elided = self.collapse_strings(lines[line_number])
815 """Returns the number of lines represented."""
893 def check_for_copyright(lines, error):
898 for line in xrange(1, min(len(lines), 11)):
899 if re.search(r'Copyright', lines[line], re.I):
933 def check_for_header_guard(filename, lines, error):
941 lines: An array of strings, each representing a line of the file.
950 for line_number, line in enumerate(lines):
975 def check_for_unicode_replacement_characters(lines, error):
984 lines: An array of strings, each representing a line of the file.
987 for line_number, line in enumerate(lines):
993 def check_for_new_line_at_eof(lines, error):
997 lines: An array of strings, each representing a line of the file.
1001 # The array lines() was created by adding two newlines to the
1004 # last-but-two element of lines() exists and is empty.
1005 if len(lines) < 3 or lines[-2]:
1006 error(len(lines) - 2, 'whitespace/ending_newline', 5,
1016 lines, as long as a line continuation character (backslash)
1145 Call this when all lines in a file have been processed.
1226 line = clean_lines.lines[line_number]
1432 function_state: Current function name and lines in body so far.
1443 lines = clean_lines.lines
1444 line = lines[line_number]
1448 # Lines ending with a \ indicate a macro. Don't try to check them.
1520 Blank/comment lines are not counted so as to avoid encouraging the removal
1527 function_state: Current function name and lines in body so far.
1530 lines = clean_lines.lines
1531 line = lines[line_number]
1539 function_state.count(line_number) # Count non-blank/non-comment lines.
1579 function_state: Current function name and lines in body so far.
1628 function_state: Current function name and lines in body so far.
1634 lines = clean_lines.lines
1635 line = lines[line_number]
1652 blank lines in a row.
1666 # blank lines at the end of a function (ie, right before a line like '}').
1713 # Also, ignore blank lines at the end of a block in a long if-else
1747 # but some lines are exceptions -- e.g. if they're big
2052 # Skip not only empty lines but also those with preprocessor directives.
2152 'Else clause should never be on same line as else (use 2 lines)')
2204 # Skip not only empty lines but also those with preprocessor directives
2209 # Skip lines with closing braces on the original indentation level.
2213 # these lines and proceed to the line before that.
2221 # As we're going up the lines, the first real statement to encounter
2240 # Skip lines
2466 # for loops are allowed two ;'s (and may run over two lines).
2484 'Boolean expressions that span multiple lines should have their '
2613 """Check rules that are applicable to #include lines.
2615 Strings on #include lines
2617 applicable to #include lines in CheckLanguage must be put here.
2633 line = clean_lines.lines[line_number]
2688 previous_line = clean_lines.lines[previous_line_number]
2693 previous_line = clean_lines.lines[previous_line_number]
2906 # macros are typically OK, so we allow use of "namespace {" on lines
3274 if not '<' in line: # Reduces the cpu time usage by skipping lines.
3317 # All the lines have been processed, report the errors found.
3342 function_state: A _FunctionState instance which counts function lines, etc.
3354 if search(r'\bNOLINT\b', raw_lines[line]): # ignore nolint lines
3367 def _process_lines(filename, file_extension, lines, error, min_confidence):
3373 lines: An array of strings, each representing a line of the file, with the
3377 lines = (['// marker so line numbers and indices both start at 1'] + lines +
3384 check_for_copyright(lines, error)
3387 check_for_header_guard(filename, lines, error)
3389 remove_multi_line_comments(lines, error)
3390 clean_lines = CleansedLines(lines)
3400 # lines rather than "cleaned" lines.
3401 check_for_unicode_replacement_characters(lines, error)
3403 check_for_new_line_at_eof(lines, error)
3408 """Processes C++ lines for checking style."""
3515 def check(self, lines):
3516 _process_lines(self.file_path, self.file_extension, lines,
3521 def process_file_data(filename, file_extension, lines, error, min_confidence, unit_test_config):
3525 checker.check(lines)