# HG changeset patch # User Andi-Bogdan Postelnicu # Date 1535537454 0 # Wed Aug 29 10:10:54 2018 +0000 # Node ID adbee46f307f7bc4617735c425398b3b87e9994e # Parent 9f51c11758e462e10c6d148927cf5a389a54cabf Bug 1486729 - [Static-Analysis][Clang-Tidy] As default, a checker should be publish by default. r=sylvestre Differential Revision: https://phabricator.services.mozilla.com/D4436 diff --git a/python/mozbuild/mozbuild/mach_commands.py b/python/mozbuild/mozbuild/mach_commands.py --- a/python/mozbuild/mozbuild/mach_commands.py +++ b/python/mozbuild/mozbuild/mach_commands.py @@ -1952,22 +1952,30 @@ class StaticAnalysis(MachCommandBase): self._clang_tidy_checks = [c.strip() for c in available_checks if c] # Build the dummy compile_commands.json self._compilation_commands_path = self._create_temp_compilation_db(config) with concurrent.futures.ThreadPoolExecutor(max_workers=max_workers) as executor: futures = [] for item in config['clang_checkers']: - # Do not test mozilla specific checks nor the default '-*' - if not (item['publish'] and ('restricted-platforms' in item - and platform not in item['restricted-platforms'] - or 'restricted-platforms' not in item) - and item['name'] not in ['mozilla-*', '-*'] and - (checker_names == [] or item['name'] in checker_names)): + # Skip if any of the following statements is true: + # 1. Checker attribute 'publish' is False. + not_published = not bool(item.get('publish', True)) + # 2. Checker has restricted-platforms and current platform is not of them. + ignored_platform = 'restricted-platforms' in item and platform not in item['restricted-platforms'] + # 3. Checker name is mozilla-* or -*. + ignored_checker = item['name'] in ['mozilla-*', '-*'] + # 4. List checker_names is passed and the current checker is not part of the + # list or 'publish' is False + checker_not_in_list = checker_names and (item['name'] not in checker_names or not_published) + if not_published or \ + ignored_platform or \ + ignored_checker or \ + checker_not_in_list: continue futures.append(executor.submit(self._verify_checker, item)) for future in concurrent.futures.as_completed(futures): ret_val = future.result() if ret_val != self.TOOLS_SUCCESS: # Also delete the tmp folder shutil.rmtree(self._compilation_commands_path) @@ -2169,17 +2177,17 @@ class StaticAnalysis(MachCommandBase): def _get_checks(self): checks = '-*' import yaml with open(mozpath.join(self.topsrcdir, "tools", "clang-tidy", "config.yaml")) as f: try: config = yaml.safe_load(f) for item in config['clang_checkers']: - if item['publish']: + if item.get('publish', True): checks += ',' + item['name'] except Exception: print('Looks like config.yaml is not valid, so we are unable to ' 'determine default checkers, using \'-checks=-*,mozilla-*\'') checks += ',mozilla-*' return checks def _get_config_environment(self): diff --git a/tools/clang-tidy/config.yaml b/tools/clang-tidy/config.yaml --- a/tools/clang-tidy/config.yaml +++ b/tools/clang-tidy/config.yaml @@ -7,132 +7,81 @@ platforms: - macosx64 - linux64 - win64 - win32 clang_checkers: - name: -* publish: !!bool no - name: bugprone-argument-comment - publish: !!bool yes - name: bugprone-assert-side-effect - publish: !!bool yes - name: bugprone-bool-pointer-implicit-conversion - publish: !!bool yes - name: bugprone-forward-declaration-namespace - publish: !!bool yes - name: bugprone-macro-repeated-side-effects - publish: !!bool yes - name: bugprone-string-constructor - publish: !!bool yes - name: bugprone-string-integer-assignment - publish: !!bool yes - name: bugprone-suspicious-memset-usage - publish: !!bool yes - name: bugprone-suspicious-missing-comma - publish: !!bool yes - name: bugprone-suspicious-semicolon - publish: !!bool yes - name: bugprone-swapped-arguments - publish: !!bool yes - name: bugprone-unused-raii - publish: !!bool yes - name: clang-analyzer-cplusplus.NewDelete - publish: !!bool yes - name: clang-analyzer-cplusplus.NewDeleteLeaks - publish: !!bool yes - name: clang-analyzer-deadcode.DeadStores - publish: !!bool yes - name: clang-analyzer-security.FloatLoopCounter - publish: !!bool yes - name: clang-analyzer-security.insecureAPI.getpw - publish: !!bool yes # We don't add clang-analyzer-security.insecureAPI.gets here; it's deprecated. - name: clang-analyzer-security.insecureAPI.mkstemp - publish: !!bool yes - name: clang-analyzer-security.insecureAPI.mktemp - publish: !!bool yes - name: clang-analyzer-security.insecureAPI.rand publish: !!bool no - name: clang-analyzer-security.insecureAPI.strcpy publish: !!bool no - name: clang-analyzer-security.insecureAPI.UncheckedReturn - publish: !!bool yes - name: clang-analyzer-security.insecureAPI.vfork - publish: !!bool yes - name: clang-analyzer-unix.Malloc - publish: !!bool yes - name: clang-analyzer-unix.cstring.BadSizeArg - publish: !!bool yes - name: clang-analyzer-unix.cstring.NullArg - publish: !!bool yes - name: misc-unused-alias-decls - publish: !!bool yes - name: misc-unused-using-decls - publish: !!bool yes - name: modernize-avoid-bind - publish: !!bool yes restricted-platforms: - win32 - win64 - name: modernize-loop-convert - publish: !!bool yes - name: modernize-raw-string-literal - publish: !!bool yes - name: modernize-redundant-void-arg publish: !!bool no - name: modernize-shrink-to-fit - publish: !!bool yes - name: modernize-use-auto # Controversial, see bug 1371052. publish: !!bool no - name: modernize-use-bool-literals - publish: !!bool yes - name: modernize-use-equals-default - publish: !!bool yes - name: modernize-use-equals-delete - publish: !!bool yes - name: modernize-use-nullptr - publish: !!bool yes - name: modernize-use-override # Too noisy because of the way how we implement NS_IMETHOD. See Bug 1420366. publish: !!bool no - name: mozilla-* - publish: !!bool yes - name: performance-faster-string-find - publish: !!bool yes - name: performance-for-range-copy - publish: !!bool yes # Only available from clang tidy 6.0. We are currently using 5.0 # - name: performance-implicit-conversion-in-loop - # publish: !!bool yes - name: performance-inefficient-string-concatenation - publish: !!bool yes - name: performance-inefficient-vector-operation - publish: !!bool yes - name: performance-type-promotion-in-math-fn - publish: !!bool yes - name: performance-unnecessary-copy-initialization - publish: !!bool yes - name: performance-unnecessary-value-param - publish: !!bool yes - name: readability-container-size-empty - publish: !!bool yes - name: readability-else-after-return - publish: !!bool yes - name: readability-misleading-indentation - publish: !!bool yes - name: readability-redundant-control-flow - publish: !!bool yes - name: readability-redundant-smartptr-get publish: !!bool no - name: readability-redundant-string-cstr - publish: !!bool yes - name: readability-redundant-string-init - publish: !!bool yes - name: readability-uniqueptr-delete-release - publish: !!bool yes # Only available from clang tidy 6.0. We are currently using 5.0 # - name: readability-static-accessed-through-instance -# publish: !!bool yes # Third party files from mozilla-central third_party: tools/rewriting/ThirdPartyPaths.txt