Fix typo in var name

This commit is contained in:
Benoit Perigaud
2024-04-04 18:38:01 +02:00
parent 490bfb7e30
commit d50146fa4d

View File

@@ -17,13 +17,13 @@
{# we remove the comments that start with -- , or other characters configured #}
{%- set comment_chars_match = "(" ~ var('comment_chars') | join("|") ~ ").*" -%}
{%- set model_raw_sql_co_comments = re.sub(comment_chars_match, '', model_raw_sql) -%}
{%- set model_raw_sql_no_comments = re.sub(comment_chars_match, '', model_raw_sql) -%}
{%- for token, token_cost in var('token_costs').items() -%}
{# this is not 100% perfect but it checks more or less if the token exists as a word by itself or followed by "("" like for least()/greatest() #}
{%- set token_with_boundaries = "\\b" ~ token ~ "[\\t\\r\\n (]" -%}
{%- set all_regex_matches = re.findall(token_with_boundaries, model_raw_sql_co_comments, re.IGNORECASE) -%}
{%- set all_regex_matches = re.findall(token_with_boundaries, model_raw_sql_no_comments, re.IGNORECASE) -%}
{%- set ns.complexity = ns.complexity + token_cost * (all_regex_matches | length) -%}
{%- endfor -%}