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

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

Issue 609633004: Eliminate style rule about one space after punctuation. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | 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 1924 matching lines...) Expand 10 before | Expand all | Expand 10 after
1935 # comment delimiters like: 1935 # comment delimiters like:
1936 # //---------------------------------------------------------- 1936 # //----------------------------------------------------------
1937 # or they begin with multiple slashes followed by a space: 1937 # or they begin with multiple slashes followed by a space:
1938 # //////// Header comment 1938 # //////// Header comment
1939 matched = (search(r'[=/-]{4,}\s*$', line[commentend:]) 1939 matched = (search(r'[=/-]{4,}\s*$', line[commentend:])
1940 or search(r'^/+ ', line[commentend:])) 1940 or search(r'^/+ ', line[commentend:]))
1941 if not matched: 1941 if not matched:
1942 error(line_number, 'whitespace/comments', 4, 1942 error(line_number, 'whitespace/comments', 4,
1943 'Should have a space between // and comment') 1943 'Should have a space between // and comment')
1944 1944
1945 # There should only be one space after punctuation in a comment.
1946 if search(r'[.!?,;:]\s\s+\w', line[comment_position:]):
1947 error(line_number, 'whitespace/comments', 5,
1948 'Should have only a single space after a punctuation in a comment.')
1949
1950 line = clean_lines.elided[line_number] # get rid of comments and strings 1945 line = clean_lines.elided[line_number] # get rid of comments and strings
1951 1946
1952 # Don't try to do spacing checks for operator methods 1947 # Don't try to do spacing checks for operator methods
1953 line = sub(r'operator(==|!=|<|<<|<=|>=|>>|>|\+=|-=|\*=|/=|%=|&=|\|=|^=|<<=|> >=|/)\(', 'operator\(', line) 1948 line = sub(r'operator(==|!=|<|<<|<=|>=|>>|>|\+=|-=|\*=|/=|%=|&=|\|=|^=|<<=|> >=|/)\(', 'operator\(', line)
1954 # Don't try to do spacing checks for #include or #import statements at 1949 # Don't try to do spacing checks for #include or #import statements at
1955 # minimum because it messes up checks for spacing around / 1950 # minimum because it messes up checks for spacing around /
1956 if match(r'\s*#\s*(?:include|import)', line): 1951 if match(r'\s*#\s*(?:include|import)', line):
1957 return 1952 return
1958 if search(r'[\w.]=[\w.]', line): 1953 if search(r'[\w.]=[\w.]', line):
1959 error(line_number, 'whitespace/operators', 4, 1954 error(line_number, 'whitespace/operators', 4,
(...skipping 2114 matching lines...) Expand 10 before | Expand all | Expand 10 after
4074 4069
4075 def check(self, lines): 4070 def check(self, lines):
4076 _process_lines(self.file_path, self.file_extension, lines, 4071 _process_lines(self.file_path, self.file_extension, lines,
4077 self.handle_style_error, self.min_confidence) 4072 self.handle_style_error, self.min_confidence)
4078 4073
4079 4074
4080 # FIXME: Remove this function (requires refactoring unit tests). 4075 # FIXME: Remove this function (requires refactoring unit tests).
4081 def process_file_data(filename, file_extension, lines, error, min_confidence, fs =None): 4076 def process_file_data(filename, file_extension, lines, error, min_confidence, fs =None):
4082 checker = CppChecker(filename, file_extension, error, min_confidence, fs) 4077 checker = CppChecker(filename, file_extension, error, min_confidence, fs)
4083 checker.check(lines) 4078 checker.check(lines)
OLDNEW
« no previous file with comments | « no previous file | Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698