You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by mp...@apache.org on 2015/12/03 19:43:17 UTC

[1/3] mesos git commit: Added linter for license headers in some file types.

Repository: mesos
Updated Branches:
  refs/heads/master f7af25085 -> 75aaaacb8


Added linter for license headers in some file types.

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


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

Branch: refs/heads/master
Commit: 1f64cf1f1fa3ddefeab357e794149a88b6a6b6ea
Parents: f7af250
Author: Benjamin Bannier <be...@mesosphere.io>
Authored: Thu Dec 3 13:30:23 2015 -0500
Committer: Michael Park <mp...@apache.org>
Committed: Thu Dec 3 13:30:23 2015 -0500

----------------------------------------------------------------------
 support/mesos-style.py | 119 +++++++++++++++++++++++++++-----------------
 1 file changed, 73 insertions(+), 46 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/1f64cf1f/support/mesos-style.py
----------------------------------------------------------------------
diff --git a/support/mesos-style.py b/support/mesos-style.py
index 66b4569..5ee1759 100755
--- a/support/mesos-style.py
+++ b/support/mesos-style.py
@@ -1,32 +1,12 @@
 #!/usr/bin/env python
 
-# Runs style checker using Google's cpplint.
-# http://google-styleguide.googlecode.com/svn/trunk/cpplint/cpplint.py
+''' Runs checks for mesos style. '''
 
 import os
 import re
 import subprocess
 import sys
 
-# See cpplint.py for full list of rules.
-active_rules = ['build/class',
-                'build/deprecated',
-                'build/endif_comment',
-                'readability/todo',
-                'readability/namespace',
-                'runtime/vlog',
-                'whitespace/blank_line',
-                'whitespace/comma',
-                'whitespace/end_of_line',
-                'whitespace/ending_newline',
-                'whitespace/forcolon',
-                'whitespace/indent',
-                'whitespace/line_length',
-                'whitespace/operators',
-                'whitespace/semicolon',
-                'whitespace/tab',
-                'whitespace/todo']
-
 # Root source paths (will be traversed recursively).
 source_dirs = ['src',
                'include',
@@ -52,24 +32,67 @@ def find_candidates(root_dir):
                 yield path
 
 def run_lint(source_paths):
+    '''
+    Runs cpplint over given files.
+
+    http://google-styleguide.googlecode.com/svn/trunk/cpplint/cpplint.py
+    '''
+
+    # See cpplint.py for full list of rules.
+    active_rules = [
+        'build/class',
+        'build/deprecated',
+        'build/endif_comment',
+        'readability/todo',
+        'readability/namespace',
+        'runtime/vlog',
+        'whitespace/blank_line',
+        'whitespace/comma',
+        'whitespace/end_of_line',
+        'whitespace/ending_newline',
+        'whitespace/forcolon',
+        'whitespace/indent',
+        'whitespace/line_length',
+        'whitespace/operators',
+        'whitespace/semicolon',
+        'whitespace/tab',
+        'whitespace/todo']
+
     rules_filter = '--filter=-,+' + ',+'.join(active_rules)
-    print 'Checking ' + str(len(source_paths)) + ' files using filter ' \
-        + rules_filter
     p = subprocess.Popen(
         ['python', 'support/cpplint.py', rules_filter] + source_paths,
         stderr=subprocess.PIPE,
         close_fds=True)
 
     # Lines are stored and filtered, only showing found errors instead
-    # of 'Done processing XXX.' which tends to be dominant output.
-    lint_out_regex = re.compile(':')
+    # of e.g., 'Done processing XXX.' which tends to be dominant output.
     for line in p.stderr:
-        if lint_out_regex.search(line) is not None:
-            sys.stdout.write(line)
+        if re.match('^(Done processing |Total errors found: )', line):
+            continue
+        sys.stderr.write(line)
 
     p.wait()
     return p.returncode
 
+def check_license_header(source_paths):
+    ''' Checks the license headers of the given files. '''
+    error_count = 0
+    for path in source_paths:
+        with open(path) as source_file:
+            head = source_file.readline()
+
+            # Check that opening comment has correct style.
+            # TODO(bbannier) We allow `Copyright` for currently deviating files.
+            # This should be removed one we have a uniform license format.
+            if not re.match(r'^\/\/ [Licensed|Copyright]', head):
+                sys.stderr.write(
+                    "{path}:1:  A license header should appear on the file's "
+                    " first line starting with '// Licensed'.: {head}".\
+                        format(path=path, head=head))
+                error_count += 1
+
+    return error_count
+
 
 if __name__ == '__main__':
     # Verify that source roots are accessible from current working directory.
@@ -77,7 +100,7 @@ if __name__ == '__main__':
     # (possibly nested) paths.
     for source_dir in source_dirs:
         if not os.path.exists(source_dir):
-            print 'Could not find "' + source_dir + '"'
+            print "Could not find '{dir}'".format(dir=source_dir)
             print 'Please run from the root of the mesos source directory'
             exit(1)
 
@@ -87,22 +110,26 @@ if __name__ == '__main__':
         for candidate in find_candidates(source_dir):
             candidates.append(candidate)
 
-    if len(sys.argv) == 1:
-        # No file paths specified, run lint on all candidates.
-        sys.exit(run_lint(candidates))
+    # If file paths are specified, check all file paths that are
+    # candidates; else check all candidates.
+    file_paths = sys.argv[1:] if len(sys.argv) > 1 else candidates
+
+    # Compute the set intersect of the input file paths and candidates.
+    # This represents the reduced set of candidates to run lint on.
+    candidates_set = set(candidates)
+    clean_file_paths_set = set(map(lambda x: x.rstrip(), file_paths))
+    filtered_candidates_set = clean_file_paths_set.intersection(
+        candidates_set)
+
+    if filtered_candidates_set:
+        print 'Checking {num_files} files'.\
+                format(num_files=len(filtered_candidates_set))
+        license_errors = check_license_header(filtered_candidates_set)
+        lint_errors = run_lint(list(filtered_candidates_set))
+        total_errors = license_errors + lint_errors
+        sys.stderr.write('Total errors found: {num_errors}\n'.\
+                            format(num_errors=total_errors))
+        sys.exit(total_errors)
     else:
-        # File paths specified, run lint on all file paths that are candidates.
-        file_paths = sys.argv[1:]
-
-        # Compute the set intersect of the input file paths and candidates.
-        # This represents the reduced set of candidates to run lint on.
-        candidates_set = set(candidates)
-        clean_file_paths_set = set(map(lambda x: x.rstrip(), file_paths))
-        filtered_candidates_set = clean_file_paths_set.intersection(
-            candidates_set)
-
-        if filtered_candidates_set:
-            sys.exit(run_lint(list(filtered_candidates_set)))
-        else:
-            print "No files to lint\n"
-            sys.exit(0)
+        print "No files to lint\n"
+        sys.exit(0)


[3/3] mesos git commit: Made license-headers doxygen-compatible.

Posted by mp...@apache.org.
Made license-headers doxygen-compatible.

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


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

Branch: refs/heads/master
Commit: 75aaaacb89fa961b249c9ab7fa0f45dfa9d415a5
Parents: 13d7cde
Author: Benjamin Bannier <be...@mesosphere.io>
Authored: Thu Dec 3 13:37:52 2015 -0500
Committer: Michael Park <mp...@apache.org>
Committed: Thu Dec 3 13:38:31 2015 -0500

----------------------------------------------------------------------
 src/linux/routing/handle.cpp                    | 32 +++++++++-----------
 src/tests/containerizer/launcher.cpp            | 32 +++++++++-----------
 src/tests/master_quota_tests.cpp                | 32 +++++++++-----------
 src/tests/persistent_volume_endpoints_tests.cpp | 32 +++++++++-----------
 4 files changed, 60 insertions(+), 68 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/75aaaacb/src/linux/routing/handle.cpp
----------------------------------------------------------------------
diff --git a/src/linux/routing/handle.cpp b/src/linux/routing/handle.cpp
index 09589e9..e88c6eb 100644
--- a/src/linux/routing/handle.cpp
+++ b/src/linux/routing/handle.cpp
@@ -1,20 +1,18 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
 
 #include <string>
 #include <vector>

http://git-wip-us.apache.org/repos/asf/mesos/blob/75aaaacb/src/tests/containerizer/launcher.cpp
----------------------------------------------------------------------
diff --git a/src/tests/containerizer/launcher.cpp b/src/tests/containerizer/launcher.cpp
index 22b44ba..a92d989 100644
--- a/src/tests/containerizer/launcher.cpp
+++ b/src/tests/containerizer/launcher.cpp
@@ -1,20 +1,18 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
 
 #include "tests/containerizer/launcher.hpp"
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/75aaaacb/src/tests/master_quota_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/master_quota_tests.cpp b/src/tests/master_quota_tests.cpp
index c9d78cf..7aa116f 100644
--- a/src/tests/master_quota_tests.cpp
+++ b/src/tests/master_quota_tests.cpp
@@ -1,20 +1,18 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
 
 #include <string>
 #include <vector>

http://git-wip-us.apache.org/repos/asf/mesos/blob/75aaaacb/src/tests/persistent_volume_endpoints_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/persistent_volume_endpoints_tests.cpp b/src/tests/persistent_volume_endpoints_tests.cpp
index ac46806..0a03b5f 100644
--- a/src/tests/persistent_volume_endpoints_tests.cpp
+++ b/src/tests/persistent_volume_endpoints_tests.cpp
@@ -1,20 +1,18 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
 
 #include <string>
 #include <vector>


[2/3] mesos git commit: stout: Made license-headers doxygen-compatible.

Posted by mp...@apache.org.
stout: Made license-headers doxygen-compatible.

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


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

Branch: refs/heads/master
Commit: 13d7cde15c250db087e9bfd5cecadd852ad6073b
Parents: 1f64cf1
Author: Benjamin Bannier <be...@mesosphere.io>
Authored: Thu Dec 3 13:38:12 2015 -0500
Committer: Michael Park <mp...@apache.org>
Committed: Thu Dec 3 13:38:31 2015 -0500

----------------------------------------------------------------------
 .../3rdparty/stout/tests/numify_tests.cpp       | 24 +++++++++-----------
 1 file changed, 11 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/13d7cde1/3rdparty/libprocess/3rdparty/stout/tests/numify_tests.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/tests/numify_tests.cpp b/3rdparty/libprocess/3rdparty/stout/tests/numify_tests.cpp
index 40629f4..26fa7a4 100644
--- a/3rdparty/libprocess/3rdparty/stout/tests/numify_tests.cpp
+++ b/3rdparty/libprocess/3rdparty/stout/tests/numify_tests.cpp
@@ -1,16 +1,14 @@
-/**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//  http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
 
 #include <gtest/gtest.h>