Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: third_party/WebKit/Tools/Scripts/webkitpy/style/checkers/cpp.py

Issue 2136793002: Remove all unused variables. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 # -*- coding: utf-8 -*- 1 # -*- coding: utf-8 -*-
2 # 2 #
3 # Copyright (C) 2009, 2010, 2012 Google Inc. All rights reserved. 3 # Copyright (C) 2009, 2010, 2012 Google Inc. All rights reserved.
4 # Copyright (C) 2009 Torch Mobile Inc. 4 # Copyright (C) 2009 Torch Mobile Inc.
5 # Copyright (C) 2009 Apple Inc. All rights reserved. 5 # Copyright (C) 2009 Apple Inc. All rights reserved.
6 # Copyright (C) 2010 Chris Jerdonek (cjerdonek@webkit.org) 6 # Copyright (C) 2010 Chris Jerdonek (cjerdonek@webkit.org)
7 # 7 #
8 # Redistribution and use in source and binary forms, with or without 8 # Redistribution and use in source and binary forms, with or without
9 # modification, are permitted provided that the following conditions are 9 # modification, are permitted provided that the following conditions are
10 # met: 10 # met:
(...skipping 2778 matching lines...) Expand 10 before | Expand all | Expand 10 after
2789 know_whether_using_braces = True 2789 know_whether_using_braces = True
2790 using_braces = current_arm_uses_brace 2790 using_braces = current_arm_uses_brace
2791 2791
2792 if using_braces: 2792 if using_braces:
2793 # Skip over the entire arm. 2793 # Skip over the entire arm.
2794 current_pos = close_expression(lines, current_pos) 2794 current_pos = close_expression(lines, current_pos)
2795 if current_pos.column < 0: 2795 if current_pos.column < 0:
2796 return 2796 return
2797 else: 2797 else:
2798 # Skip over the current expression. 2798 # Skip over the current expression.
2799 current_line_number = current_pos.row
2800 current_pos = _find_in_lines(r';', lines, current_pos, None) 2799 current_pos = _find_in_lines(r';', lines, current_pos, None)
2801 if not current_pos: 2800 if not current_pos:
2802 return 2801 return
2803 # If the end of the expression is beyond the line just after 2802 # If the end of the expression is beyond the line just after
2804 # the close parenthesis or control clause, we've found a 2803 # the close parenthesis or control clause, we've found a
2805 # single-expression arm that spans multiple lines. (We don't 2804 # single-expression arm that spans multiple lines. (We don't
2806 # fire this error for expressions ending on the same line; that 2805 # fire this error for expressions ending on the same line; that
2807 # is a different error, handled elsewhere.) 2806 # is a different error, handled elsewhere.)
2808 if current_pos.row > 1 + end_line_of_conditional: 2807 if current_pos.row > 1 + end_line_of_conditional:
2809 error(current_pos.row, 'whitespace/braces', 4, 2808 error(current_pos.row, 'whitespace/braces', 4,
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
2887 # Look for "override" or "final" after the parameter list 2886 # Look for "override" or "final" after the parameter list
2888 # (possibly on the next few lines). 2887 # (possibly on the next few lines).
2889 for i in xrange(end_position.row, min(end_position.row + 3, clean_lines.num_ lines())): 2888 for i in xrange(end_position.row, min(end_position.row + 3, clean_lines.num_ lines())):
2890 line = clean_lines.elided[i][end_position.column:] 2889 line = clean_lines.elided[i][end_position.column:]
2891 override_or_final = search(r'\b(override|final)\b', line) 2890 override_or_final = search(r'\b(override|final)\b', line)
2892 if override_or_final: 2891 if override_or_final:
2893 error(linenum, 'readability/inheritance', 4, 2892 error(linenum, 'readability/inheritance', 4,
2894 ('"virtual" is redundant since function is ' 2893 ('"virtual" is redundant since function is '
2895 'already declared as "%s"' % override_or_final.group(1))) 2894 'already declared as "%s"' % override_or_final.group(1)))
2896 2895
2897 # Set end_col to check whole lines after we are done with the
2898 # first line.
2899 end_col = 0
2900 if search(r'[^\w]\s*$', line): 2896 if search(r'[^\w]\s*$', line):
2901 break 2897 break
2902 2898
2903 2899
2904 def check_redundant_override(clean_lines, linenum, error): 2900 def check_redundant_override(clean_lines, linenum, error):
2905 """Checks if line contains a redundant "override" virt-specifier. 2901 """Checks if line contains a redundant "override" virt-specifier.
2906 2902
2907 Args: 2903 Args:
2908 clean_lines: A CleansedLines instance containing the file. 2904 clean_lines: A CleansedLines instance containing the file.
2909 linenum: The number of the line to check. 2905 linenum: The number of the line to check.
(...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after
3590 3586
3591 Args: 3587 Args:
3592 filename: The name of the header file in which to check for toFoo definiti on. 3588 filename: The name of the header file in which to check for toFoo definiti on.
3593 pattern: The conversion function pattern to grep for. 3589 pattern: The conversion function pattern to grep for.
3594 error: The function to call with any errors found. 3590 error: The function to call with any errors found.
3595 """ 3591 """
3596 def get_abs_filepath(filename): 3592 def get_abs_filepath(filename):
3597 fileSystem = FileSystem() 3593 fileSystem = FileSystem()
3598 base_dir = fileSystem.path_to_module(FileSystem.__module__).split('WebKi t', 1)[0] 3594 base_dir = fileSystem.path_to_module(FileSystem.__module__).split('WebKi t', 1)[0]
3599 base_dir = ''.join((base_dir, 'WebKit/Source')) 3595 base_dir = ''.join((base_dir, 'WebKit/Source'))
3600 for root, dirs, names in os.walk(base_dir): 3596 for root, _, names in os.walk(base_dir):
3601 if filename in names: 3597 if filename in names:
3602 return os.path.join(root, filename) 3598 return os.path.join(root, filename)
3603 return None 3599 return None
3604 3600
3605 def grep(lines, pattern, error): 3601 def grep(lines, pattern, error):
3606 matches = [] 3602 matches = []
3607 function_state = None 3603 function_state = None
3608 for line_number in xrange(lines.num_lines()): 3604 for line_number in xrange(lines.num_lines()):
3609 line = (lines.elided[line_number]).rstrip() 3605 line = (lines.elided[line_number]).rstrip()
3610 try: 3606 try:
(...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after
4213 4209
4214 def check(self, lines): 4210 def check(self, lines):
4215 _process_lines(self.file_path, self.file_extension, lines, 4211 _process_lines(self.file_path, self.file_extension, lines,
4216 self.handle_style_error, self.min_confidence) 4212 self.handle_style_error, self.min_confidence)
4217 4213
4218 4214
4219 # FIXME: Remove this function (requires refactoring unit tests). 4215 # FIXME: Remove this function (requires refactoring unit tests).
4220 def process_file_data(filename, file_extension, lines, error, min_confidence, fs =None): 4216 def process_file_data(filename, file_extension, lines, error, min_confidence, fs =None):
4221 checker = CppChecker(filename, file_extension, error, min_confidence, fs) 4217 checker = CppChecker(filename, file_extension, error, min_confidence, fs)
4222 checker.check(lines) 4218 checker.check(lines)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698