From f39c33382a0ddf7b242ebee54a5e3098707d57ca Mon Sep 17 00:00:00 2001 From: agable Date: Mon, 26 Sep 2016 09:35:42 -0700 Subject: [PATCH] Use a whitelist for depot_tools pylint instead R=maruel@chromium.org BUG=644995 Review-Url: https://codereview.chromium.org/2353393004 --- PRESUBMIT.py | 34 ++++++++++++++++------------------ cpplint.py | 2 ++ 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/PRESUBMIT.py b/PRESUBMIT.py index ce1aea69c..f082fb010 100644 --- a/PRESUBMIT.py +++ b/PRESUBMIT.py @@ -12,22 +12,15 @@ import fnmatch import os -def CommonChecks(input_api, output_api, tests_to_black_list): - results = [] - results.extend(input_api.canned_checks.CheckOwners(input_api, output_api)) - black_list = list(input_api.DEFAULT_BLACK_LIST) + [ - r'^\.recipe_deps[\/\\].*', - r'^infra[\/\\]\.recipe_deps[\/\\].*', - r'^cpplint\.py$', - r'^cpplint_chromium\.py$', - r'^external_bin[\/\\].+', - r'^python[0-9]*_bin[\/\\].+', - r'^recipes\.py$', - r'^site-packages-py[0-9]\.[0-9][\/\\].+', - r'^svn_bin[\/\\].+', - r'^testing_support[\/\\]_rietveld[\/\\].+', - r'^testing_support[\/\\]_infra[\/\\].+', +def DepotToolsPylint(input_api, output_api): + """Gather all the pylint logic into one place to make it self-contained.""" + white_list = [ + r'^[^/]*\.py$', + r'^testing_support/[^/]*\.py$', + r'^tests/[^/]*\.py$', + r'^recipe_modules/.*\.py$', # Allow recursive search in recipe modules. ] + black_list = list(input_api.DEFAULT_BLACK_LIST) if os.path.exists('.gitignore'): with open('.gitignore') as fh: lines = [l.strip() for l in fh.readlines()] @@ -42,21 +35,26 @@ def CommonChecks(input_api, output_api, tests_to_black_list): 'R0401', # Cyclic import 'W0613', # Unused argument ] - pylint = input_api.canned_checks.GetPylint( + return input_api.canned_checks.GetPylint( input_api, output_api, - white_list=[r'.*\.py$'], + white_list=white_list, black_list=black_list, disabled_warnings=disabled_warnings) + + +def CommonChecks(input_api, output_api, tests_to_black_list): + results = [] + results.extend(input_api.canned_checks.CheckOwners(input_api, output_api)) # TODO(maruel): Make sure at least one file is modified first. # TODO(maruel): If only tests are modified, only run them. + tests = DepotToolsPylint(input_api, output_api) unit_tests = input_api.canned_checks.GetUnitTestsInDirectory( input_api, output_api, 'tests', whitelist=[r'.*test\.py$'], blacklist=tests_to_black_list) - tests = pylint if not input_api.platform.startswith(('cygwin', 'win32')): tests.extend(unit_tests) else: diff --git a/cpplint.py b/cpplint.py index f74eff79f..6d23859f3 100755 --- a/cpplint.py +++ b/cpplint.py @@ -28,6 +28,8 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# pylint: skip-file + """Does google-lint on c++ files. The goal of this script is to identify places in the code that *may*