Bug 1375861 - [mozlint] Globally exclude paths listed in tools/rewriting/ThirdPartyPaths.txt from our linters, r=sylvestre
authorAndrew Halberstadt <ahalberstadt@mozilla.com>
Thu, 18 Oct 2018 15:27:59 +0000
changeset 500432 1635530c393a0f80512a3cf695fe968eb53562f2
parent 500416 6b1ecbbb842712c0a40d78dd39d5aea0ea615d15
child 500433 b815b16f74a14ce0173bae0000f47ebf5e277e17
push id1864
push userffxbld-merge
push dateMon, 03 Dec 2018 15:51:40 +0000
treeherdermozilla-release@f040763d99ad [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssylvestre
bugs1375861
milestone64.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1375861 - [mozlint] Globally exclude paths listed in tools/rewriting/ThirdPartyPaths.txt from our linters, r=sylvestre Differential Revision: https://phabricator.services.mozilla.com/D9126
python/mozlint/mozlint/parser.py
tools/lint/codespell.yml
tools/lint/cpp-virtual-final.yml
tools/lint/mach_commands.py
tools/lint/mingw-capitalization.yml
tools/lint/py2.yml
tools/lint/py3.yml
tools/lint/test-disable.yml
--- a/python/mozlint/mozlint/parser.py
+++ b/python/mozlint/mozlint/parser.py
@@ -6,16 +6,18 @@ from __future__ import absolute_import
 
 import os
 
 import yaml
 
 from .errors import LinterNotFound, LinterParseError
 from .types import supported_types
 
+GLOBAL_SUPPORT_FILES = []
+
 
 class Parser(object):
     """Reads and validates lint configuration files."""
     required_attributes = (
         'name',
         'description',
         'type',
         'payload',
@@ -98,12 +100,12 @@ class Parser(object):
         if not config:
             raise LinterParseError(path, "No lint definitions found!")
 
         linters = []
         for name, linter in config.iteritems():
             linter['name'] = name
             linter['path'] = path
             self._validate(linter)
-            linter.setdefault('support-files', []).append(path)
+            linter.setdefault('support-files', []).extend(GLOBAL_SUPPORT_FILES + [path])
             linter.setdefault('include', ['.'])
             linters.append(linter)
         return linters
--- a/tools/lint/codespell.yml
+++ b/tools/lint/codespell.yml
@@ -29,18 +29,16 @@ codespell:
         - python/safety/
         - services/sync/locales/en-US/
         - taskcluster/docs/
         - testing/mozbase/docs/
         - toolkit/components/extensions/docs/
         - toolkit/components/telemetry/docs/
         - toolkit/crashreporter/docs/
         - tools/lint/
-    exclude:
-        - third_party
     # List of extensions coming from:
     # tools/lint/{flake8,eslint}.yml
     # tools/mach_commands.py (clang-format)
     # + documentation
     # + localization files
     extensions:
         - js
         - jsm
--- a/tools/lint/cpp-virtual-final.yml
+++ b/tools/lint/cpp-virtual-final.yml
@@ -2,20 +2,16 @@
 cpp-virtual-final:
     description: "Virtual function declarations should specify only one of
                   `virtual`, `final`, or `override`"
     level: error
     include: ['.']
     exclude:
         # Third-party code with cpp-virtual-final warnings:
         - '**/node_modules'
-        - gfx/angle
-        - gfx/skia
-        - media/webrtc/trunk
-        - security/sandbox/chromium
     extensions: ['cpp', 'h', 'mm']
     type: regex
     #
     # This lint warns about:
     #
     #   virtual void Bad1() final
     #   void Bad2() final override
     #   void Bad3() override final
--- a/tools/lint/mach_commands.py
+++ b/tools/lint/mach_commands.py
@@ -15,48 +15,58 @@ from mozbuild.base import (
 from mach.decorators import (
     CommandArgument,
     CommandProvider,
     Command,
 )
 
 
 here = os.path.abspath(os.path.dirname(__file__))
+THIRD_PARTY_PATHS = os.path.join('tools', 'rewriting', 'ThirdPartyPaths.txt')
 GLOBAL_EXCLUDES = [
     'tools/lint/test/files',
 ]
 
 
 def setup_argument_parser():
     from mozlint import cli
     return cli.MozlintParser()
 
 
 def get_global_excludes(topsrcdir):
+    # exclude misc paths
     excludes = GLOBAL_EXCLUDES[:]
+
+    # exclude top level paths that look like objdirs
     excludes.extend([name for name in os.listdir(topsrcdir)
                      if name.startswith('obj') and os.path.isdir(name)])
+
+    # exclude third party paths
+    with open(os.path.join(topsrcdir, THIRD_PARTY_PATHS), 'r') as fh:
+        excludes.extend([f.strip() for f in fh.readlines()])
+
     return excludes
 
 
 @CommandProvider
 class MachCommands(MachCommandBase):
 
     @Command(
         'lint', category='devenv',
         description='Run linters.',
         parser=setup_argument_parser)
     def lint(self, *runargs, **lintargs):
         """Run linters."""
         self._activate_virtualenv()
-        from mozlint import cli
+        from mozlint import cli, parser
 
         lintargs.setdefault('root', self.topsrcdir)
         lintargs['exclude'] = get_global_excludes(lintargs['root'])
         cli.SEARCH_PATHS.append(here)
+        parser.GLOBAL_SUPPORT_FILES.append(os.path.join(self.topsrcdir, THIRD_PARTY_PATHS))
         return cli.run(*runargs, **lintargs)
 
     @Command('eslint', category='devenv',
              description='Run eslint or help configure eslint for optimal development.')
     @CommandArgument('paths', default=None, nargs='*',
                      help="Paths to file or directories to lint, like "
                           "'browser/' Defaults to the "
                           "current directory if not given.")
--- a/tools/lint/mingw-capitalization.yml
+++ b/tools/lint/mingw-capitalization.yml
@@ -2,25 +2,11 @@
 mingw-capitalization:
     description: >
       "A Windows include file is not lowercase, and may break the MinGW build"
     extensions: ['h', 'cpp', 'cc', 'c']
     include: ['.']
     exclude:
         # We do not compile WebRTC with MinGW yet
         - media/webrtc
-        - media/mtransport/third_party/nrappkit/src/util/util.c
-        - gfx/angle/checkout/src/common/tls.cpp
-        - gfx/cairo/cairo/src/cairo-atomic-private.h
-        - gfx/harfbuzz/src/hb-directwrite.cc
-        - gfx/skia/skia/src/xps/SkXPSDevice.cpp
-        - gfx/skia/skia/src/xps/SkXPSDevice.h
-        - gfx/skia/skia/src/xps/SkXPSDocument.h
-        - ipc/chromium/src/third_party/libevent
-        - modules/freetype2/builds/mac/ftmac.c
-        - other-licenses/7zstub
-        - security/nss/nss-tool/common/util.cc
-        - toolkit/crashreporter/google-breakpad/src/tools/windows
-        - toolkit/crashreporter/google-breakpad/src/common/windows
-        - third_party/python/psutil/psutil
     type: external
     level: error
     payload: cpp.mingw-capitalization:lint
--- a/tools/lint/py2.yml
+++ b/tools/lint/py2.yml
@@ -40,17 +40,16 @@ py2:
         - testing/mozharness
         - testing/raptor
         - testing/remotecppunittests.py
         - testing/runcppunittests.py
         - testing/runtimes
         - testing/tools
         - testing/tps
         - testing/web-platform
-        - third_party
         - toolkit
         - tools/docs
         - tools/jprof/split-profile.py
         - tools/lint
         - tools/mach_commands.py
         - tools/power/mach_commands.py
         - tools/profiler
         - tools/rb
--- a/tools/lint/py3.yml
+++ b/tools/lint/py3.yml
@@ -8,41 +8,36 @@ py3:
         - browser/extensions
         - build
         - client.py
         - config
         - dom/bindings
         - dom/canvas/test
         - dom/media/test
         - gfx
-        - intl/icu
-        - ipc/chromium
         - ipc/ipdl
         - js/src
         - layout/reftests
         - layout/style
         - layout/tools/reftest
         - media
         - memory/replace
         - modules/freetype2
-        - nsprpub
         - python/safety
         - security/manager/ssl
-        - security/nss
         - servo
         - testing/awsy
         - testing/firefox-ui/harness/firefox_ui_harness/runners/update.py
         - testing/gtest
         - testing/mochitest
         - testing/mozharness
         - testing/raptor
         - testing/tools/iceserver
         - testing/tps
         - testing/web-platform
-        - third_party
         - toolkit
         - tools/jprof
         - tools/profiler
         - tools/rb
         - tools/update-packaging
         - xpcom/idl-parser
     extensions: ['py']
     support-files:
--- a/tools/lint/test-disable.yml
+++ b/tools/lint/test-disable.yml
@@ -5,13 +5,12 @@ no-comment-disable:
       comment"
     include: ['.']
     exclude:
         - "**/application.ini"
         - "**/l10n.ini"
         - dom/canvas/test/webgl-conf/mochitest-errata.ini
         - testing/mozbase/manifestparser/tests
         - testing/web-platform
-        - third_party
         - xpcom/tests/unit/data
     extensions: ['ini']
     type: regex
     payload: ^[ \t]*(#|;)[ \t]*\[