1 # Copyright 2014 The Chromium Authors. All rights reserved. 2 # Use of this source code is governed by a BSD-style license that can be 3 # found in the LICENSE file. 4 5 """ 6 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts for 7 details on the presubmit API built into gcl. 8 """ 9 10 SOURCE_FILES = (r'^.*\.(cc|h)$') 11 12 def CheckChangeLintsClean(input_api, output_api): 13 input_api.cpplint._cpplint_state.ResetErrorCounts() # reset global state 14 source_filter = lambda x: input_api.FilterSourceFile( 15 x, white_list=SOURCE_FILES, black_list=None) 16 files = [f.AbsoluteLocalPath() for f in 17 input_api.AffectedSourceFiles(source_filter)] 18 level = 1 # strict, but just warn 19 20 for file_name in files: 21 input_api.cpplint.ProcessFile(file_name, level) 22 23 if not input_api.cpplint._cpplint_state.error_count: 24 return [] 25 26 return [output_api.PresubmitPromptWarning( 27 'Changelist failed cpplint.py check.')] 28 29 30 def CheckChangeOnUpload(input_api, output_api): 31 results = [] 32 results += CheckChangeLintsClean(input_api, output_api) 33 return results 34