You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by bb...@apache.org on 2018/05/15 08:20:16 UTC

[2/3] mesos git commit: Updated cpplint from upstream.

Updated cpplint from upstream.

This patch updates the bundled cpplint to upstream 'e8ffd7ce6'. We
also update the patch file to reflect changes; we include the changes
made in '7b1ab032' which where not included in the patch.

Review: https://reviews.apache.org/r/64610/


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/7454420c
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/7454420c
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/7454420c

Branch: refs/heads/master
Commit: 7454420c05994d6f57c7001cdbc9e20863ed2981
Parents: 4485641
Author: Benjamin Bannier <be...@mesosphere.io>
Authored: Tue May 15 10:00:00 2018 +0200
Committer: Benjamin Bannier <bb...@apache.org>
Committed: Tue May 15 10:06:26 2018 +0200

----------------------------------------------------------------------
 support/cpplint.patch |  118 +-
 support/cpplint.py    | 3393 +++++++++++++++++++++++++++++++-------------
 2 files changed, 2503 insertions(+), 1008 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/7454420c/support/cpplint.patch
----------------------------------------------------------------------
diff --git a/support/cpplint.patch b/support/cpplint.patch
index 1b4d4ee..c29454d 100644
--- a/support/cpplint.patch
+++ b/support/cpplint.patch
@@ -1,32 +1,51 @@
 diff --git a/support/cpplint.py b/support/cpplint.py
-index 2ad644e..5c5fd99 100644
+index 53dbe81..7a020a4 100644
 --- a/support/cpplint.py
 +++ b/support/cpplint.py
-@@ -29,6 +29,10 @@
+@@ -28,6 +28,12 @@
+ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
- # Modified by Adam B (adam@mesosphere.io) to handle hpp files.
+ 
++# Modified by Adam B (adam@mesosphere.io) to handle hpp files.
 +# Modified by Avinash S (avinash@mesosphere.io) to check for at least
 +# a __single__ space in comments is required for hpp and cpp files.
 +# Modified by Tomek J (janiszt@gmail.com) to check for NULL usage.
 +
-
++
  """Does google-lint on c++ files.
-
-@@ -153,6 +157,7 @@ _ERROR_CATEGORIES = [
-   'build/include_order',
-   'build/include_what_you_use',
-   'build/namespaces',
-+  'build/nullptr',
-   'build/printf_format',
-   'build/storage_class',
-   'legal/copyright',
-@@ -1777,16 +1782,16 @@ class _NamespaceInfo(_BlockInfo):
+ 
+ The goal of this script is to identify places in the code that *may*
+@@ -40,6 +46,7 @@ In particular, we can get very confused by /* and // inside strings!
+ We do a small hack, which is to ignore //'s with "'s after them on the
+ same line, but it is far from perfect (in either direction).
+ """
++# pylint: skip-file
+ 
+ import codecs
+ import copy
+@@ -210,6 +217,7 @@ _ERROR_CATEGORIES = [
+     'build/include_order',
+     'build/include_what_you_use',
+     'build/namespaces',
++    'build/nullptr',
+     'build/printf_format',
+     'build/storage_class',
+     'legal/copyright',
+@@ -552,7 +560,7 @@ _line_length = 80
+ 
+ # The allowed extensions for file names
+ # This is set by --extensions flag.
+-_valid_extensions = set(['cc', 'h', 'cpp', 'cu', 'cuh'])
++_valid_extensions = set(['cc', 'h', 'cpp', 'cu', 'cuh', 'hpp'])
+ 
+ # Treat all headers starting with 'h' equally: .h, .hpp, .hxx etc.
+ # This is set by --headers flag.
+@@ -2364,14 +2372,14 @@ class _NamespaceInfo(_BlockInfo):
      if self.name:
        # Named namespace
-       if not Match((r'};*\s*(//|/\*).*\bnamespace\s+' + re.escape(self.name) +
--                    r'[\*/\.\\\s]*$'),
-+                    r'[\*/\.\\\s]* {$'),
+       if not Match((r'^\s*};*\s*(//|/\*).*\bnamespace\s+' +
+-                    re.escape(self.name) + r'[\*/\.\\\s]*$'),
++                    re.escape(self.name) + r'[\*/\.\\\s]* {$'),
                     line):
          error(filename, linenum, 'readability/namespace', 5,
 -              'Namespace should be terminated with "// namespace %s"' %
@@ -34,18 +53,24 @@ index 2ad644e..5c5fd99 100644
                self.name)
      else:
        # Anonymous namespace
--      if not Match(r'};*\s*(//|/\*).*\bnamespace[\*/\.\\\s]*$', line):
-+      if not Match(r'};*\s*(//|/\*).*\bnamespace[\*/\.\\\s]* {$', line):
-         error(filename, linenum, 'readability/namespace', 5,
--              'Namespace should be terminated with "// namespace"')
-+              'Namespace should be terminated with "// namespace {"')
-
-
+-      if not Match(r'^\s*};*\s*(//|/\*).*\bnamespace[\*/\.\\\s]*$', line):
++      if not Match(r'^\s*};*\s*(//|/\*).*\bnamespace[\*/\.\\\s]* {$', line):
+         # If "// namespace anonymous" or "// anonymous namespace (more text)",
+         # mention "// anonymous namespace" as an acceptable form
+         if Match(r'^\s*}.*\b(namespace anonymous|anonymous namespace)\b', line):
+@@ -2380,7 +2388,7 @@ class _NamespaceInfo(_BlockInfo):
+                 ' or "// anonymous namespace"')
+         else:
+           error(filename, linenum, 'readability/namespace', 5,
+-                'Anonymous namespace should be terminated with "// namespace"')
++                'Anonymous namespace should be terminated with "// namespace {"')
+ 
+ 
  class _PreprocessorInfo(object):
-@@ -1995,11 +2000,9 @@ class _NestingState(object):
+@@ -2682,11 +2690,9 @@ class NestingState(object):
        if access_match:
          classinfo.access = access_match.group(2)
-
+ 
 -        # Check that access keywords are indented +1 space.  Skip this
 -        # check if the keywords are not preceded by whitespaces.
 +        # Check that access keywords are not indented.
@@ -56,20 +81,20 @@ index 2ad644e..5c5fd99 100644
            if classinfo.is_struct:
              parent = 'struct ' + classinfo.name
            else:
-@@ -2008,7 +2011,7 @@ class _NestingState(object):
+@@ -2695,7 +2701,7 @@ class NestingState(object):
            if access_match.group(3):
              slots = access_match.group(3)
            error(filename, linenum, 'whitespace/indent', 3,
 -                '%s%s: should be indented +1 space inside %s' % (
 +                '%s%s: should not be indented inside %s' % (
                      access_match.group(2), slots, parent))
-
+ 
      # Consume braces or semicolons from what's left of the line
-@@ -2637,13 +2640,10 @@ def CheckSpacing(filename, clean_lines, linenum, nesting_state, error):
-     if (line.count('"', 0, commentpos) -
-         line.count('\\"', 0, commentpos)) % 2 == 0:   # not in quotes
+@@ -3123,13 +3129,10 @@ def CheckComment(line, filename, linenum, next_line_start, error):
+     # Check if the // may be in quotes.  If so, ignore it
+     if re.sub(r'\\.', '', line[0:commentpos]).count('"') % 2 == 0:
        # Allow one space for new scopes, two spaces otherwise:
--      if (not Match(r'^\s*{ //', line) and
+-      if (not (Match(r'^.*{ *//', line) and next_line_start == commentpos) and
 -          ((commentpos >= 1 and
 -            line[commentpos-1] not in string.whitespace) or
 -           (commentpos >= 2 and
@@ -79,31 +104,26 @@ index 2ad644e..5c5fd99 100644
          error(filename, linenum, 'whitespace/comments', 2,
 -              'At least two spaces is best between code and comments')
 +              'At least a single space is required between code and comments')
-       # There should always be a space between the // and the comment
-       commentend = commentpos + 2
-       if commentend < len(line) and not line[commentend] == ' ':
-@@ -2694,11 +2694,11 @@ def CheckSpacing(filename, clean_lines, linenum, nesting_state, error):
-           'Missing spaces around %s' % match.group(1))
-   # We allow no-spaces around << when used like this: 10<<20, but
-   # not otherwise (particularly, not when used as streams)
--  # Also ignore using ns::operator<<;
-+  # Also ignore 'operator<<'.
-   match = Search(r'(operator|\S)(?:L|UL|ULL|l|ul|ull)?<<(\S)', line)
-   if (match and
-       not (match.group(1).isdigit() and match.group(2).isdigit()) and
+ 
+       # Checks for common mistakes in TODO comments.
+       comment = line[commentpos:]
+@@ -3377,7 +3380,7 @@ def CheckOperatorSpacing(filename, clean_lines, linenum, error):
+   # those tend to be macros that deal with operators.
+   match = Search(r'(operator|[^\s(<])(?:L|UL|LL|ULL|l|ul|ll|ull)?<<([^\s,=<])', line)
+   if (match and not (match.group(1).isdigit() and match.group(2).isdigit()) and
 -      not (match.group(1) == 'operator' and match.group(2) == ';')):
 +      not (match.group(1) == 'operator')):
      error(filename, linenum, 'whitespace/operators', 3,
            'Missing spaces around <<')
-   elif not Match(r'#.*include', line):
-@@ -3441,6 +3441,10 @@ def CheckStyle(filename, clean_lines, linenum, file_extension, nesting_state,
+ 
+@@ -4394,6 +4397,10 @@ def CheckStyle(filename, clean_lines, linenum, file_extension, nesting_state,
      error(filename, linenum, 'whitespace/newline', 0,
            'More than one command on the same line')
-
+ 
 +  if re.search(r'\bNULL\b', cleansed_line):
 +    error(filename, linenum, 'build/nullptr', 1,
 +          'NULL found; better to use nullptr')
 +
    # Some more style checks
    CheckBraces(filename, clean_lines, linenum, error)
-   CheckEmptyBlockBody(filename, clean_lines, linenum, error)
+   CheckTrailingSemicolon(filename, clean_lines, linenum, error)