Add cpplint check for redundant empty line(s)
Change-Id: I7a2d99bd814c0d1048781fa0d5cb53992425f0ed
diff --git a/cpplint.py b/cpplint.py
index 342c5da..40003ef 100755
--- a/cpplint.py
+++ b/cpplint.py
@@ -3024,6 +3024,17 @@
# reason. This includes the first line after a block is opened, and
# blank lines at the end of a function (ie, right before a line like '}'
#
+ # Check if there is an empty line at the beginning or more than one
+ # consecutive empty lines.
+ if IsBlankLine(line):
+ if linenum == 1 and clean_lines.NumLines() > 2:
+ error(filename, linenum, 'whitespace/blank_line', 2,
+ 'Redundant blank line at file beginning.')
+ if (linenum > 1 and IsBlankLine(raw[linenum - 1]) and
+ not IsBlankLine(raw[linenum - 2])):
+ error(filename, linenum, 'whitespace/blank_line', 2,
+ 'Redundant blank line(s).')
+ #
# Skip all the blank line checks if we are immediately inside a
# namespace body. In other words, don't issue blank line warnings
# for this block: