| OLD | NEW |
| 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 2059 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2070 if search(r'}else', line): | 2070 if search(r'}else', line): |
| 2071 error(line_number, 'whitespace/braces', 5, | 2071 error(line_number, 'whitespace/braces', 5, |
| 2072 'Missing space before else') | 2072 'Missing space before else') |
| 2073 | 2073 |
| 2074 # You shouldn't have spaces before your brackets, except maybe after | 2074 # You shouldn't have spaces before your brackets, except maybe after |
| 2075 # 'delete []' or 'new char * []'. | 2075 # 'delete []' or 'new char * []'. |
| 2076 if search(r'\w\s+\[', line) and not search(r'delete\s+\[', line): | 2076 if search(r'\w\s+\[', line) and not search(r'delete\s+\[', line): |
| 2077 error(line_number, 'whitespace/braces', 5, | 2077 error(line_number, 'whitespace/braces', 5, |
| 2078 'Extra space before [') | 2078 'Extra space before [') |
| 2079 | 2079 |
| 2080 # There should always be a single space in between braces on the same line. | 2080 # There should always be zero or one space in between braces on the same lin
e. |
| 2081 if search(r'\{\}', line): | |
| 2082 error(line_number, 'whitespace/braces', 5, 'Missing space inside { }.') | |
| 2083 if search(r'\{\s\s+\}', line): | 2081 if search(r'\{\s\s+\}', line): |
| 2084 error(line_number, 'whitespace/braces', 5, 'Too many spaces inside { }.'
) | 2082 error(line_number, 'whitespace/braces', 5, 'Too many spaces inside { }.'
) |
| 2085 | 2083 |
| 2086 # You shouldn't have a space before a semicolon at the end of the line. | 2084 # You shouldn't have a space before a semicolon at the end of the line. |
| 2087 # There's a special case for "for" since the style guide allows space before | 2085 # There's a special case for "for" since the style guide allows space before |
| 2088 # the semicolon there. | 2086 # the semicolon there. |
| 2089 if search(r':\s*;\s*$', line): | 2087 if search(r':\s*;\s*$', line): |
| 2090 error(line_number, 'whitespace/semicolon', 5, | 2088 error(line_number, 'whitespace/semicolon', 5, |
| 2091 'Semicolon defining empty statement. Use { } instead.') | 2089 'Semicolon defining empty statement. Use { } instead.') |
| 2092 elif search(r'^\s*;\s*$', line): | 2090 elif search(r'^\s*;\s*$', line): |
| (...skipping 1994 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4087 | 4085 |
| 4088 def check(self, lines): | 4086 def check(self, lines): |
| 4089 _process_lines(self.file_path, self.file_extension, lines, | 4087 _process_lines(self.file_path, self.file_extension, lines, |
| 4090 self.handle_style_error, self.min_confidence) | 4088 self.handle_style_error, self.min_confidence) |
| 4091 | 4089 |
| 4092 | 4090 |
| 4093 # FIXME: Remove this function (requires refactoring unit tests). | 4091 # FIXME: Remove this function (requires refactoring unit tests). |
| 4094 def process_file_data(filename, file_extension, lines, error, min_confidence, fs
=None): | 4092 def process_file_data(filename, file_extension, lines, error, min_confidence, fs
=None): |
| 4095 checker = CppChecker(filename, file_extension, error, min_confidence, fs) | 4093 checker = CppChecker(filename, file_extension, error, min_confidence, fs) |
| 4096 checker.check(lines) | 4094 checker.check(lines) |
| OLD | NEW |