Merge the two if conditions

pull/246/head
Leo Feyer 5 years ago
parent 2296ec63b8
commit 91cb70b8af

@ -128,6 +128,7 @@ def check(conf, token, prev, next, nextnext, context):
quote_type = conf['quote-type'] quote_type = conf['quote-type']
required = conf['required'] required = conf['required']
extra_regex = conf['needed-extra-regex']
# Completely relaxed about quotes (same as the rule being disabled) # Completely relaxed about quotes (same as the rule being disabled)
if required is False and quote_type == 'any': if required is False and quote_type == 'any':
@ -150,10 +151,8 @@ def check(conf, token, prev, next, nextnext, context):
# Quotes are disallowed when not needed # Quotes are disallowed when not needed
if (tag == DEFAULT_SCALAR_TAG and token.value if (tag == DEFAULT_SCALAR_TAG and token.value
and token.value[0] not in START_TOKENS): and token.value[0] not in START_TOKENS and (extra_regex == ''
extra_regex = conf['needed-extra-regex'] or not re.search(extra_regex, token.value))):
if extra_regex == '' or not re.search(extra_regex, token.value):
msg = "string value is redundantly quoted with %s quotes" % ( msg = "string value is redundantly quoted with %s quotes" % (
quote_type) quote_type)

Loading…
Cancel
Save