# sqlfluff linter adding way too much white space

**URL:** <https://discourse.getdbt.com/t/sqlfluff-linter-adding-way-too-much-white-space/13383>\
**Category:** Help\
**Tags:** jinja\
**Created:** [May 15, 2024, 10:55pm UTC](https://discourse.getdbt.com/t/sqlfluff-linter-adding-way-too-much-white-space/13383 "2024-05-15T22:55:35Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![audessy](https://avatars.discourse-cdn.com/v4/letter/a/7ab992/32.png) [@audessy](https://discourse.getdbt.com/u/audessy)\
**Post date:** [May 15, 2024, 10:55pm UTC](https://discourse.getdbt.com/t/sqlfluff-linter-adding-way-too-much-white-space/13383/1 "2024-05-15T22:55:35Z")

</div>

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](https://docs.sqlfluff.com/en/stable/rules.html#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

```auto
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

```auto
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
                                                )

```

 ![Screenshot 2024-05-15 at 3.48.48 PM](https://us1.discourse-cdn.com/flex020/uploads/getdbt/original/2X/c/c9f4b2308b898ec4e842f9586ba71e622128254e.png)
