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

should return a error but return a nil value error #616

Open
alingse opened this issue Dec 15, 2024 · 0 comments
Open

should return a error but return a nil value error #616

alingse opened this issue Dec 15, 2024 · 0 comments

Comments

@alingse
Copy link

alingse commented Dec 15, 2024

Describe the bug

https://github.com/charmbracelet/soft-serve/blob/main/pkg/web/git.go#L472
code in here should return a new err

		nRead, err := r.Read(p)
		if err == io.EOF {
			break
		}
		nWrite, err := f.ResponseWriter.Write(p[:nRead])
		if err != nil {
			return n, err
		}
		if nRead != nWrite {
			return n, err
		}

the err is nil , but here need return a new err

see golang io.Copy implement here
https://github.com/golang/go/blob/master/src/io/io.go#L431-L445

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Environment (please complete the following information):

  • OS: [e.g. Linux]
  • Terminal [e.g. kitty, iterm2, gnome-terminal]
  • Version [e.g. v0.4.0]

Additional context
Add any other context about the problem here.

I create a linter to detect code that returns a non-relevant nilness error bug. I checked the top 1000 GitHub Go repositories and found this, all result listed in alingse/sundrylint#4

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

1 participant