Support no-warnings specified in config
This commit is contained in:
@@ -208,7 +208,7 @@ def run(argv=None):
|
|||||||
print(e, file=sys.stderr)
|
print(e, file=sys.stderr)
|
||||||
sys.exit(-1)
|
sys.exit(-1)
|
||||||
prob_level = show_problems(problems, file, args_format=args.format,
|
prob_level = show_problems(problems, file, args_format=args.format,
|
||||||
no_warn=args.no_warnings)
|
no_warn=args.no_warnings or conf.no_warnings)
|
||||||
max_level = max(max_level, prob_level)
|
max_level = max(max_level, prob_level)
|
||||||
|
|
||||||
# read yaml from stdin
|
# read yaml from stdin
|
||||||
@@ -219,7 +219,7 @@ def run(argv=None):
|
|||||||
print(e, file=sys.stderr)
|
print(e, file=sys.stderr)
|
||||||
sys.exit(-1)
|
sys.exit(-1)
|
||||||
prob_level = show_problems(problems, 'stdin', args_format=args.format,
|
prob_level = show_problems(problems, 'stdin', args_format=args.format,
|
||||||
no_warn=args.no_warnings)
|
no_warn=args.no_warnings or conf.no_warnings)
|
||||||
max_level = max(max_level, prob_level)
|
max_level = max(max_level, prob_level)
|
||||||
|
|
||||||
if max_level == PROBLEM_LEVELS['error']:
|
if max_level == PROBLEM_LEVELS['error']:
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ class YamlLintConfig(object):
|
|||||||
'gitwildmatch', ['*.yaml', '*.yml', '.yamllint'])
|
'gitwildmatch', ['*.yaml', '*.yml', '.yamllint'])
|
||||||
|
|
||||||
self.locale = None
|
self.locale = None
|
||||||
|
self.no_warnings = False
|
||||||
|
|
||||||
if file is not None:
|
if file is not None:
|
||||||
with open(file) as f:
|
with open(file) as f:
|
||||||
@@ -119,6 +120,12 @@ class YamlLintConfig(object):
|
|||||||
'invalid config: locale should be a string')
|
'invalid config: locale should be a string')
|
||||||
self.locale = conf['locale']
|
self.locale = conf['locale']
|
||||||
|
|
||||||
|
if 'no-warnings' in conf:
|
||||||
|
if not isinstance(conf['no-warnings'], bool):
|
||||||
|
raise YamlLintConfigError(
|
||||||
|
'invalid config: no-warnings should be a bool')
|
||||||
|
self.no_warnings = bool(conf['no-warnings'])
|
||||||
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
for id in self.rules:
|
for id in self.rules:
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in New Issue
Block a user