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

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

Issue 2747643002: Remove unused methods in webkitpy cpp style checker and test. (Closed)
Patch Set: Remove empty tearDownClass Created 3 years, 9 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
« no previous file with comments | « no previous file | third_party/WebKit/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1182 matching lines...) Expand 10 before | Expand all | Expand 10 after
1193 # get in the way of brace matching. See the testBuildClass test in 1193 # get in the way of brace matching. See the testBuildClass test in
1194 # cpp_style_unittest.py for an example of this. 1194 # cpp_style_unittest.py for an example of this.
1195 error(self.classinfo_stack[0].line_number, 'build/class', 5, 1195 error(self.classinfo_stack[0].line_number, 'build/class', 5,
1196 'Failed to find complete declaration of class %s' % 1196 'Failed to find complete declaration of class %s' %
1197 self.classinfo_stack[0].name) 1197 self.classinfo_stack[0].name)
1198 1198
1199 1199
1200 class _FileState(object): 1200 class _FileState(object):
1201 1201
1202 def __init__(self, clean_lines, file_extension): 1202 def __init__(self, clean_lines, file_extension):
1203 self._did_inside_namespace_indent_warning = False
1204 self._clean_lines = clean_lines 1203 self._clean_lines = clean_lines
1205 if file_extension in ['m', 'mm']: 1204 if file_extension in ['m', 'mm']:
1206 self._is_objective_c = True 1205 self._is_objective_c = True
1207 self._is_c = False 1206 self._is_c = False
1208 elif file_extension == 'h': 1207 elif file_extension == 'h':
1209 # In the case of header files, it is unknown if the file 1208 # In the case of header files, it is unknown if the file
1210 # is c / objective c or not, so set this value to None and then 1209 # is c / objective c or not, so set this value to None and then
1211 # if it is requested, use heuristics to guess the value. 1210 # if it is requested, use heuristics to guess the value.
1212 self._is_objective_c = None 1211 self._is_objective_c = None
1213 self._is_c = None 1212 self._is_c = None
1214 elif file_extension == 'c': 1213 elif file_extension == 'c':
1215 self._is_c = True 1214 self._is_c = True
1216 self._is_objective_c = False 1215 self._is_objective_c = False
1217 else: 1216 else:
1218 self._is_objective_c = False 1217 self._is_objective_c = False
1219 self._is_c = False 1218 self._is_c = False
1220 1219
1221 def set_did_inside_namespace_indent_warning(self):
1222 self._did_inside_namespace_indent_warning = True
1223
1224 def did_inside_namespace_indent_warning(self):
1225 return self._did_inside_namespace_indent_warning
1226
1227 def is_objective_c(self): 1220 def is_objective_c(self):
1228 if self._is_objective_c is None: 1221 if self._is_objective_c is None:
1229 for line in self._clean_lines.elided: 1222 for line in self._clean_lines.elided:
1230 # Starting with @ or #import seem like the best indications 1223 # Starting with @ or #import seem like the best indications
1231 # that we have an Objective C file. 1224 # that we have an Objective C file.
1232 if line.startswith('@') or line.startswith('#import'): 1225 if line.startswith('@') or line.startswith('#import'):
1233 self._is_objective_c = True 1226 self._is_objective_c = True
1234 break 1227 break
1235 else: 1228 else:
1236 self._is_objective_c = False 1229 self._is_objective_c = False
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after
1816 enum_state: A _EnumState instance which maintains enum declaration state. 1809 enum_state: A _EnumState instance which maintains enum declaration state.
1817 error: The function to call with any errors found. 1810 error: The function to call with any errors found.
1818 """ 1811 """
1819 1812
1820 line = clean_lines.elided[line_number] # Get rid of comments and strings. 1813 line = clean_lines.elided[line_number] # Get rid of comments and strings.
1821 if not enum_state.process_clean_line(line): 1814 if not enum_state.process_clean_line(line):
1822 error(line_number, 'readability/enum_casing', 4, 1815 error(line_number, 'readability/enum_casing', 4,
1823 'enum members should use InterCaps with an initial capital letter. ') 1816 'enum members should use InterCaps with an initial capital letter. ')
1824 1817
1825 1818
1826 def get_initial_spaces_for_line(clean_line):
1827 initial_spaces = 0
1828 while initial_spaces < len(clean_line) and clean_line[initial_spaces] == ' ' :
1829 initial_spaces += 1
1830 return initial_spaces
1831
1832
1833 def check_using_std(clean_lines, line_number, file_state, error): 1819 def check_using_std(clean_lines, line_number, file_state, error):
1834 """Looks for 'using std::foo;' statements which should be replaced with 'usi ng namespace std;'. 1820 """Looks for 'using std::foo;' statements which should be replaced with 'usi ng namespace std;'.
1835 1821
1836 Args: 1822 Args:
1837 clean_lines: A CleansedLines instance containing the file. 1823 clean_lines: A CleansedLines instance containing the file.
1838 line_number: The number of the line to check. 1824 line_number: The number of the line to check.
1839 file_state: A _FileState instance which maintains information about 1825 file_state: A _FileState instance which maintains information about
1840 the state of things in the file. 1826 the state of things in the file.
1841 error: The function to call with any errors found. 1827 error: The function to call with any errors found.
1842 """ 1828 """
(...skipping 1754 matching lines...) Expand 10 before | Expand all | Expand 10 after
3597 3583
3598 def check(self, lines): 3584 def check(self, lines):
3599 _process_lines(self.file_path, self.file_extension, lines, 3585 _process_lines(self.file_path, self.file_extension, lines,
3600 self.handle_style_error, self.min_confidence) 3586 self.handle_style_error, self.min_confidence)
3601 3587
3602 3588
3603 # FIXME: Remove this function (requires refactoring unit tests). 3589 # FIXME: Remove this function (requires refactoring unit tests).
3604 def process_file_data(filename, file_extension, lines, error, min_confidence, fs =None): 3590 def process_file_data(filename, file_extension, lines, error, min_confidence, fs =None):
3605 checker = CppChecker(filename, file_extension, error, min_confidence, fs) 3591 checker = CppChecker(filename, file_extension, error, min_confidence, fs)
3606 checker.check(lines) 3592 checker.check(lines)
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698