Skip to content

Commit c70cbab

Browse files
author
Lukasz A.J. Wrona
committed
Remove linter braces rule
Braces are already checked by clang-format, and this rule doesn't allow me to use initializer list constructors/uniform initialization in unit tests
1 parent 799768e commit c70cbab

File tree

1 file changed

+0
-54
lines changed

1 file changed

+0
-54
lines changed

scripts/cpplint.py

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -3928,60 +3928,6 @@ def CheckBracesSpacing(filename, clean_lines, linenum, nesting_state, error):
39283928
"""
39293929
line = clean_lines.elided[linenum]
39303930

3931-
# Except after an opening paren, or after another opening brace (in case of
3932-
# an initializer list, for instance), you should have spaces before your
3933-
# braces when they are delimiting blocks, classes, namespaces etc.
3934-
# And since you should never have braces at the beginning of a line,
3935-
# this is an easy test. Except that braces used for initialization don't
3936-
# follow the same rule; we often don't want spaces before those.
3937-
match = Match(r'^(.*[^ ({>]){', line)
3938-
3939-
if match:
3940-
# Try a bit harder to check for brace initialization. This
3941-
# happens in one of the following forms:
3942-
# Constructor() : initializer_list_{} { ... }
3943-
# Constructor{}.MemberFunction()
3944-
# Type variable{};
3945-
# FunctionCall(type{}, ...);
3946-
# LastArgument(..., type{});
3947-
# LOG(INFO) << type{} << " ...";
3948-
# map_of_type[{...}] = ...;
3949-
# ternary = expr ? new type{} : nullptr;
3950-
# OuterTemplate<InnerTemplateConstructor<Type>{}>
3951-
#
3952-
# We check for the character following the closing brace, and
3953-
# silence the warning if it's one of those listed above, i.e.
3954-
# "{.;,)<>]:".
3955-
#
3956-
# To account for nested initializer list, we allow any number of
3957-
# closing braces up to "{;,)<". We can't simply silence the
3958-
# warning on first sight of closing brace, because that would
3959-
# cause false negatives for things that are not initializer lists.
3960-
# Silence this: But not this:
3961-
# Outer{ if (...) {
3962-
# Inner{...} if (...){ // Missing space before {
3963-
# }; }
3964-
#
3965-
# There is a false negative with this approach if people inserted
3966-
# spurious semicolons, e.g. "if (cond){};", but we will catch the
3967-
# spurious semicolon with a separate check.
3968-
leading_text = match.group(1)
3969-
(endline, endlinenum, endpos) = CloseExpression(
3970-
clean_lines, linenum, len(match.group(1)))
3971-
trailing_text = ''
3972-
if endpos > -1:
3973-
trailing_text = endline[endpos:]
3974-
for offset in xrange(endlinenum + 1,
3975-
min(endlinenum + 3, clean_lines.NumLines() - 1)):
3976-
trailing_text += clean_lines.elided[offset]
3977-
# We also suppress warnings for `uint64_t{expression}` etc., as the style
3978-
# guide recommends brace initialization for integral types to avoid
3979-
# overflow/truncation.
3980-
if (not Match(r'^[\s}]*[{.;,)<>\]:]', trailing_text)
3981-
and not _IsType(clean_lines, nesting_state, leading_text)):
3982-
error(filename, linenum, 'whitespace/braces', 5,
3983-
'Missing space before {')
3984-
39853931
# You shouldn't have a space before a semicolon at the end of the line.
39863932
# There's a special case for "for" since the style guide allows space before
39873933
# the semicolon there.

0 commit comments

Comments
 (0)