mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 13:21:05 +00:00
Bug 1402302 - sync checkers for static-analysis with the mozreview bot. r=sylvestre
MozReview-Commit-ID: I5rn4DEXGOK --HG-- extra : rebase_source : 049079671c84a670718cf2efa2bd1a8c851446cc
This commit is contained in:
parent
cdba57eac5
commit
88b1f10b9f
@ -2196,7 +2196,7 @@ class StaticAnalysis(MachCommandBase):
|
||||
'the analysis is only performed on the files changed '
|
||||
'in the patch streamed through stdin. This is called '
|
||||
'the diff mode.')
|
||||
@CommandArgument('--checks', '-c', default='-*,mozilla-*', metavar='checks',
|
||||
@CommandArgument('--checks', '-c', default='-*', metavar='checks',
|
||||
help='Static analysis checks to enable. By default, this enables only '
|
||||
'custom Mozilla checks, but can be any clang-tidy checks syntax.')
|
||||
@CommandArgument('--jobs', '-j', default='0', metavar='jobs', type=int,
|
||||
@ -2206,7 +2206,7 @@ class StaticAnalysis(MachCommandBase):
|
||||
@CommandArgument('--fix', '-f', default=False, action='store_true',
|
||||
help='Try to autofix errors detected by clang-tidy checkers.')
|
||||
def check(self, source=None, jobs=2, strip=1, verbose=False,
|
||||
checks='-*,mozilla-*', fix=False):
|
||||
checks='-*', fix=False):
|
||||
self._set_log_level(verbose)
|
||||
rc = self._build_compile_db(verbose=verbose)
|
||||
if rc != 0:
|
||||
@ -2222,6 +2222,9 @@ class StaticAnalysis(MachCommandBase):
|
||||
|
||||
python = self.virtualenv_manager.python_path
|
||||
|
||||
if checks == '-*':
|
||||
checks = self._get_checks()
|
||||
|
||||
common_args = ['-clang-tidy-binary', self._clang_tidy_path,
|
||||
'-checks=%s' % checks,
|
||||
'-extra-arg=-DMOZ_CLANG_PLUGIN']
|
||||
@ -2296,6 +2299,21 @@ class StaticAnalysis(MachCommandBase):
|
||||
args = [self._clang_tidy_path, '-list-checks', '-checks=-*,mozilla-*']
|
||||
return self._run_command_in_objdir(args=args, pass_thru=True)
|
||||
|
||||
def _get_checks(self):
|
||||
checks = '-*'
|
||||
import yaml
|
||||
with open(mozpath.join(self.topsrcdir, "tools", "clang-tidy", "config.yaml")) as f:
|
||||
try:
|
||||
config = yaml.load(f)
|
||||
for item in config['clang_checkers']:
|
||||
if item['publish']:
|
||||
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):
|
||||
ran_configure = False
|
||||
config = None
|
||||
|
59
tools/clang-tidy/config.yaml
Normal file
59
tools/clang-tidy/config.yaml
Normal file
@ -0,0 +1,59 @@
|
||||
---
|
||||
target: obj-x86_64-pc-linux-gnu
|
||||
# It is used by 'mach static-analysis' and 'mozreview static-analysis bot'
|
||||
# in order to have consistency across the used checkers.
|
||||
# All the clang checks used by the static-analysis tools.
|
||||
clang_checkers:
|
||||
- name: -*
|
||||
publish: !!bool no
|
||||
- name: clang-analyzer-deadcode.DeadStores
|
||||
publish: !!bool yes
|
||||
- name: clang-analyzer-security.*
|
||||
publish: !!bool no
|
||||
- name: misc-assert-side-effect
|
||||
publish: !!bool yes
|
||||
- name: misc-suspicious-missing-comma
|
||||
publish: !!bool yes
|
||||
- name: misc-suspicious-semicolon
|
||||
publish: !!bool yes
|
||||
- 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-equals-default
|
||||
publish: !!bool yes
|
||||
- name: modernize-use-equals-delete
|
||||
publish: !!bool yes
|
||||
- name: modernize-use-nullptr
|
||||
publish: !!bool yes
|
||||
- name: modernize-use-override
|
||||
publish: !!bool yes
|
||||
- name: mozilla-*
|
||||
publish: !!bool yes
|
||||
- name: performance-*
|
||||
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-uniqueptr-delete-release
|
||||
publish: !!bool yes
|
||||
- name: modernize-use-auto
|
||||
# Controversial, see bug 1371052.
|
||||
publish: !!bool no
|
||||
- name: modernize-use-bool-literals
|
||||
# Too noisy because of `while (0)` in many macros.
|
||||
publish: !!bool no
|
||||
|
||||
# Third party files from mozilla-central
|
||||
third_party: tools/rewriting/ThirdPartyPaths.txt
|
Loading…
Reference in New Issue
Block a user