From 91cb70b8af98105e1f9c54733533962ce1214255 Mon Sep 17 00:00:00 2001 From: Leo Feyer Date: Fri, 10 Apr 2020 09:59:29 +0200 Subject: [PATCH] Merge the two if conditions --- yamllint/rules/quoted_strings.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/yamllint/rules/quoted_strings.py b/yamllint/rules/quoted_strings.py index 8ff288d..4ab4f02 100644 --- a/yamllint/rules/quoted_strings.py +++ b/yamllint/rules/quoted_strings.py @@ -128,6 +128,7 @@ def check(conf, token, prev, next, nextnext, context): quote_type = conf['quote-type'] required = conf['required'] + extra_regex = conf['needed-extra-regex'] # Completely relaxed about quotes (same as the rule being disabled) if required is False and quote_type == 'any': @@ -150,12 +151,10 @@ def check(conf, token, prev, next, nextnext, context): # Quotes are disallowed when not needed if (tag == DEFAULT_SCALAR_TAG and token.value - and token.value[0] not in START_TOKENS): - extra_regex = conf['needed-extra-regex'] - - if extra_regex == '' or not re.search(extra_regex, token.value): - msg = "string value is redundantly quoted with %s quotes" % ( - quote_type) + and token.value[0] not in START_TOKENS and (extra_regex == '' + or not re.search(extra_regex, token.value))): + msg = "string value is redundantly quoted with %s quotes" % ( + quote_type) # But when used need to match config elif token.style and not quote_match(quote_type, token.style):