sqlfluff linter adding way too much white space

I just added SQLFluff to our dbt project and was testing it out on some existing code.

I’m getting some unexpected behavior when fixing some code where the fix is adding a ton of extra whitespace and indents.

When I hover over the jinja section, the popup shows that the code is violating rule JJ01: jinja tags should have a single whitespace on either side. However, when I fix all the violations of this rule (by selecting ‘Quick Fix’) a ton of extra whitespace is added to each line so that the code becomes unreadable. Any ideas for what’s happening here?

In my .sqlfluff file I have used the default rules for whitespace

Example code before linting

with month_totals as (
    select date,

    {% for grr_type in grr_types %}
    -- end arr totals:
    sum({{grr_type}}_endarr) as sum_{{grr_type}}_endarr,
    -- churn + contraction totals: 
    sum({{grr_type}}_cc) as sum_{{grr_type}}_cc
    {% if not loop.last %},{% endif %}
    {% endfor %}

    from {{ ref('fct_fpaa__monthly_grr_intermediate') }}
    group by date
    )

Example code after linting

with month_totals as (
    select
        date,

        {% for grr_type in grr_types %}
        -- end arr totals:
        sum({{ grr_type }}_endarr)
                                                                                                                                                as sum_{{ grr_type }}_endarr
            -- churn + contraction totals: 
            , sum({{ grr_type }}_cc)
                                                                                                                                                                                                                                                as sum_{{ grr_type }}_cc
            {% if not loop.last %}
                                            
                                            
                                            ,
                                            {% endif %}
        {% endfor %}

                                                    from
                                                        {{ ref('fct_fpaa__monthly_grr_intermediate') }}
                                                    group by date
                                                )