Implement --only and --exclude flags

This commit is contained in:
Tino de Bruijn 2017-07-28 11:35:20 +02:00
parent 1e26d46d17
commit b485697742
1 changed files with 19 additions and 9 deletions

View File

@ -449,6 +449,16 @@ def run_linters(options, config, extras=[]):
unlintable_filenames = set(all_filenames) - lintable_filenames
# Filter the linter config down to the selected ones.
if 'only' in options:
config = [linter for linter in config
if linter.name in options['only']]
elif 'exclude' in options:
config = [linter for linter in config
if linter.name not in options['exclude']]
if not len(config):
raise RuntimeError('No linters left to run! Be less strict with --only and --exclude.')
working_linter_names, broken_linter_names = get_linter_status(config)
cant_lint_filter = MatchFilter(build_config_subset(