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

Fix parsing long lines in diffs #967

Merged
merged 5 commits into from Apr 21, 2022

Conversation

Dhertz
Copy link
Contributor

@Dhertz Dhertz commented Jun 8, 2021

Fixes issue if there is a line longer than 4096 characters in a diff. Currently Reviewdog returns 4096 characters over multiple lines, this changes resolves the issue to return just a single (entire) line correctly.

  • Updated Unreleased section in CHANGELOG or it's not notable changes.
    • Bugfix only

if err != nil {
return "", err
}
l = append(l, line...)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need this line because the godoc says that readline consumes remaining content even if the line size reaches size limit.

// readline reads lines from bufio.Reader with size limit. It consumes
// remaining content even if the line size reaches size limit.
func readline(r *bufio.Reader) (string, error) {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So it is intentional to not parse the entire diff if it has long lines?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it's yes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be great to figure this out, as I am happy to modify the comment if this enhancement is going to be accepted

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@haya14busa How do you think about this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sry for the super later reply.

Originally, it's not important for reviewdog to read whole lines in diff because reviewdog only wants to know whether lines are added/changed/deleted to filter diagnostics.

However, we introduced diff format with #699 and reading whole lines in diff is important for suggestion feature.

I'm not sure whether it's realistic to show super-large lines as code suggestions, but we should accept this p-r.

@Dhertz Dhertz requested a review from shogo82148 June 10, 2021 16:28
@haya14busa haya14busa merged commit 356a5ec into reviewdog:master Apr 21, 2022
@review-dog
Copy link
Member

Hi, @Dhertz! We merged your PR to reviewdog! 🐶
Thank you for your contribution! ✨

We just invited you to join the @reviewdog organization on GitHub.
Accept the invite by visiting https://github.com/orgs/reviewdog/invitation.
By joining the team, you'll be a part of reviewdog community and can help the maintenance of reviewdog.

Thanks again!

@shogo82148 shogo82148 mentioned this pull request Sep 2, 2023
1 task
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

Successfully merging this pull request may close these issues.

None yet

4 participants