Skip to content

Mixture of line endings #278

Open
Open
@coryschwartz

Description

@coryschwartz

Yesterday, I submitted a PR and I struggled to make a succinct PR.

Although I was editing only a single line in a single file, my editor automatically re-wrote the entire file, adding Windows line endings too every line.

It turns out that this repo has a .editorconfig that mandates crlf line endings, but since most files do not have this line ending, editors that follow this file will automatically apply this change.

The reason this is a problem is that it makes it difficult to write small PRs that do not involve editing every line in the file.

Here is the offending line: https://github.com/go-oauth2/oauth2/blob/master/.editorconfig#L2

Steps to reproduce:

  1. Use an editor that abides by crlf line endings. (I'm using neovim v0.10.2)
  2. cat -A $(filename) to observe line endings
  3. Edit any of the many files that have Unix line endings. Add a single empty line, for example.
    1. git diff -- observe that every line in the entire file has been edited.

Observation

Most of the .go files have Unix line endings. Only four files actually adhere to the behavior expected in .editorconfig.

$ find . -name '*.go' -exec file "{}" ";" | grep -c "with CRLF line terminators"
4

My Recommendation

I think you should just remove the .editorconfig file. I can't think of any reason why it's needed. but if it is needed, then you should probably convert the files to have CRLF line endings.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions