Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rufo aligns HEREDOCs funny #110

Open
SamSaffron opened this issue Jul 17, 2018 · 5 comments
Open

rufo aligns HEREDOCs funny #110

SamSaffron opened this issue Jul 17, 2018 · 5 comments

Comments

@SamSaffron
Copy link

SamSaffron commented Jul 17, 2018

def a
  test = DB.exec <<~SQL
    UPDATE table set col = 1
  SQL
end

Is aligned:

def a
  test = DB.exec <<~SQL
                   UPDATE table set col = 1
                 SQL
end

Which is somewhat odd... it aligns as expected for DB.exec(<<~SQL)

Note, now the we adopted Prettier for Discourse js I am very very keen to move to rufo, from my tests on a few files this appears to be the biggest point of contention, there is some around params as well cause our rubocop rules currently are at odds with what rufo produces.

@cmatheson
Copy link

I have another example of unexpected heredoc formatting that I think is definitely not desired behavior:

        expect(   
          course_type.resolve(<<~GQL, current_user: @student)
            assignmentsConnection(filter: {gradingPeriodId: null}) { edges { node { _id } } }
          GQL
        ).to match course.assignments.published.map(&:to_param)

becomes

        expect(
          course_type.resolve(<<~GQL, current_user: @student)
            assignmentsConnection(filter: {gradingPeriodId: null}) { edges { node { _id } } }
          GQL
········
).to match course.assignments.published.map(&:to_param)

(the ········ in this case is whitespace that rufo is introducing for whatever reason).

@JonRowe
Copy link

JonRowe commented Nov 2, 2018

Rufo will format HEREDOCs invalidly too, e.g.

Turn this valid, and in my opinion, correctly formatted HEREDOC

    execute (<<-SQL).gsub(/\n\s+/, " ")
       # Some complex SQL migration thats being dedented
    SQL

Into

    execute (<<-SQL
).gsub(/\n\s+/, " ")
       # Some complex SQL migration thats being dedented
    SQL

After it's done this it will then be unable to parse the file again, as it's now not valid Ruby.

@alsemyonov
Copy link

Rufo somehow added very long lines of spaces for some my heredoc strings (and has completely broken tilda heredocs contents with that).

@braindev
Copy link

FWIW I noticed that it will keep adding more indentation each time rufo is run. In other words it doesn't get to a stable formatting. This is with the latest version of rufo at the time of writing this (0.7.0).

@lastobelus
Copy link

I created a new issue #188 specifically for the rowing whitespace issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants